summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTony Mantler <nicoya@google.com>2014-06-17 16:25:01 -0700
committerTony Mantler <nicoya@google.com>2014-06-17 16:26:25 -0700
commit9b4df381c0a1197d8381134181c6c12087a90e2f (patch)
treed353fc3680f4171ae56dd183d8de306de9f18f8b /tests
parent119f5a51d761c7e28670898526240b89cb0d071e (diff)
downloadandroid_packages_apps_UnifiedEmail-9b4df381c0a1197d8381134181c6c12087a90e2f.tar.gz
android_packages_apps_UnifiedEmail-9b4df381c0a1197d8381134181c6c12087a90e2f.tar.bz2
android_packages_apps_UnifiedEmail-9b4df381c0a1197d8381134181c6c12087a90e2f.zip
Sort of port over tests for GeneralPrefsFragment
b/9566150 Change-Id: Ifcbd0d36b6214cf9babe804a1fe1f379bd06865a
Diffstat (limited to 'tests')
-rw-r--r--tests/Android.mk2
-rw-r--r--tests/src/com/android/mail/ui/settings/GeneralPrefsFragmentTest.java100
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());
+ */
+ }
+
+}