PreferenceTitles { @StringRes int getTitleRes(String preferenceKey) { final Integer res = titleResources.get(preferenceKey); return res == null ? 0 : res; } PreferenceTitles(@NonNull Resources resources, @XmlRes int preferenceRes);   }
@Test public void testParseValidKey() { final int res = subject.getTitleRes("com.zegoggles.smssync.activity.fragments.AutoBackupSettings"); assertThat(res).isGreaterThan(0); String resolved = RuntimeEnvironment.application.getString(res); assertThat(resolved).isEqualTo("Auto backup settings"); }
@Test public void testInvalidKeyReturnsZero() { final int res = subject.getTitleRes("foo.bar.not.found"); assertThat(res).isEqualTo(0); }