+ public void adjustInitialExpandedChildCount_invalidInput_shouldNotadjust() {
+ HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(null /* host */);
+ HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(mFragment);
+ final Bundle args = new Bundle();
+ when(mFragment.getArguments()).thenReturn(args);
+ HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(mFragment);
+ final PreferenceScreen screen = mock(PreferenceScreen.class);
+ when(mFragment.getArguments()).thenReturn(null);
+ when(mFragment.getPreferenceScreen()).thenReturn(screen);
+ HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(mFragment);
+ verifyZeroInteractions(screen);
+ }
+
+ @Test
+ public void adjustInitialExpandedChildCount_hasHightlightKey_shouldExpandAllChildren() {
+ final Bundle args = new Bundle();
+ when(mFragment.getArguments()).thenReturn(args);
+ args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, "testkey");
+ final PreferenceScreen screen = mock(PreferenceScreen.class);
+ when(mFragment.getPreferenceScreen()).thenReturn(screen);
+ HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(mFragment);
+
+ verify(screen).setInitialExpandedChildrenCount(Integer.MAX_VALUE);
+ }
+
+ @Test
+ public void adjustInitialExpandedChildCount_noKeyOrChildCountOverride_shouldDoNothing() {
+ final Bundle args = new Bundle();
+ when(mFragment.getArguments()).thenReturn(args);
+ when(mFragment.getInitialExpandedChildCount()).thenReturn(-1);
+ final PreferenceScreen screen = mock(PreferenceScreen.class);
+ when(mFragment.getPreferenceScreen()).thenReturn(screen);
+ HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(mFragment);
+
+ verify(mFragment).getInitialExpandedChildCount();
+ verifyZeroInteractions(screen);
+ }
+
+ @Test
+ public void adjustInitialExpandedChildCount_hasCountOverride_shouldDoNothing() {
+ when(mFragment.getInitialExpandedChildCount()).thenReturn(10);
+ final PreferenceScreen screen = mock(PreferenceScreen.class);
+ when(mFragment.getPreferenceScreen()).thenReturn(screen);
+ HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(mFragment);
+
+ verify(mFragment).getInitialExpandedChildCount();
+
+ verify(screen).setInitialExpandedChildrenCount(10);
+ }
+
+ @Test