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

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

Issue 2406453002: Require Google Play Services in ChromeBackupIntegrationTest. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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; 5 package org.chromium.chrome.browser;
6 6
7 import android.accounts.Account; 7 import android.accounts.Account;
8 import android.annotation.TargetApi; 8 import android.annotation.TargetApi;
9 import android.content.Context; 9 import android.content.Context;
10 import android.content.SharedPreferences; 10 import android.content.SharedPreferences;
11 import android.os.Build; 11 import android.os.Build;
12 import android.test.suitebuilder.annotation.SmallTest; 12 import android.test.suitebuilder.annotation.SmallTest;
13 13
14 import org.chromium.base.ContextUtils; 14 import org.chromium.base.ContextUtils;
15 import org.chromium.base.StreamUtil; 15 import org.chromium.base.StreamUtil;
16 import org.chromium.base.ThreadUtils; 16 import org.chromium.base.ThreadUtils;
17 import org.chromium.base.test.util.CommandLineFlags; 17 import org.chromium.base.test.util.CommandLineFlags;
18 import org.chromium.base.test.util.MinAndroidSdkLevel; 18 import org.chromium.base.test.util.MinAndroidSdkLevel;
19 import org.chromium.base.test.util.Restriction;
19 import org.chromium.chrome.browser.firstrun.FirstRunSignInProcessor; 20 import org.chromium.chrome.browser.firstrun.FirstRunSignInProcessor;
20 import org.chromium.chrome.browser.firstrun.FirstRunStatus; 21 import org.chromium.chrome.browser.firstrun.FirstRunStatus;
21 import org.chromium.chrome.browser.init.ChromeBrowserInitializer; 22 import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
22 import org.chromium.chrome.browser.signin.AccountIdProvider; 23 import org.chromium.chrome.browser.signin.AccountIdProvider;
23 import org.chromium.chrome.test.ChromeTabbedActivityTestBase; 24 import org.chromium.chrome.test.ChromeTabbedActivityTestBase;
25 import org.chromium.chrome.test.util.ChromeRestriction;
24 import org.chromium.components.signin.AccountManagerHelper; 26 import org.chromium.components.signin.AccountManagerHelper;
25 import org.chromium.components.signin.ChromeSigninController; 27 import org.chromium.components.signin.ChromeSigninController;
26 import org.chromium.components.signin.test.util.MockAccountManager; 28 import org.chromium.components.signin.test.util.MockAccountManager;
27 29
28 import java.io.File; 30 import java.io.File;
29 import java.io.FileInputStream; 31 import java.io.FileInputStream;
30 import java.io.FileNotFoundException; 32 import java.io.FileNotFoundException;
31 import java.io.FileOutputStream; 33 import java.io.FileOutputStream;
32 import java.io.IOException; 34 import java.io.IOException;
33 import java.io.UnsupportedEncodingException; 35 import java.io.UnsupportedEncodingException;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 98 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
97 @Override 99 @Override
98 public void run() { 100 public void run() {
99 AccountIdProvider.setInstanceForTest(new MockAccountIdProvider() ); 101 AccountIdProvider.setInstanceForTest(new MockAccountIdProvider() );
100 } 102 }
101 }); 103 });
102 } 104 }
103 105
104 @SmallTest 106 @SmallTest
105 @MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP) 107 @MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP)
108 @Restriction(ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES)
106 public void testSimpleRestore() throws InterruptedException, IOException { 109 public void testSimpleRestore() throws InterruptedException, IOException {
107 110
108 // Fake having previously gone through FRE and signed in. 111 // Fake having previously gone through FRE and signed in.
109 SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); 112 SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
110 SharedPreferences.Editor preferenceEditor = prefs.edit(); 113 SharedPreferences.Editor preferenceEditor = prefs.edit();
111 preferenceEditor.putBoolean(FirstRunStatus.FIRST_RUN_FLOW_COMPLETE, true ); 114 preferenceEditor.putBoolean(FirstRunStatus.FIRST_RUN_FLOW_COMPLETE, true );
112 preferenceEditor.putBoolean(FirstRunSignInProcessor.FIRST_RUN_FLOW_SIGNI N_SETUP, true); 115 preferenceEditor.putBoolean(FirstRunSignInProcessor.FIRST_RUN_FLOW_SIGNI N_SETUP, true);
113 116
114 String chromeInputPrefs = 117 String chromeInputPrefs =
115 "{\"junk1\":\"abc\", " 118 "{\"junk1\":\"abc\", "
(...skipping 23 matching lines...) Expand all
139 142
140 assertTrue(chromeOutputPrefs.contains("\"keep_everything_synced\":\"fals e\"")); 143 assertTrue(chromeOutputPrefs.contains("\"keep_everything_synced\":\"fals e\""));
141 assertTrue(chromeOutputPrefs.contains("\"passwords\":\"true\"")); 144 assertTrue(chromeOutputPrefs.contains("\"passwords\":\"true\""));
142 assertFalse(chromeOutputPrefs.contains("junk")); 145 assertFalse(chromeOutputPrefs.contains("junk"));
143 146
144 } 147 }
145 148
146 149
147 @SmallTest 150 @SmallTest
148 @MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP) 151 @MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP)
152 @Restriction(ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES)
149 public void testRestoreAccountMissing() throws InterruptedException, IOExcep tion { 153 public void testRestoreAccountMissing() throws InterruptedException, IOExcep tion {
150 // Fake having previously gone through FRE and signed in. 154 // Fake having previously gone through FRE and signed in.
151 SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); 155 SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
152 SharedPreferences.Editor preferenceEditor = prefs.edit(); 156 SharedPreferences.Editor preferenceEditor = prefs.edit();
153 preferenceEditor.putBoolean(FirstRunStatus.FIRST_RUN_FLOW_COMPLETE, true ); 157 preferenceEditor.putBoolean(FirstRunStatus.FIRST_RUN_FLOW_COMPLETE, true );
154 preferenceEditor.putBoolean(FirstRunSignInProcessor.FIRST_RUN_FLOW_SIGNI N_SETUP, true); 158 preferenceEditor.putBoolean(FirstRunSignInProcessor.FIRST_RUN_FLOW_SIGNI N_SETUP, true);
155 159
156 // Use an account that hasn't been created by the mocks as the signed in account. 160 // Use an account that hasn't been created by the mocks as the signed in account.
157 preferenceEditor.putString(ChromeSigninController.SIGNED_IN_ACCOUNT_KEY, TEST_ACCOUNT_2); 161 preferenceEditor.putString(ChromeSigninController.SIGNED_IN_ACCOUNT_KEY, TEST_ACCOUNT_2);
158 preferenceEditor.apply(); 162 preferenceEditor.apply();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 int fileLength = (int) prefsFile.length(); 204 int fileLength = (int) prefsFile.length();
201 byte[] inputBuffer = new byte[fileLength]; 205 byte[] inputBuffer = new byte[fileLength];
202 assertEquals(fileLength, prefsFileReader.read(inputBuffer)); 206 assertEquals(fileLength, prefsFileReader.read(inputBuffer));
203 return new String(inputBuffer, "UTF-8"); 207 return new String(inputBuffer, "UTF-8");
204 } finally { 208 } finally {
205 StreamUtil.closeQuietly(prefsFileReader); 209 StreamUtil.closeQuietly(prefsFileReader);
206 } 210 }
207 } 211 }
208 212
209 } 213 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698