Index: chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java |
diff --git a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java |
index 71016f8aa197c072379b53773e0d49f49cea4151..496f87d24e6ddb7a706741b54e47be09f02f303d 100644 |
--- a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java |
+++ b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java |
@@ -12,13 +12,17 @@ import android.preference.Preference; |
import android.preference.SwitchPreference; |
import android.preference.TwoStatePreference; |
import android.test.suitebuilder.annotation.SmallTest; |
+import android.view.View; |
+import android.widget.ListView; |
import org.chromium.base.ThreadUtils; |
import org.chromium.base.test.util.Feature; |
+import org.chromium.chrome.browser.sync.ui.PassphraseTypeDialogFragment; |
import org.chromium.chrome.browser.sync.ui.SyncCustomizationFragment; |
import org.chromium.chrome.shell.R; |
import org.chromium.chrome.test.util.browser.sync.SyncTestUtil; |
import org.chromium.sync.AndroidSyncSettings; |
+import org.chromium.sync.internal_api.pub.PassphraseType; |
import org.chromium.sync.internal_api.pub.base.ModelType; |
import java.util.Collection; |
@@ -138,6 +142,12 @@ public class SyncCustomizationFragmentTest extends SyncTestBase { |
assertFalse(mAndroidSyncSettings.isChromeSyncEnabled()); |
} |
+ /** |
+ * Make sure that the encryption UI presents the correct options. |
+ * |
+ * By default it should show the CUSTOM and KEYSTORE options, in that order. |
+ * KEYSTORE should be selected but both should be enabled. |
+ */ |
@SmallTest |
@Feature({"Sync"}) |
public void testSettingDataTypes() throws Exception { |
@@ -167,6 +177,33 @@ public class SyncCustomizationFragmentTest extends SyncTestBase { |
assertDataTypesAre(expectedTypes); |
} |
+ @SmallTest |
+ @Feature({"Sync"}) |
+ public void testDefaultEncryptionOptions() throws Exception { |
+ setupTestAccountAndSignInToSync(CLIENT_ID); |
+ startSync(); |
+ SyncCustomizationFragment fragment = startSyncCustomizationFragment(); |
+ Preference encryption = getEncryption(fragment); |
+ clickPreference(encryption); |
+ |
+ PassphraseTypeDialogFragment typeFragment = getPassphraseTypeDialogFragment(); |
+ ListView listView = (ListView) typeFragment.getDialog() |
+ .findViewById(R.id.passphrase_type_list); |
+ PassphraseTypeDialogFragment.Adapter adapter = |
+ (PassphraseTypeDialogFragment.Adapter) listView.getAdapter(); |
+ |
+ // Confirm that correct types show up in the correct order. |
+ assertEquals(PassphraseType.CUSTOM_PASSPHRASE, adapter.getType(0)); |
+ assertEquals(PassphraseType.KEYSTORE_PASSPHRASE, adapter.getType(1)); |
+ assertEquals(2, listView.getCount()); |
+ // Make sure they are both enabled and the correct on is selected. |
+ View customView = listView.getChildAt(0); |
+ View keystoreView = listView.getChildAt(1); |
+ assertTrue(customView.isEnabled()); |
+ assertTrue(keystoreView.isEnabled()); |
+ assertEquals(keystoreView, listView.getSelectedView()); |
+ } |
+ |
private SyncCustomizationFragment startSyncCustomizationFragment() { |
SyncCustomizationFragment fragment = new SyncCustomizationFragment(); |
Bundle args = new Bundle(); |
@@ -217,6 +254,11 @@ public class SyncCustomizationFragmentTest extends SyncTestBase { |
SyncCustomizationFragment.PREFERENCE_SYNC_MANAGE_DATA); |
} |
+ private PassphraseTypeDialogFragment getPassphraseTypeDialogFragment() { |
+ return (PassphraseTypeDialogFragment) mActivity.getFragmentManager() |
+ .findFragmentByTag(SyncCustomizationFragment.FRAGMENT_PASSWORD_TYPE); |
+ } |
+ |
private void assertDefaultSyncOnState(SyncCustomizationFragment fragment) { |
assertTrue("The sync switch should be on.", getSyncSwitch(fragment).isChecked()); |
assertTrue("The sync switch should be enabled.", getSyncSwitch(fragment).isEnabled()); |
@@ -279,4 +321,14 @@ public class SyncCustomizationFragmentTest extends SyncTestBase { |
}); |
getInstrumentation().waitForIdleSync(); |
} |
+ |
+ private void clickPreference(final Preference pref) { |
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
+ @Override |
+ public void run() { |
+ pref.getOnPreferenceClickListener().onPreferenceClick(pref); |
+ } |
+ }); |
+ getInstrumentation().waitForIdleSync(); |
+ } |
} |