@Test public void testForceMakeKeyboardsOnAddOnsPrefChange() { SharedPrefsHelper.setPrefsValue(KeyboardAddOnAndBuilder.KEYBOARD_PREF_PREFIX + "test", false); Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher()).flushKeyboardsCache(); Mockito.reset(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher()); SharedPrefsHelper.setPrefsValue("dictionary_test", false); Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher()).flushKeyboardsCache(); Mockito.reset(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher()); SharedPrefsHelper.setPrefsValue( RuntimeEnvironment.application.getString(R.string.settings_key_active_quick_text_key), "dummy"); Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher()).flushKeyboardsCache(); Mockito.reset(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher()); // sanity SharedPrefsHelper.setPrefsValue("random", "dummy"); Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher(), Mockito.never()) .flushKeyboardsCache(); }
@Test public void testForceMakeKeyboardsUiPrefChange() { SharedPrefsHelper.setPrefsValue( RuntimeEnvironment.application.getString(R.string.settings_key_keyboard_theme_key), "ac8ea510-ca66-11e1-9b23-0800200c9a66"); Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher()).flushKeyboardsCache(); Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher()) .setInputView(Mockito.isNotNull(AnyKeyboardView.class)); Mockito.reset(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher()); SharedPrefsHelper.setPrefsValue( RuntimeEnvironment.application.getString(R.string.settings_key_smiley_icon_on_smileys_key), "dummy"); Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher(), Mockito.never()) .flushKeyboardsCache(); SharedPrefsHelper.setPrefsValue( RuntimeEnvironment.application.getString(R.string.settings_key_default_split_state), "dummy"); Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher(), Mockito.never()) .flushKeyboardsCache(); }
@Test public void testDoNotFlushKeyboardsOnRowAddOnsPrefChange() { SharedPrefsHelper.setPrefsValue( RuntimeEnvironment.application.getString(R.string.settings_key_ext_kbd_bottom_row_key), "dummy"); Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher(), Mockito.never()) .flushKeyboardsCache(); SharedPrefsHelper.setPrefsValue( RuntimeEnvironment.application.getString(R.string.settings_key_ext_kbd_top_row_key), "dummy"); Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher(), Mockito.never()) .flushKeyboardsCache(); SharedPrefsHelper.setPrefsValue( RuntimeEnvironment.application.getString(R.string.settings_key_ext_kbd_ext_ketboard_key), "dummy"); Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher(), Mockito.never()) .flushKeyboardsCache(); SharedPrefsHelper.setPrefsValue( RuntimeEnvironment.application.getString( R.string.settings_key_ext_kbd_hidden_bottom_row_key), "dummy"); Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedKeyboardSwitcher(), Mockito.never()) .flushKeyboardsCache(); }