LocaleManager { void notifyLocaleChanged(Locale locale) { for (LocaleChangedListener listener : localeChangedListeners) { listener.onLocaleChanged(locale); } } @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)  LocaleManager(@NonNull Context context, @NonNull PreferenceDataStore preferenceDataStore); void addListener(@NonNull LocaleChangedListener listener); void removeListener(@NonNull LocaleChangedListener listener); void setLocaleOverride(@Nullable Locale locale); @NonNull Locale getLocale(); static final String LOCALE_OVERRIDE_LANGUAGE_KEY; static final String LOCALE_OVERRIDE_COUNTRY_KEY; static final String LOCALE_OVERRIDE_VARIANT_KEY; }
@Test public void testNotifyLocaleChanged() { Locale en = new Locale("en"); context.getResources().getConfiguration().setLocale(en); LocaleChangedListener listener = mock(LocaleChangedListener.class); localeManager.addListener(listener); localeManager.onDeviceLocaleChanged(); verify(listener).onLocaleChanged(en); }