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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/util/JSUtils.java

Issue 2201783003: Add test to ensure shouldOverrideUrlLoading throws Java exception (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reupload PS1 with similarity 40% to show JSUtils.java as moved file. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/javatests/src/org/chromium/android_webview/test/util/JSUtils.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/util/JSUtils.java b/android_webview/javatests/src/org/chromium/android_webview/test/util/JSUtils.java
deleted file mode 100644
index 306be04687e7d03ee9ff5eaba1d10aae9d851bd6..0000000000000000000000000000000000000000
--- a/android_webview/javatests/src/org/chromium/android_webview/test/util/JSUtils.java
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.android_webview.test.util;
-
-import android.test.InstrumentationTestCase;
-
-import junit.framework.Assert;
-
-import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
-
-import org.chromium.android_webview.AwContents;
-import org.chromium.content.browser.test.util.Criteria;
-import org.chromium.content.browser.test.util.CriteriaHelper;
-import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnEvaluateJavaScriptResultHelper;
-
-/**
- * Collection of functions for JavaScript-based interactions with a page.
- */
-public class JSUtils {
- private static final long WAIT_TIMEOUT_MS = scaleTimeout(2000);
- private static final int CHECK_INTERVAL = 100;
-
- public static void clickOnLinkUsingJs(
- final InstrumentationTestCase testCase,
- final AwContents awContents,
- final OnEvaluateJavaScriptResultHelper onEvaluateJavaScriptResultHelper,
- final String linkId) throws Exception {
-
- CriteriaHelper.pollInstrumentationThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- try {
- String linkIsNotNull = executeJavaScriptAndWaitForResult(testCase, awContents,
- onEvaluateJavaScriptResultHelper,
- "document.getElementById('" + linkId + "') != null");
- return linkIsNotNull.equals("true");
- } catch (Throwable t) {
- t.printStackTrace();
- Assert.fail("Failed to check if DOM is loaded: " + t.toString());
- return false;
- }
- }
- }, WAIT_TIMEOUT_MS, CHECK_INTERVAL);
-
- testCase.getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- awContents.getWebContents().evaluateJavaScriptForTests(
- "var evObj = new MouseEvent('click', {bubbles: true});"
- + "document.getElementById('" + linkId + "').dispatchEvent(evObj);"
- + "console.log('element with id [" + linkId + "] clicked');",
- null);
- }
- });
- }
-
- public static String executeJavaScriptAndWaitForResult(
- InstrumentationTestCase testCase,
- final AwContents awContents,
- final OnEvaluateJavaScriptResultHelper onEvaluateJavaScriptResultHelper,
- final String code) throws Exception {
- testCase.getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- onEvaluateJavaScriptResultHelper.evaluateJavaScriptForTests(
- awContents.getWebContents(), code);
- }
- });
- onEvaluateJavaScriptResultHelper.waitUntilHasValue();
- Assert.assertTrue("Failed to retrieve JavaScript evaluation results.",
- onEvaluateJavaScriptResultHelper.hasValue());
- return onEvaluateJavaScriptResultHelper.getJsonResultAndClear();
- }
-}

Powered by Google App Engine
This is Rietveld 408576698