diff options
author | Tony Mantler <nicoya@google.com> | 2014-06-18 17:24:17 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-06-18 16:45:13 +0000 |
commit | 4701eca710ec88f656e43226d0878da2be0fe7a7 (patch) | |
tree | 02b5447f1058203d77a927bb1265d7e922152843 /tests | |
parent | 3ecca77461c181474162acada1d956f45d6cdbb6 (diff) | |
parent | 9b4df381c0a1197d8381134181c6c12087a90e2f (diff) | |
download | android_packages_apps_UnifiedEmail-4701eca710ec88f656e43226d0878da2be0fe7a7.tar.gz android_packages_apps_UnifiedEmail-4701eca710ec88f656e43226d0878da2be0fe7a7.tar.bz2 android_packages_apps_UnifiedEmail-4701eca710ec88f656e43226d0878da2be0fe7a7.zip |
Merge "Sort of port over tests for GeneralPrefsFragment" into ub-mail-master
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Android.mk | 2 | ||||
-rw-r--r-- | tests/src/com/android/mail/ui/settings/GeneralPrefsFragmentTest.java | 100 |
2 files changed, 101 insertions, 1 deletions
diff --git a/tests/Android.mk b/tests/Android.mk index 06efb23c2..be4845b61 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE_TAGS := tests # LOCAL_JAVA_LIBRARIES := android.test.runner -LOCAL_SDK_VERSION := 14 +LOCAL_SDK_VERSION := current LOCAL_PACKAGE_NAME := UnifiedEmailTests LOCAL_INSTRUMENTATION_FOR := UnifiedEmail diff --git a/tests/src/com/android/mail/ui/settings/GeneralPrefsFragmentTest.java b/tests/src/com/android/mail/ui/settings/GeneralPrefsFragmentTest.java new file mode 100644 index 000000000..c1a531123 --- /dev/null +++ b/tests/src/com/android/mail/ui/settings/GeneralPrefsFragmentTest.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (C) 2014 Google Inc. + * Licensed to The Android Open Source Project. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ + +package com.android.mail.ui.settings; + +import android.app.Activity; +import android.content.Intent; +import android.preference.PreferenceActivity; +import android.test.ActivityInstrumentationTestCase2; +import android.test.UiThreadTest; +import android.test.suitebuilder.annotation.MediumTest; +import android.test.suitebuilder.annotation.Suppress; + +// TODO: Insert the unified prefs class here once it's written +@Suppress +public class GeneralPrefsFragmentTest + extends ActivityInstrumentationTestCase2<Activity> { + + public GeneralPrefsFragmentTest() { + super(Activity.class); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + + final Intent i = new Intent(); + i.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, "com.android.mail.ui.settings."); + setActivityIntent(i); + getActivity(); + } + + @UiThreadTest + @MediumTest + public void testChangeAutoAdvance() throws Throwable { + // A weak proxy test that a click on auto-advance will actually persist the proper value. + // A better test would simulate a dialog, dialog click, and check that the value is + // both displayed and persisted. + /* + final Activity activity = getActivity(); + final MailPrefs mailPrefs = MailPrefs.get(activity); + + activity.getFragmentManager().executePendingTransactions(); + + final GeneralPrefsFragment fragment = activity.getGeneralPrefsFragment(); + final ListPreference autoAdvancePref = (ListPreference) fragment + .findPreference(GeneralPrefsFragment.AUTO_ADVANCE_WIDGET); + + fragment.onPreferenceChange(autoAdvancePref, UIProvider.AUTO_ADVANCE_MODE_OLDER); + + assertEquals(AutoAdvance.OLDER, mailPrefs.getAutoAdvanceMode()); + + fragment.onPreferenceChange(autoAdvancePref, UIProvider.AUTO_ADVANCE_MODE_NEWER); + + assertEquals(AutoAdvance.NEWER, mailPrefs.getAutoAdvanceMode()); + */ + } + + @UiThreadTest + @MediumTest + public void testChangeSnapHeader() throws Throwable { + /* + final Activity activity = getActivity(); + final MailPrefs mailPrefs = MailPrefs.get(activity); + + activity.getFragmentManager().executePendingTransactions(); + + final GeneralPrefsFragment fragment = activity.getGeneralPrefsFragment(); + final ListPreference snapPref = (ListPreference) fragment + .findPreference(GeneralPrefsFragment.SNAP_HEADER_MODE_WIDGET); + + final int neverValue = GeneralPrefsFragment.prefValueToWidgetIndex( + GeneralPrefsFragment.SNAP_HEADER_VALUES, SnapHeaderValue.NEVER, -1); + snapPref.setValueIndex(neverValue); + + assertEquals(SnapHeaderValue.NEVER, mailPrefs.getSnapHeaderMode()); + + final int alwaysValue = GeneralPrefsFragment.prefValueToWidgetIndex( + GeneralPrefsFragment.SNAP_HEADER_VALUES, SnapHeaderValue.ALWAYS, -1); + snapPref.setValueIndex(alwaysValue); + + assertEquals(SnapHeaderValue.ALWAYS, mailPrefs.getSnapHeaderMode()); + */ + } + +} |