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

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

Issue 1247853007: [Sync] Add auto-generated ModelType in Java. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add SYNC_EXPORT and rebase. Created 5 years, 5 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 7c7f4d16e41f76779410f9cc79627fdec6c85704..18c10f86e515dcfe0f4629bd85b7ef2bc83cad33 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
@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.sync;
+import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.app.FragmentTransaction;
@@ -30,12 +31,12 @@ 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;
import org.chromium.sync.AndroidSyncSettings;
+import org.chromium.sync.ModelType;
import org.chromium.sync.internal_api.pub.PassphraseType;
-import org.chromium.sync.internal_api.pub.base.ModelType;
import java.util.Collection;
-import java.util.EnumSet;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
@@ -43,6 +44,7 @@ import java.util.concurrent.Callable;
/**
* Tests for SyncCustomizationFragment.
*/
+@SuppressLint("UseSparseArrays")
public class SyncCustomizationFragmentTest extends SyncTestBase {
private static final String TAG = "SyncCustomizationFragmentTest";
private static final String TEST_ACCOUNT = "test@gmail.com";
@@ -50,17 +52,17 @@ public class SyncCustomizationFragmentTest extends SyncTestBase {
/**
* Maps ModelTypes to their UI element IDs.
*/
- private static final Map<ModelType, String> UI_DATATYPES;
+ private static final Map<Integer, String> UI_DATATYPES;
static {
- UI_DATATYPES = new HashMap<ModelType, String>();
+ UI_DATATYPES = new HashMap<Integer, String>();
UI_DATATYPES.put(ModelType.AUTOFILL, SyncCustomizationFragment.PREFERENCE_SYNC_AUTOFILL);
- UI_DATATYPES.put(ModelType.BOOKMARK, SyncCustomizationFragment.PREFERENCE_SYNC_BOOKMARKS);
- UI_DATATYPES.put(ModelType.TYPED_URL, SyncCustomizationFragment.PREFERENCE_SYNC_OMNIBOX);
- UI_DATATYPES.put(ModelType.PASSWORD, SyncCustomizationFragment.PREFERENCE_SYNC_PASSWORDS);
+ UI_DATATYPES.put(ModelType.BOOKMARKS, SyncCustomizationFragment.PREFERENCE_SYNC_BOOKMARKS);
+ UI_DATATYPES.put(ModelType.TYPED_URLS, SyncCustomizationFragment.PREFERENCE_SYNC_OMNIBOX);
+ UI_DATATYPES.put(ModelType.PASSWORDS, SyncCustomizationFragment.PREFERENCE_SYNC_PASSWORDS);
UI_DATATYPES.put(ModelType.PROXY_TABS,
SyncCustomizationFragment.PREFERENCE_SYNC_RECENT_TABS);
- UI_DATATYPES.put(ModelType.PREFERENCE,
+ UI_DATATYPES.put(ModelType.PREFERENCES,
SyncCustomizationFragment.PREFERENCE_SYNC_SETTINGS);
}
@@ -176,7 +178,7 @@ public class SyncCustomizationFragmentTest extends SyncTestBase {
SyncTestUtil.waitForSyncActive(mContext);
SyncCustomizationFragment fragment = startSyncCustomizationFragment();
SwitchPreference syncEverything = getSyncEverything(fragment);
- Map<ModelType, CheckBoxPreference> dataTypes = getDataTypes(fragment);
+ Map<Integer, CheckBoxPreference> dataTypes = getDataTypes(fragment);
assertDefaultSyncOnState(fragment);
togglePreference(syncEverything);
@@ -185,19 +187,19 @@ public class SyncCustomizationFragmentTest extends SyncTestBase {
assertTrue(dataType.isEnabled());
}
- Set<ModelType> expectedTypes = EnumSet.copyOf(dataTypes.keySet());
+ Set<Integer> expectedTypes = new HashSet<Integer>(dataTypes.keySet());
// TODO(zea): update this once preferences are supported.
- expectedTypes.remove(ModelType.PREFERENCE);
- expectedTypes.add(ModelType.PRIORITY_PREFERENCE);
+ expectedTypes.remove(ModelType.PREFERENCES);
+ expectedTypes.add(ModelType.PRIORITY_PREFERENCES);
assertDataTypesAre(expectedTypes);
togglePreference(dataTypes.get(ModelType.AUTOFILL));
- togglePreference(dataTypes.get(ModelType.PASSWORD));
+ togglePreference(dataTypes.get(ModelType.PASSWORDS));
// Nothing should have changed before the fragment closes.
assertDataTypesAre(expectedTypes);
closeFragment(fragment);
expectedTypes.remove(ModelType.AUTOFILL);
- expectedTypes.remove(ModelType.PASSWORD);
+ expectedTypes.remove(ModelType.PASSWORDS);
assertDataTypesAre(expectedTypes);
}
@@ -367,11 +369,11 @@ public class SyncCustomizationFragmentTest extends SyncTestBase {
SyncCustomizationFragment.PREFERENCE_SYNC_EVERYTHING);
}
- private Map<ModelType, CheckBoxPreference> getDataTypes(SyncCustomizationFragment fragment) {
- Map<ModelType, CheckBoxPreference> dataTypes =
- new HashMap<ModelType, CheckBoxPreference>();
- for (Map.Entry<ModelType, String> uiDataType : UI_DATATYPES.entrySet()) {
- ModelType modelType = uiDataType.getKey();
+ private Map<Integer, CheckBoxPreference> getDataTypes(SyncCustomizationFragment fragment) {
+ Map<Integer, CheckBoxPreference> dataTypes =
+ new HashMap<Integer, CheckBoxPreference>();
+ for (Map.Entry<Integer, String> uiDataType : UI_DATATYPES.entrySet()) {
+ Integer modelType = uiDataType.getKey();
String prefId = uiDataType.getValue();
dataTypes.put(modelType, (CheckBoxPreference) fragment.findPreference(prefId));
}
@@ -432,16 +434,16 @@ public class SyncCustomizationFragmentTest extends SyncTestBase {
getManageData(fragment).isEnabled());
}
- private void assertDataTypesAre(final Set<ModelType> enabledDataTypes) {
- final Set<ModelType> disabledDataTypes = EnumSet.copyOf(UI_DATATYPES.keySet());
+ private void assertDataTypesAre(final Set<Integer> enabledDataTypes) {
+ final Set<Integer> disabledDataTypes = new HashSet<Integer>(UI_DATATYPES.keySet());
disabledDataTypes.removeAll(enabledDataTypes);
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
- Set<ModelType> actualDataTypes = mProfileSyncService.getPreferredDataTypes();
+ Set<Integer> actualDataTypes = mProfileSyncService.getPreferredDataTypes();
assertTrue(actualDataTypes.containsAll(enabledDataTypes));
// There is no Set.containsNone(), sadly.
- for (ModelType disabledDataType : disabledDataTypes) {
+ for (Integer disabledDataType : disabledDataTypes) {
assertFalse(actualDataTypes.contains(disabledDataType));
}
}

Powered by Google App Engine
This is Rietveld 408576698