Files
app_Settings/tests/robotests/src/com/android/settings/DisplaySettingsTest.java
Doris Ling 6f60cddc9e Add a new feature flag for the expand button in support lib.
- check the feature flag to determine whether to use the existing
progressive disclosure mixin or use the expand button in the support
library.
- add corresponding preference xml files that add the new preference
group attribute to use with the expand button in the support lib.

Bug: 63985174
Test: make RunSettingsRoboTests
Change-Id: Ida6eb6182a8066ad1413b7f6142512345fd914d0
2017-09-15 11:56:31 -07:00

48 lines
1.8 KiB
Java

package com.android.settings;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
import android.content.Context;
import com.android.settings.dashboard.ProgressiveDisclosureMixin;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.XmlTestUtils;
import com.android.settings.testutils.shadow.ShadowPowerManagerWrapper;
import com.android.settingslib.core.AbstractPreferenceController;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class DisplaySettingsTest {
@Test
@Config(shadows = ShadowPowerManagerWrapper.class)
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
final Context context = RuntimeEnvironment.application;
final DisplaySettings fragment = new DisplaySettings();
ReflectionHelpers.setField(fragment, "mProgressiveDisclosureMixin",
mock(ProgressiveDisclosureMixin.class));
final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context,
fragment.getPreferenceScreenResId());
final List<String> preferenceKeys = new ArrayList<>();
for (AbstractPreferenceController controller : fragment.getPreferenceControllers(context)) {
preferenceKeys.add(controller.getPreferenceKey());
}
// Nightmode is currently hidden
preferenceKeys.remove("night_mode");
assertThat(preferenceScreenKeys).containsAllIn(preferenceKeys);
}
}