OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.android_webview.test; | 5 package org.chromium.android_webview.test; |
6 | 6 |
7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; | 7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; |
8 | 8 |
9 import android.app.Instrumentation; | 9 import android.app.Instrumentation; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 super.setUp(); | 91 super.setUp(); |
92 if (needsBrowserProcessStarted()) { | 92 if (needsBrowserProcessStarted()) { |
93 startBrowserProcess(); | 93 startBrowserProcess(); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 protected void createAwBrowserContext() { | 97 protected void createAwBrowserContext() { |
98 if (mBrowserContext != null) { | 98 if (mBrowserContext != null) { |
99 throw new AndroidRuntimeException("There should only be one browser
context."); | 99 throw new AndroidRuntimeException("There should only be one browser
context."); |
100 } | 100 } |
101 Context appContext = getInstrumentation().getTargetContext().getApplicat
ionContext(); | 101 final InMemorySharedPreferences prefs = new InMemorySharedPreferences(); |
102 mBrowserContext = new AwBrowserContext(new InMemorySharedPreferences(),
appContext); | 102 final Context appContext = getInstrumentation().getTargetContext().getAp
plicationContext(); |
| 103 getInstrumentation().runOnMainSync(new Runnable() { |
| 104 @Override |
| 105 public void run() { |
| 106 mBrowserContext = new AwBrowserContext(prefs, appContext); |
| 107 } |
| 108 }); |
103 } | 109 } |
104 | 110 |
105 protected void startBrowserProcess() throws Exception { | 111 protected void startBrowserProcess() throws Exception { |
106 // The activity must be launched in order for proper webview statics to
be setup. | 112 // The Activity must be launched in order for proper webview statics to
be setup. |
107 getActivity(); | 113 getActivity(); |
108 getInstrumentation().runOnMainSync(new Runnable() { | 114 getInstrumentation().runOnMainSync(new Runnable() { |
109 @Override | 115 @Override |
110 public void run() { | 116 public void run() { |
111 AwBrowserProcess.start(); | 117 AwBrowserProcess.start(); |
112 } | 118 } |
113 }); | 119 }); |
114 } | 120 } |
115 | 121 |
116 /** | 122 /** |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 int titleCallCount = onReceivedTitleHelper.getCallCount(); | 703 int titleCallCount = onReceivedTitleHelper.getCallCount(); |
698 | 704 |
699 onPageFinishedHelper.waitForCallback(finishCallCount, 1, WAIT_TIMEOUT_MS
, | 705 onPageFinishedHelper.waitForCallback(finishCallCount, 1, WAIT_TIMEOUT_MS
, |
700 TimeUnit.MILLISECONDS); | 706 TimeUnit.MILLISECONDS); |
701 onReceivedTitleHelper.waitForCallback(titleCallCount, 1, WAIT_TIMEOUT_MS
, | 707 onReceivedTitleHelper.waitForCallback(titleCallCount, 1, WAIT_TIMEOUT_MS
, |
702 TimeUnit.MILLISECONDS); | 708 TimeUnit.MILLISECONDS); |
703 | 709 |
704 return new PopupInfo(popupContentsClient, popupContainerView, popupConte
nts); | 710 return new PopupInfo(popupContentsClient, popupContainerView, popupConte
nts); |
705 } | 711 } |
706 } | 712 } |
OLD | NEW |