Search in sources :

Example 16 with GearPreference

use of com.android.settings.widget.GearPreference in project platform_packages_apps_Settings by BlissRoms.

the class CurrentDreamPreferenceControllerTest method gearShowsIfActiveDreamInfoHasOptions.

@Test
public void gearShowsIfActiveDreamInfoHasOptions() {
    mDreamInfo.settingsComponentName = mock(ComponentName.class);
    mDreamInfo.isActive = true;
    when(mBackend.getDreamInfos()).thenReturn(new ArrayList<>(Arrays.asList(mDreamInfo)));
    GearPreference mockPref = mock(GearPreference.class);
    ArgumentCaptor<GearPreference.OnGearClickListener> captor = ArgumentCaptor.forClass(GearPreference.OnGearClickListener.class);
    // verify that updateState sets a non-null gear click listener
    mController.updateState(mockPref);
    verify(mockPref).setOnGearClickListener(captor.capture());
    captor.getAllValues().forEach(listener -> assertThat(listener).isNotNull());
}
Also used : GearPreference(com.android.settings.widget.GearPreference) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 17 with GearPreference

use of com.android.settings.widget.GearPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class CurrentDreamPreferenceControllerTest method gearShowsIfActiveDreamInfoHasOptions.

@Test
public void gearShowsIfActiveDreamInfoHasOptions() {
    mDreamInfo.settingsComponentName = mock(ComponentName.class);
    mDreamInfo.isActive = true;
    when(mBackend.getDreamInfos()).thenReturn(Collections.singletonList(mDreamInfo));
    GearPreference mockPref = mock(GearPreference.class);
    ArgumentCaptor<GearPreference.OnGearClickListener> captor = ArgumentCaptor.forClass(GearPreference.OnGearClickListener.class);
    // verify that updateState sets a non-null gear click listener
    mController.updateState(mockPref);
    verify(mockPref).setOnGearClickListener(captor.capture());
    captor.getAllValues().forEach(listener -> assertThat(listener).isNotNull());
}
Also used : GearPreference(com.android.settings.widget.GearPreference) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 18 with GearPreference

use of com.android.settings.widget.GearPreference in project android_packages_apps_Settings by LineageOS.

the class CurrentDreamPreferenceController method setGearClickListenerForPreference.

private void setGearClickListenerForPreference(Preference preference) {
    if (!(preference instanceof GearPreference))
        return;
    GearPreference gearPreference = (GearPreference) preference;
    Optional<DreamInfo> info = getActiveDreamInfo();
    if (!info.isPresent() || info.get().settingsComponentName == null) {
        gearPreference.setOnGearClickListener(null);
        return;
    }
    gearPreference.setOnGearClickListener(gearPref -> launchScreenSaverSettings());
}
Also used : GearPreference(com.android.settings.widget.GearPreference) DreamInfo(com.android.settingslib.dream.DreamBackend.DreamInfo)

Example 19 with GearPreference

use of com.android.settings.widget.GearPreference in project android_packages_apps_Settings by LineageOS.

the class CurrentDreamPreferenceControllerTest method gearShowsIfActiveDreamInfoHasOptions.

@Test
public void gearShowsIfActiveDreamInfoHasOptions() {
    mDreamInfo.settingsComponentName = mock(ComponentName.class);
    mDreamInfo.isActive = true;
    when(mBackend.getDreamInfos()).thenReturn(new ArrayList<>(Arrays.asList(mDreamInfo)));
    GearPreference mockPref = mock(GearPreference.class);
    ArgumentCaptor<GearPreference.OnGearClickListener> captor = ArgumentCaptor.forClass(GearPreference.OnGearClickListener.class);
    // verify that updateState sets a non-null gear click listener
    mController.updateState(mockPref);
    verify(mockPref).setOnGearClickListener(captor.capture());
    captor.getAllValues().forEach(listener -> assertThat(listener).isNotNull());
}
Also used : GearPreference(com.android.settings.widget.GearPreference) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 20 with GearPreference

use of com.android.settings.widget.GearPreference in project android_packages_apps_Settings by omnirom.

the class CurrentDreamPreferenceControllerTest method gearShowsIfActiveDreamInfoHasOptions.

@Test
public void gearShowsIfActiveDreamInfoHasOptions() {
    mDreamInfo.settingsComponentName = mock(ComponentName.class);
    mDreamInfo.isActive = true;
    when(mBackend.getDreamInfos()).thenReturn(new ArrayList<>(Arrays.asList(mDreamInfo)));
    GearPreference mockPref = mock(GearPreference.class);
    ArgumentCaptor<GearPreference.OnGearClickListener> captor = ArgumentCaptor.forClass(GearPreference.OnGearClickListener.class);
    // verify that updateState sets a non-null gear click listener
    mController.updateState(mockPref);
    verify(mockPref).setOnGearClickListener(captor.capture());
    captor.getAllValues().forEach(listener -> assertThat(listener).isNotNull());
}
Also used : GearPreference(com.android.settings.widget.GearPreference) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Aggregations

GearPreference (com.android.settings.widget.GearPreference)34 Test (org.junit.Test)14 Preference (android.support.v7.preference.Preference)11 ComponentName (android.content.ComponentName)7 ContentResolver (android.content.ContentResolver)7 EngineInfo (android.speech.tts.TextToSpeech.EngineInfo)7 SettingsActivity (com.android.settings.SettingsActivity)7 SeekBarPreference (com.android.settings.widget.SeekBarPreference)7 DreamInfo (com.android.settingslib.dream.DreamBackend.DreamInfo)7 ListPreference (android.support.v7.preference.ListPreference)6 LayoutPreference (com.android.settings.applications.LayoutPreference)6 Activity (android.app.Activity)5 PersistableBundle (android.os.PersistableBundle)5 UserManager (android.os.UserManager)5 SwitchPreference (android.support.v14.preference.SwitchPreference)5 PreferenceGroup (android.support.v7.preference.PreferenceGroup)5 PreferenceScreen (android.support.v7.preference.PreferenceScreen)5 CarrierConfigManager (android.telephony.CarrierConfigManager)5 TelephonyManager (android.telephony.TelephonyManager)5 RestrictedPreference (com.android.settingslib.RestrictedPreference)5