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

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

Issue 1817083003: Add pathway to auto-migrate users when Chrome launches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@assassin
Patch Set: Redid the world Created 4 years, 8 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 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.tabmodel; 5 package org.chromium.chrome.browser.tabmodel;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.test.MoreAsserts; 8 import android.test.MoreAsserts;
9 import android.test.suitebuilder.annotation.MediumTest; 9 import android.test.suitebuilder.annotation.MediumTest;
10 import android.test.suitebuilder.annotation.SmallTest; 10 import android.test.suitebuilder.annotation.SmallTest;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 writeDoneCallback.notifyCalled(); 203 writeDoneCallback.notifyCalled();
204 } 204 }
205 } 205 }
206 }; 206 };
207 207
208 File[] tabbedModeFilesBefore = mTabbedModeDirectory.getDataDirectory().l istFiles(); 208 File[] tabbedModeFilesBefore = mTabbedModeDirectory.getDataDirectory().l istFiles();
209 assertNotNull(tabbedModeFilesBefore); 209 assertNotNull(tabbedModeFilesBefore);
210 int numFilesBefore = tabbedModeFilesBefore.length; 210 int numFilesBefore = tabbedModeFilesBefore.length;
211 assertEquals(0, writeStartedCallback.getCallCount()); 211 assertEquals(0, writeStartedCallback.getCallCount());
212 assertEquals(0, writeDoneCallback.getCallCount()); 212 assertEquals(0, writeDoneCallback.getCallCount());
213 final Context context = getInstrumentation().getTargetContext();
213 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 214 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
214 @Override 215 @Override
215 public void run() { 216 public void run() {
216 assassin.addObserver(observer); 217 assassin.addObserver(observer);
217 assassin.writeTabModelMetadata( 218 assassin.writeTabModelMetadata(testTabModel, migratedTabIds, con text,
218 mTabbedModeDirectory.getDataDirectory(), testTabModel, m igratedTabIds); 219 mTabbedModeDirectory.getDataDirectory());
219 } 220 }
220 }); 221 });
221 222
222 // Wait and confirm that the tabbed mode metadata file was written out. 223 // Wait and confirm that the tabbed mode metadata file was written out.
223 writeStartedCallback.waitForCallback(0); 224 writeStartedCallback.waitForCallback(0);
224 writeDoneCallback.waitForCallback(0); 225 writeDoneCallback.waitForCallback(0);
225 File[] tabbedModeFilesAfter = mTabbedModeDirectory.getDataDirectory().li stFiles(); 226 File[] tabbedModeFilesAfter = mTabbedModeDirectory.getDataDirectory().li stFiles();
226 assertNotNull(tabbedModeFilesAfter); 227 assertNotNull(tabbedModeFilesAfter);
227 assertEquals(numFilesBefore + 1, tabbedModeFilesAfter.length); 228 assertEquals(numFilesBefore + 1, tabbedModeFilesAfter.length);
228 229
229 // Load up the metadata file via a TabPersistentStore to make sure that it contains all of 230 // Load up the metadata file via a TabPersistentStore to make sure that it contains all of
230 // the migrated tab information. 231 // the migrated tab information.
231 loadNativeLibraryAndInitBrowserProcess(); 232 loadNativeLibraryAndInitBrowserProcess();
232 TabPersistentStore.setBaseStateDirectory(mTabbedModeDirectory.getBaseDir ectory()); 233 TabPersistentStore.setBaseStateDirectory(mTabbedModeDirectory.getBaseDir ectory());
233 234
234 Context context = getInstrumentation().getTargetContext();
235 TestTabModelSelector selector = new TestTabModelSelector(context); 235 TestTabModelSelector selector = new TestTabModelSelector(context);
236 TabPersistentStore store = selector.mTabPersistentStore; 236 TabPersistentStore store = selector.mTabPersistentStore;
237 MockTabPersistentStoreObserver mockObserver = selector.mTabPersistentSto reObserver; 237 MockTabPersistentStoreObserver mockObserver = selector.mTabPersistentSto reObserver;
238 238
239 // Load up the TabModel metadata. 239 // Load up the TabModel metadata.
240 int numExpectedTabs = TEST_INFO.numRegularTabs + TEST_INFO.numIncognitoT abs; 240 int numExpectedTabs = TEST_INFO.numRegularTabs + TEST_INFO.numIncognitoT abs;
241 store.loadState(); 241 store.loadState();
242 mockObserver.initializedCallback.waitForCallback(0, 1); 242 mockObserver.initializedCallback.waitForCallback(0, 1);
243 assertEquals(numExpectedTabs, mockObserver.mTabCountAtStartup); 243 assertEquals(numExpectedTabs, mockObserver.mTabCountAtStartup);
244 mockObserver.detailsReadCallback.waitForCallback(0, TEST_INFO.contents.l ength); 244 mockObserver.detailsReadCallback.waitForCallback(0, TEST_INFO.contents.l ength);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 TabState.SAVED_TAB_STATE_FILE_PREFIX + "_unparseable"); 322 TabState.SAVED_TAB_STATE_FILE_PREFIX + "_unparseable");
323 323
324 // Kick off copying the tab states. 324 // Kick off copying the tab states.
325 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 325 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
326 @Override 326 @Override
327 public void run() { 327 public void run() {
328 assassin.addObserver(observer); 328 assassin.addObserver(observer);
329 assertEquals(0, copyStartedCallback.getCallCount()); 329 assertEquals(0, copyStartedCallback.getCallCount());
330 assertEquals(0, copyDoneCallback.getCallCount()); 330 assertEquals(0, copyDoneCallback.getCallCount());
331 assertEquals(0, copyCallback.getCallCount()); 331 assertEquals(0, copyCallback.getCallCount());
332 assassin.copyTabStateFiles(selectedTabId, mDocumentModeDirectory .getDataDirectory(), 332 assassin.copyTabStateFiles(selectedTabId, getInstrumentation().g etTargetContext(),
333 mDocumentModeDirectory.getDataDirectory(),
333 mTabbedModeDirectory.getDataDirectory()); 334 mTabbedModeDirectory.getDataDirectory());
334 } 335 }
335 }); 336 });
336 copyStartedCallback.waitForCallback(0); 337 copyStartedCallback.waitForCallback(0);
337 338
338 // Confirm that the first TabState file copied back is the selected one. 339 // Confirm that the first TabState file copied back is the selected one.
339 copyCallback.waitForCallback(0); 340 copyCallback.waitForCallback(0);
340 if (selectedTabId != Tab.INVALID_TAB_ID) assertEquals(selectedTabId, fir stCopiedId.get()); 341 if (selectedTabId != Tab.INVALID_TAB_ID) assertEquals(selectedTabId, fir stCopiedId.get());
341 342
342 // Confirm that all the TabState files were copied over. 343 // Confirm that all the TabState files were copied over.
(...skipping 11 matching lines...) Expand all
354 355
355 for (int i = 0; i < TAB_STATE_INFO.length; i++) { 356 for (int i = 0; i < TAB_STATE_INFO.length; i++) {
356 boolean found = false; 357 boolean found = false;
357 for (int j = 0; j < tabbedModeFilesAfter.length && !found; j++) { 358 for (int j = 0; j < tabbedModeFilesAfter.length && !found; j++) {
358 found |= TAB_STATE_INFO[i].filename.equals(tabbedModeFilesAfter[ j].getName()); 359 found |= TAB_STATE_INFO[i].filename.equals(tabbedModeFilesAfter[ j].getName());
359 } 360 }
360 assertTrue("Couldn't find file: " + TAB_STATE_INFO[i].filename, foun d); 361 assertTrue("Couldn't find file: " + TAB_STATE_INFO[i].filename, foun d);
361 } 362 }
362 } 363 }
363 } 364 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698