| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 android.app.Instrumentation; | 7 import android.app.Instrumentation; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.test.ActivityInstrumentationTestCase2; | 9 import android.test.ActivityInstrumentationTestCase2; |
| 10 import android.view.View; | 10 import android.view.View; |
| 11 import android.view.ViewGroup; | |
| 12 | 11 |
| 13 import junit.framework.Assert; | 12 import junit.framework.Assert; |
| 14 | 13 |
| 15 import org.chromium.android_webview.AndroidWebViewUtil; | 14 import org.chromium.android_webview.AndroidWebViewUtil; |
| 16 import org.chromium.android_webview.AwContents; | 15 import org.chromium.android_webview.AwContents; |
| 17 import org.chromium.android_webview.AwContentsClient; | 16 import org.chromium.android_webview.AwContentsClient; |
| 18 import org.chromium.content.browser.ContentSettings; | 17 import org.chromium.content.browser.ContentSettings; |
| 19 import org.chromium.content.browser.ContentView; | 18 import org.chromium.content.browser.ContentView; |
| 20 import org.chromium.content.browser.ContentViewClient; | 19 import org.chromium.content.browser.ContentViewClient; |
| 21 import org.chromium.content.browser.ContentViewCore; | 20 import org.chromium.content.browser.ContentViewCore; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 final Context context = getActivity(); | 164 final Context context = getActivity(); |
| 166 getInstrumentation().runOnMainSync(new Runnable() { | 165 getInstrumentation().runOnMainSync(new Runnable() { |
| 167 @Override | 166 @Override |
| 168 public void run() { | 167 public void run() { |
| 169 testContainerView.set(createAwTestContainerView(incognito, clien
t)); | 168 testContainerView.set(createAwTestContainerView(incognito, clien
t)); |
| 170 } | 169 } |
| 171 }); | 170 }); |
| 172 return testContainerView.get(); | 171 return testContainerView.get(); |
| 173 } | 172 } |
| 174 | 173 |
| 174 protected void destroyAwContentsOnMainSync(final AwContents contents) { |
| 175 if (contents == null) return; |
| 176 getInstrumentation().runOnMainSync(new Runnable() { |
| 177 @Override |
| 178 public void run() { |
| 179 contents.destroy(); |
| 180 } |
| 181 }); |
| 182 } |
| 183 |
| 175 protected String getTitleOnUiThread(final ContentViewCore contentViewCore) t
hrows Throwable { | 184 protected String getTitleOnUiThread(final ContentViewCore contentViewCore) t
hrows Throwable { |
| 176 return runTestOnUiThreadAndGetResult(new Callable<String>() { | 185 return runTestOnUiThreadAndGetResult(new Callable<String>() { |
| 177 @Override | 186 @Override |
| 178 public String call() throws Exception { | 187 public String call() throws Exception { |
| 179 return contentViewCore.getTitle(); | 188 return contentViewCore.getTitle(); |
| 180 } | 189 } |
| 181 }); | 190 }); |
| 182 } | 191 } |
| 183 | 192 |
| 184 protected ContentSettings getContentSettingsOnUiThread( | 193 protected ContentSettings getContentSettingsOnUiThread( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 206 public void run() { | 215 public void run() { |
| 207 requestId.set(core.evaluateJavaScript(code)); | 216 requestId.set(core.evaluateJavaScript(code)); |
| 208 } | 217 } |
| 209 }); | 218 }); |
| 210 onEvaluateJavaScriptResultHelper.waitForCallback(currentCallCount); | 219 onEvaluateJavaScriptResultHelper.waitForCallback(currentCallCount); |
| 211 Assert.assertEquals("Response ID mismatch when evaluating JavaScript.", | 220 Assert.assertEquals("Response ID mismatch when evaluating JavaScript.", |
| 212 requestId.get(), onEvaluateJavaScriptResultHelper.getId()); | 221 requestId.get(), onEvaluateJavaScriptResultHelper.getId()); |
| 213 return onEvaluateJavaScriptResultHelper.getJsonResult(); | 222 return onEvaluateJavaScriptResultHelper.getJsonResult(); |
| 214 } | 223 } |
| 215 } | 224 } |
| OLD | NEW |