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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/preferences/PreferencesTest.java

Issue 1698043006: Created the dialog offering the user to merge their account data or keep it (Closed) Base URL: maybelle.lon.corp.google.com:/usr/local/google/code/clankium/src@sync_settings
Patch Set: Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.preferences; 5 package org.chromium.chrome.browser.preferences;
6 6
7 import android.accounts.Account;
8 import android.app.Activity; 7 import android.app.Activity;
9 import android.app.DialogFragment;
10 import android.app.Instrumentation; 8 import android.app.Instrumentation;
11 import android.content.Context; 9 import android.content.Context;
12 import android.content.Intent; 10 import android.content.Intent;
13 import android.preference.Preference; 11 import android.preference.Preference;
14 import android.preference.PreferenceFragment; 12 import android.preference.PreferenceFragment;
15 import android.preference.PreferenceScreen; 13 import android.preference.PreferenceScreen;
16 import android.test.suitebuilder.annotation.SmallTest; 14 import android.test.suitebuilder.annotation.SmallTest;
17 15
18 import org.chromium.base.ThreadUtils; 16 import org.chromium.base.ThreadUtils;
19 import org.chromium.base.test.util.DisabledTest; 17 import org.chromium.base.test.util.DisabledTest;
20 import org.chromium.base.test.util.Feature; 18 import org.chromium.base.test.util.Feature;
21 import org.chromium.chrome.browser.accessibility.FontSizePrefs; 19 import org.chromium.chrome.browser.accessibility.FontSizePrefs;
22 import org.chromium.chrome.browser.preferences.website.ContentSetting; 20 import org.chromium.chrome.browser.preferences.website.ContentSetting;
23 import org.chromium.chrome.browser.preferences.website.GeolocationInfo; 21 import org.chromium.chrome.browser.preferences.website.GeolocationInfo;
24 import org.chromium.chrome.browser.preferences.website.WebsitePreferenceBridge; 22 import org.chromium.chrome.browser.preferences.website.WebsitePreferenceBridge;
25 import org.chromium.chrome.browser.search_engines.TemplateUrlService; 23 import org.chromium.chrome.browser.search_engines.TemplateUrlService;
26 import org.chromium.chrome.browser.search_engines.TemplateUrlService.LoadListene r; 24 import org.chromium.chrome.browser.search_engines.TemplateUrlService.LoadListene r;
27 import org.chromium.chrome.browser.search_engines.TemplateUrlService.TemplateUrl ; 25 import org.chromium.chrome.browser.search_engines.TemplateUrlService.TemplateUrl ;
28 import org.chromium.chrome.browser.signin.SigninManager;
29 import org.chromium.chrome.browser.sync.ui.ChooseAccountFragment;
30 import org.chromium.content.browser.test.NativeLibraryTestBase; 26 import org.chromium.content.browser.test.NativeLibraryTestBase;
31 import org.chromium.content.browser.test.util.CallbackHelper; 27 import org.chromium.content.browser.test.util.CallbackHelper;
32 import org.chromium.content.browser.test.util.UiUtils; 28 import org.chromium.content.browser.test.util.UiUtils;
33 import org.chromium.sync.signin.AccountManagerHelper;
34 import org.chromium.sync.test.util.MockAccountManager;
35 import org.chromium.sync.test.util.SimpleFuture;
36 29
37 import java.lang.reflect.InvocationTargetException; 30 import java.lang.reflect.InvocationTargetException;
38 import java.lang.reflect.Method; 31 import java.lang.reflect.Method;
39 import java.text.NumberFormat; 32 import java.text.NumberFormat;
40 import java.util.List; 33 import java.util.List;
41 34
42 /** 35 /**
43 * Tests for the Settings menu. 36 * Tests for the Settings menu.
44 */ 37 */
45 public class PreferencesTest extends NativeLibraryTestBase { 38 public class PreferencesTest extends NativeLibraryTestBase {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 onTemplateUrlServiceLoadedHelper.waitForCallback(0); 205 onTemplateUrlServiceLoadedHelper.waitForCallback(0);
213 } 206 }
214 207
215 private ContentSetting locationPermissionForSearchEngine(int index) { 208 private ContentSetting locationPermissionForSearchEngine(int index) {
216 String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemp lateUrl(index); 209 String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemp lateUrl(index);
217 GeolocationInfo locationSettings = new GeolocationInfo(url, null, false) ; 210 GeolocationInfo locationSettings = new GeolocationInfo(url, null, false) ;
218 ContentSetting locationPermission = locationSettings.getContentSetting() ; 211 ContentSetting locationPermission = locationSettings.getContentSetting() ;
219 return locationPermission; 212 return locationPermission;
220 } 213 }
221 214
222 /**
223 * Tests that double-clicking on sign-in doesn't show two sign-in prompts.
224 *
225 * This is a regression test for http://crbug.com/515055.
226 */
227 @SmallTest
228 @Feature({"Preferences"})
229 public void testDoubleSignin() throws Exception {
230 // Sets up state so that displayAccountPicker() shows a ChooseAccountFra gment.
231 setUpTestAccount();
232 final Preferences prefActivity = startPreferences(getInstrumentation(),
233 MainPreferences.class.getName());
234 final MainPreferences mainPrefs = (MainPreferences) prefActivity.getFrag mentForTest();
235
236 DialogFragment fragment1 = displayAccountPicker(mainPrefs);
237 DialogFragment fragment2 = displayAccountPicker(mainPrefs);
238 assertTrue(fragment1 instanceof ChooseAccountFragment);
239 assertNull(fragment2);
240 }
241
242 private DialogFragment displayAccountPicker(final MainPreferences mainPrefs)
243 throws InterruptedException {
244 final SimpleFuture<DialogFragment> result = new SimpleFuture<DialogFragm ent>();
245 ThreadUtils.runOnUiThread(new Runnable() {
246 public void run() {
247 mainPrefs.displayAccountPicker(result.createCallback());
248 }
249 });
250 return result.get();
251 }
252
253 private void setUpTestAccount() {
254 final Context context = getInstrumentation().getTargetContext();
255 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
256 @Override
257 public void run() {
258 SigninManager.get(context).onFirstRunCheckDone();
259 }
260 });
261 Account account = AccountManagerHelper.createAccountFromName("test@chrom ium.org");
262 MockAccountManager accountManager = new MockAccountManager(context, cont ext, account);
263 AccountManagerHelper.overrideAccountManagerHelperForTests(context, accou ntManager);
264 }
265
266 // TODO(mvanouwerkerk): Write new preference intent tests for notification s ettings. 215 // TODO(mvanouwerkerk): Write new preference intent tests for notification s ettings.
267 // https://crbug.com/461885 216 // https://crbug.com/461885
268 217
269 /** 218 /**
270 * Tests setting FontScaleFactor and ForceEnableZoom in AccessibilityPrefere nces and ensures 219 * Tests setting FontScaleFactor and ForceEnableZoom in AccessibilityPrefere nces and ensures
271 * that ForceEnableZoom changes corresponding to FontScaleFactor. 220 * that ForceEnableZoom changes corresponding to FontScaleFactor.
272 */ 221 */
273 @SmallTest 222 @SmallTest
274 @Feature({"Accessibility"}) 223 @Feature({"Accessibility"})
275 public void testAccessibilityPreferences() throws Exception { 224 public void testAccessibilityPreferences() throws Exception {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 private static void userSetForceEnableZoom(final AccessibilityPreferences ac cessibilityPref, 292 private static void userSetForceEnableZoom(final AccessibilityPreferences ac cessibilityPref,
344 final SeekBarLinkedCheckBoxPreference forceEnableZoomPref, final boo lean enabled) { 293 final SeekBarLinkedCheckBoxPreference forceEnableZoomPref, final boo lean enabled) {
345 ThreadUtils.runOnUiThread(new Runnable() { 294 ThreadUtils.runOnUiThread(new Runnable() {
346 @Override 295 @Override
347 public void run() { 296 public void run() {
348 accessibilityPref.onPreferenceChange(forceEnableZoomPref, enable d); 297 accessibilityPref.onPreferenceChange(forceEnableZoomPref, enable d);
349 } 298 }
350 }); 299 });
351 } 300 }
352 } 301 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698