Example #1
0
  public void test02_TestListPreferences() {
    SharedPreferences preferences =
        mActivity.getSharedPreferences(
            VideoTelephony.ENGINEER_MODE_PREFERENCE, WorkingMode.MODE_WORLD_READABLE);
    assertNotNull(preferences);
    ListPreference audioChanneAdaptPref =
        (ListPreference) mActivity.findPreference(AUDIO_CHANNEL_ADAPTATION);
    assertNotNull(audioChanneAdaptPref);
    audioChanneAdaptPref
        .getOnPreferenceChangeListener()
        .onPreferenceChange(audioChanneAdaptPref, "3");
    assertEquals(preferences.getString(VideoTelephony.CONFIG_AUDIO_CHANNEL_ADAPT, "0"), "3");

    ListPreference videoChanneAdaptlPref =
        (ListPreference) mActivity.findPreference(VIDEO_CHANNEL_ADAPTATION);
    assertNotNull(videoChanneAdaptlPref);
    videoChanneAdaptlPref
        .getOnPreferenceChangeListener()
        .onPreferenceChange(videoChanneAdaptlPref, "3");
    assertEquals(preferences.getString(VideoTelephony.CONFIG_VIDEO_CHANNEL_ADAPT, "0"), "3");

    ListPreference videoChanneRevPref =
        (ListPreference) mActivity.findPreference(VIDEO_CHANNEL_REV);
    assertNotNull(videoChanneRevPref);
    videoChanneRevPref.getOnPreferenceChangeListener().onPreferenceChange(videoChanneRevPref, "1");
    assertEquals(preferences.getString(VideoTelephony.CONFIG_VIDEO_CHANNEL_REVERSE, "0"), "1");

    ListPreference multiPref = (ListPreference) mActivity.findPreference(MULTIPLE_LEVEL);
    assertNotNull(multiPref);
    multiPref.getOnPreferenceChangeListener().onPreferenceChange(multiPref, "3");
    assertEquals(preferences.getString(VideoTelephony.CONFIG_MULTIPLEX_LEVEL, "0"), "3");

    ListPreference videoCdecPref = (ListPreference) mActivity.findPreference(VIDEO_CODEC);
    assertNotNull(videoCdecPref);
    videoCdecPref.getOnPreferenceChangeListener().onPreferenceChange(videoCdecPref, "1");
    assertEquals(preferences.getString(VideoTelephony.CONFIG_VIDEO_CODEC_PREFERENCE, "0"), "1");

    ListPreference useWnsrpPref = (ListPreference) mActivity.findPreference(USE_WNSRP);
    assertNotNull(useWnsrpPref);
    useWnsrpPref.getOnPreferenceChangeListener().onPreferenceChange(useWnsrpPref, "1");
    assertEquals(preferences.getString(VideoTelephony.CONFIG_USE_WNSRP, "0"), "1");

    ListPreference terminalTypePref = (ListPreference) mActivity.findPreference(TERMINAL_TYPE);
    assertNotNull(terminalTypePref);
    terminalTypePref.getOnPreferenceChangeListener().onPreferenceChange(terminalTypePref, "1");
    assertEquals(preferences.getString(VideoTelephony.CONFIG_TERMINAL_TYPE, "0"), "1");
  }
 @SuppressWarnings("deprecation")
 public Preference findPreference(CharSequence key) {
   return preferenceGroup == null
       ? preferenceActivity.findPreference(key)
       : preferenceGroup.findPreference(key);
 }
 @SuppressWarnings("deprecation")
 public Preference findPreference(
     final PreferenceActivity preferenceActivity, final CharSequence key) {
   return preferenceActivity.findPreference(key);
 }