Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3108)

Unified Diff: chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java

Issue 1285373007: Revert of Convert ChromeSyncShell to use ChromePublic infrastructure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 3335ed541b145e8609a57f649a2b4701e9e9c451..11b7b53fd694147fe96e102429c7c0d1db11138e 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
@@ -5,30 +5,30 @@
package org.chromium.chrome.browser.sync;
import android.annotation.SuppressLint;
+import android.app.Activity;
import android.app.Dialog;
import android.app.FragmentTransaction;
import android.content.Context;
+import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.SwitchPreference;
import android.preference.TwoStatePreference;
import android.support.v7.app.AlertDialog;
import android.test.suitebuilder.annotation.SmallTest;
+import android.view.View;
import android.widget.Button;
-import android.widget.CheckedTextView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature;
-import org.chromium.chrome.R;
-import org.chromium.chrome.browser.preferences.Preferences;
import org.chromium.chrome.browser.sync.ui.PassphraseCreationDialogFragment;
import org.chromium.chrome.browser.sync.ui.PassphraseDialogFragment;
import org.chromium.chrome.browser.sync.ui.PassphraseTypeDialogFragment;
import org.chromium.chrome.browser.sync.ui.SyncCustomizationFragment;
-import org.chromium.chrome.test.util.ActivityUtils;
+import org.chromium.chrome.shell.R;
import org.chromium.chrome.test.util.browser.sync.SyncTestUtil;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
@@ -88,12 +88,12 @@
SyncCustomizationFragment.PREFERENCE_SYNC_SETTINGS);
}
- private Preferences mPreferences;
+ private Activity mActivity;
@Override
protected void setUp() throws Exception {
super.setUp();
- mPreferences = null;
+ mActivity = getActivity();
}
@SmallTest
@@ -236,7 +236,7 @@
public void testDefaultEncryptionOptions() throws Exception {
setupTestAccountAndSignInToSync(CLIENT_ID);
SyncTestUtil.waitForSyncActive(mContext);
- final SyncCustomizationFragment fragment = startSyncCustomizationFragment();
+ SyncCustomizationFragment fragment = startSyncCustomizationFragment();
Preference encryption = getEncryption(fragment);
clickPreference(encryption);
@@ -250,14 +250,12 @@
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 one is selected.
- CheckedTextView customView = (CheckedTextView) listView.getChildAt(0);
- CheckedTextView keystoreView = (CheckedTextView) listView.getChildAt(1);
- assertTrue("The custom passphrase view should be enabled.", customView.isEnabled());
- assertFalse("The custom passphrase option should be checked.", customView.isChecked());
- assertTrue("The keystore passphrase view should be enabled.", keystoreView.isEnabled());
- assertTrue("The keystore passphrase option should be checked.", keystoreView.isChecked());
+ // 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());
}
/**
@@ -334,9 +332,8 @@
public void run() {
pss.syncStateChanged();
fragment.getFragmentManager().executePendingTransactions();
- assertNull("PassphraseDialogFragment should be dismissed.",
- mPreferences.getFragmentManager().findFragmentByTag(
- SyncCustomizationFragment.FRAGMENT_ENTER_PASSPHRASE));
+ PassphraseDialogFragment passphraseFragment = getPassphraseDialogFragment();
+ assertNull(passphraseFragment);
}
});
}
@@ -412,13 +409,20 @@
}
private SyncCustomizationFragment startSyncCustomizationFragment() {
- mPreferences = startPreferences(SyncCustomizationFragment.class.getName());
- getInstrumentation().waitForIdleSync();
- return (SyncCustomizationFragment) mPreferences.getFragmentForTest();
+ SyncCustomizationFragment fragment = new SyncCustomizationFragment();
+ Bundle args = new Bundle();
+ args.putString(SyncCustomizationFragment.ARGUMENT_ACCOUNT,
+ SyncTestUtil.DEFAULT_TEST_ACCOUNT);
+ fragment.setArguments(args);
+ FragmentTransaction transaction = mActivity.getFragmentManager().beginTransaction();
+ transaction.add(R.id.content_container, fragment, TAG);
+ transaction.commit();
+ getInstrumentation().waitForIdleSync();
+ return fragment;
}
private void closeFragment(SyncCustomizationFragment fragment) {
- FragmentTransaction transaction = mPreferences.getFragmentManager().beginTransaction();
+ FragmentTransaction transaction = mActivity.getFragmentManager().beginTransaction();
transaction.remove(fragment);
transaction.commit();
getInstrumentation().waitForIdleSync();
@@ -455,22 +459,19 @@
SyncCustomizationFragment.PREFERENCE_SYNC_MANAGE_DATA);
}
- private PassphraseDialogFragment getPassphraseDialogFragment()
- throws InterruptedException {
- return ActivityUtils.<PassphraseDialogFragment>waitForFragment(mPreferences,
+ private PassphraseDialogFragment getPassphraseDialogFragment() {
+ return (PassphraseDialogFragment) mActivity.getFragmentManager().findFragmentByTag(
SyncCustomizationFragment.FRAGMENT_ENTER_PASSPHRASE);
}
- private PassphraseTypeDialogFragment getPassphraseTypeDialogFragment()
- throws InterruptedException {
- return ActivityUtils.<PassphraseTypeDialogFragment>waitForFragment(mPreferences,
- SyncCustomizationFragment.FRAGMENT_PASSPHRASE_TYPE);
- }
-
- private PassphraseCreationDialogFragment getPassphraseCreationDialogFragment()
- throws InterruptedException {
- return ActivityUtils.<PassphraseCreationDialogFragment>waitForFragment(mPreferences,
- SyncCustomizationFragment.FRAGMENT_CUSTOM_PASSPHRASE);
+ private PassphraseTypeDialogFragment getPassphraseTypeDialogFragment() {
+ return (PassphraseTypeDialogFragment) mActivity.getFragmentManager()
+ .findFragmentByTag(SyncCustomizationFragment.FRAGMENT_PASSPHRASE_TYPE);
+ }
+
+ private PassphraseCreationDialogFragment getPassphraseCreationDialogFragment() {
+ return (PassphraseCreationDialogFragment) mActivity.getFragmentManager()
+ .findFragmentByTag(SyncCustomizationFragment.FRAGMENT_CUSTOM_PASSPHRASE);
}
private void assertDefaultSyncOnState(SyncCustomizationFragment fragment) {

Powered by Google App Engine
This is Rietveld 408576698