| Index: content/public/android/javatests/src/org/chromium/content/browser/BrowserStartupControllerTest.java
|
| diff --git a/content/public/android/javatests/src/org/chromium/content/browser/BrowserStartupControllerTest.java b/content/public/android/javatests/src/org/chromium/content/browser/BrowserStartupControllerTest.java
|
| index d60b04d335c6de3e395110464db9602b481ef8b4..188aa080dd5bab2e417d3ac6e0c07f64dbcb59c7 100644
|
| --- a/content/public/android/javatests/src/org/chromium/content/browser/BrowserStartupControllerTest.java
|
| +++ b/content/public/android/javatests/src/org/chromium/content/browser/BrowserStartupControllerTest.java
|
| @@ -37,7 +37,7 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| @Override
|
| int contentStart() {
|
| mInitializedCounter++;
|
| - if(BrowserStartupController.browserMayStartAsynchonously()) {
|
| + if (BrowserStartupController.browserMayStartAsynchonously()) {
|
| // Post to the UI thread to emulate what would happen in a real scenario.
|
| ThreadUtils.postOnUiThread(new Runnable() {
|
| @Override
|
| @@ -99,14 +99,18 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - mController.startBrowserProcessesAsync(callback);
|
| + try {
|
| + mController.startBrowserProcessesAsync(callback);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| }
|
| });
|
|
|
| assertTrue("Asynchronous mode should have been set.",
|
| BrowserStartupController.browserMayStartAsynchonously());
|
| - assertEquals("The browser process should have been initialized one time.",
|
| - 1, mController.initializedCounter());
|
| + assertEquals("The browser process should have been initialized one time.", 1,
|
| + mController.initializedCounter());
|
|
|
| // Wait for callbacks to complete.
|
| getInstrumentation().waitForIdleSync();
|
| @@ -129,13 +133,21 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - mController.startBrowserProcessesAsync(callback1);
|
| + try {
|
| + mController.startBrowserProcessesAsync(callback1);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| }
|
| });
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - mController.startBrowserProcessesAsync(callback2);
|
| + try {
|
| + mController.startBrowserProcessesAsync(callback2);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| }
|
| });
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @@ -147,8 +159,8 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
|
|
| assertTrue("Asynchronous mode should have been set.",
|
| BrowserStartupController.browserMayStartAsynchonously());
|
| - assertEquals("The browser process should have been initialized one time.",
|
| - 1, mController.initializedCounter());
|
| + assertEquals("The browser process should have been initialized one time.", 1,
|
| + mController.initializedCounter());
|
|
|
| // Wait for callbacks to complete.
|
| getInstrumentation().waitForIdleSync();
|
| @@ -176,7 +188,11 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - mController.startBrowserProcessesAsync(callback1);
|
| + try {
|
| + mController.startBrowserProcessesAsync(callback1);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| }
|
| });
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @@ -188,8 +204,8 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
|
|
| assertTrue("Asynchronous mode should have been set.",
|
| BrowserStartupController.browserMayStartAsynchonously());
|
| - assertEquals("The browser process should have been initialized one time.",
|
| - 1, mController.initializedCounter());
|
| + assertEquals("The browser process should have been initialized one time.", 1,
|
| + mController.initializedCounter());
|
|
|
| // Wait for callbacks to complete.
|
| getInstrumentation().waitForIdleSync();
|
| @@ -206,7 +222,11 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - mController.startBrowserProcessesAsync(callback3);
|
| + try {
|
| + mController.startBrowserProcessesAsync(callback3);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| }
|
| });
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @@ -239,14 +259,18 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - mController.startBrowserProcessesAsync(callback);
|
| + try {
|
| + mController.startBrowserProcessesAsync(callback);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| }
|
| });
|
|
|
| assertTrue("Asynchronous mode should have been set.",
|
| BrowserStartupController.browserMayStartAsynchonously());
|
| - assertEquals("The browser process should have been initialized one time.",
|
| - 1, mController.initializedCounter());
|
| + assertEquals("The browser process should have been initialized one time.", 1,
|
| + mController.initializedCounter());
|
|
|
| // Wait for callbacks to complete.
|
| getInstrumentation().waitForIdleSync();
|
| @@ -266,7 +290,11 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - mController.startBrowserProcessesAsync(callback1);
|
| + try {
|
| + mController.startBrowserProcessesAsync(callback1);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| }
|
| });
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @@ -278,8 +306,8 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
|
|
| assertTrue("Asynchronous mode should have been set.",
|
| BrowserStartupController.browserMayStartAsynchonously());
|
| - assertEquals("The browser process should have been initialized one time.",
|
| - 1, mController.initializedCounter());
|
| + assertEquals("The browser process should have been initialized one time.", 1,
|
| + mController.initializedCounter());
|
|
|
| // Wait for callbacks to complete.
|
| getInstrumentation().waitForIdleSync();
|
| @@ -296,7 +324,11 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - mController.startBrowserProcessesAsync(callback3);
|
| + try {
|
| + mController.startBrowserProcessesAsync(callback3);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| }
|
| });
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @@ -323,15 +355,18 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - assertTrue("Browser should have started successfully",
|
| - mController.startBrowserProcessesSync(1));
|
| + try {
|
| + mController.startBrowserProcessesSync(1);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| }
|
| });
|
| assertFalse("Synchronous mode should have been set",
|
| BrowserStartupController.browserMayStartAsynchonously());
|
|
|
| - assertEquals("The browser process should have been initialized one time.",
|
| - 1, mController.initializedCounter());
|
| + assertEquals("The browser process should have been initialized one time.", 1,
|
| + mController.initializedCounter());
|
| }
|
|
|
| @SmallTest
|
| @@ -344,19 +379,26 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - mController.startBrowserProcessesAsync(callback);
|
| + try {
|
| + mController.startBrowserProcessesAsync(callback);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| // To ensure that the async startup doesn't complete too soon we have
|
| // to do both these in a since Runnable instance. This avoids the
|
| // unpredictable race that happens in real situations.
|
| - assertTrue("Browser should have started successfully",
|
| - mController.startBrowserProcessesSync(1));
|
| + try {
|
| + mController.startBrowserProcessesSync(1);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| }
|
| });
|
| assertFalse("Synchronous mode should have been set",
|
| BrowserStartupController.browserMayStartAsynchonously());
|
|
|
| - assertEquals("The browser process should have been initialized twice.",
|
| - 2, mController.initializedCounter());
|
| + assertEquals("The browser process should have been initialized twice.", 2,
|
| + mController.initializedCounter());
|
|
|
| assertTrue("Callback should have been executed.", callback.mHasStartupResult);
|
| assertTrue("Callback should have been a success.", callback.mWasSuccess);
|
| @@ -374,13 +416,16 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - assertTrue("Browser should have started successfully",
|
| - mController.startBrowserProcessesSync(1));
|
| + try {
|
| + mController.startBrowserProcessesSync(1);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| }
|
| });
|
|
|
| - assertEquals("The browser process should have been initialized once.",
|
| - 1, mController.initializedCounter());
|
| + assertEquals("The browser process should have been initialized once.", 1,
|
| + mController.initializedCounter());
|
|
|
| assertFalse("Synchronous mode should have been set",
|
| BrowserStartupController.browserMayStartAsynchonously());
|
| @@ -389,12 +434,16 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - mController.startBrowserProcessesAsync(callback);
|
| + try {
|
| + mController.startBrowserProcessesAsync(callback);
|
| + } catch (Exception e) {
|
| + fail("Browser should have started successfully");
|
| + }
|
| }
|
| });
|
|
|
| - assertEquals("The browser process should not have been initialized a second time.",
|
| - 1, mController.initializedCounter());
|
| + assertEquals("The browser process should not have been initialized a second time.", 1,
|
| + mController.initializedCounter());
|
|
|
| // Wait for callbacks to complete.
|
| getInstrumentation().waitForIdleSync();
|
| @@ -414,20 +463,20 @@ public class BrowserStartupControllerTest extends InstrumentationTestCase {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - mController.startBrowserProcessesAsync(callback);
|
| + try {
|
| + mController.startBrowserProcessesAsync(callback);
|
| + fail("Browser should not have started successfully");
|
| + } catch (Exception e) {
|
| + // Exception expected, ignore.
|
| + }
|
| }
|
| });
|
|
|
| - assertEquals("The browser process should not have been initialized.",
|
| - 0, mController.initializedCounter());
|
| + assertEquals("The browser process should not have been initialized.", 0,
|
| + mController.initializedCounter());
|
|
|
| // Wait for callbacks to complete.
|
| getInstrumentation().waitForIdleSync();
|
| -
|
| - assertTrue("Callback should have been executed.", callback.mHasStartupResult);
|
| - assertFalse("Callback should have been a failure.", callback.mWasSuccess);
|
| - assertFalse("Callback should be told that the browser process was not already started.",
|
| - callback.mAlreadyStarted);
|
| }
|
|
|
| }
|
|
|