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

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/BrowserStartupControllerTest.java

Issue 897683003: Know the process shared library loaded in (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments and sync Created 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.test.InstrumentationTestCase; 8 import android.test.InstrumentationTestCase;
9 import android.test.suitebuilder.annotation.SmallTest; 9 import android.test.suitebuilder.annotation.SmallTest;
10 10
11 import org.chromium.base.ThreadUtils; 11 import org.chromium.base.ThreadUtils;
12 import org.chromium.base.library_loader.LibraryProcessType;
12 import org.chromium.base.library_loader.LoaderErrors; 13 import org.chromium.base.library_loader.LoaderErrors;
13 import org.chromium.base.library_loader.ProcessInitException; 14 import org.chromium.base.library_loader.ProcessInitException;
14 import org.chromium.base.test.util.AdvancedMockContext; 15 import org.chromium.base.test.util.AdvancedMockContext;
15 16
16 /** 17 /**
17 * Test of BrowserStartupController 18 * Test of BrowserStartupController
18 */ 19 */
19 public class BrowserStartupControllerTest extends InstrumentationTestCase { 20 public class BrowserStartupControllerTest extends InstrumentationTestCase {
20 21
21 private TestBrowserStartupController mController; 22 private TestBrowserStartupController mController;
22 23
23 private static class TestBrowserStartupController extends BrowserStartupCont roller { 24 private static class TestBrowserStartupController extends BrowserStartupCont roller {
24 25
25 private int mStartupResult; 26 private int mStartupResult;
26 private boolean mLibraryLoadSucceeds; 27 private boolean mLibraryLoadSucceeds;
27 private int mInitializedCounter = 0; 28 private int mInitializedCounter = 0;
28 29
29 @Override 30 @Override
30 void prepareToStartBrowserProcess(boolean singleProcess) throws ProcessI nitException { 31 void prepareToStartBrowserProcess(boolean singleProcess) throws ProcessI nitException {
31 if (!mLibraryLoadSucceeds) { 32 if (!mLibraryLoadSucceeds) {
32 throw new ProcessInitException( 33 throw new ProcessInitException(
33 LoaderErrors.LOADER_ERROR_NATIVE_LIBRARY_LOAD_FAILED); 34 LoaderErrors.LOADER_ERROR_NATIVE_LIBRARY_LOAD_FAILED);
34 } 35 }
35 } 36 }
36 37
37 private TestBrowserStartupController(Context context) { 38 private TestBrowserStartupController(Context context) {
38 super(context); 39 super(context, LibraryProcessType.PROCESS_BROWSER);
39 } 40 }
40 41
41 @Override 42 @Override
42 int contentStart() { 43 int contentStart() {
43 mInitializedCounter++; 44 mInitializedCounter++;
44 if (BrowserStartupController.browserMayStartAsynchonously()) { 45 if (BrowserStartupController.browserMayStartAsynchonously()) {
45 // Post to the UI thread to emulate what would happen in a real scenario. 46 // Post to the UI thread to emulate what would happen in a real scenario.
46 ThreadUtils.postOnUiThread(new Runnable() { 47 ThreadUtils.postOnUiThread(new Runnable() {
47 @Override 48 @Override
48 public void run() { 49 public void run() {
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 }); 478 });
478 479
479 assertEquals("The browser process should not have been initialized.", 0, 480 assertEquals("The browser process should not have been initialized.", 0,
480 mController.initializedCounter()); 481 mController.initializedCounter());
481 482
482 // Wait for callbacks to complete. 483 // Wait for callbacks to complete.
483 getInstrumentation().waitForIdleSync(); 484 getInstrumentation().waitForIdleSync();
484 } 485 }
485 486
486 } 487 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698