| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 * result of its execution in JSON format. | 565 * result of its execution in JSON format. |
| 566 */ | 566 */ |
| 567 public String executeJavaScriptAndWaitForResult(final AwContents awContents, | 567 public String executeJavaScriptAndWaitForResult(final AwContents awContents, |
| 568 TestAwContentsClient viewClient, final String code) throws Exception
{ | 568 TestAwContentsClient viewClient, final String code) throws Exception
{ |
| 569 return JSUtils.executeJavaScriptAndWaitForResult(this, awContents, | 569 return JSUtils.executeJavaScriptAndWaitForResult(this, awContents, |
| 570 viewClient.getOnEvaluateJavaScriptResultHelper(), | 570 viewClient.getOnEvaluateJavaScriptResultHelper(), |
| 571 code); | 571 code); |
| 572 } | 572 } |
| 573 | 573 |
| 574 /** | 574 /** |
| 575 * Executes JavaScript code within the given ContentView to get the text con
tent in |
| 576 * document body. Returns the result string without double quotes. |
| 577 */ |
| 578 protected String getJavaScriptResultBodyTextContent( |
| 579 final AwContents awContents, final TestAwContentsClient viewClient)
throws Exception { |
| 580 String raw = executeJavaScriptAndWaitForResult( |
| 581 awContents, viewClient, "document.body.textContent"); |
| 582 return maybeStripDoubleQuotes(raw); |
| 583 } |
| 584 |
| 585 /** |
| 575 * Wrapper around CriteriaHelper.pollInstrumentationThread. This uses AwTest
Base-specifc | 586 * Wrapper around CriteriaHelper.pollInstrumentationThread. This uses AwTest
Base-specifc |
| 576 * timeouts and treats timeouts and exceptions as test failures automaticall
y. | 587 * timeouts and treats timeouts and exceptions as test failures automaticall
y. |
| 577 */ | 588 */ |
| 578 public static void pollInstrumentationThread(final Callable<Boolean> callabl
e) | 589 public static void pollInstrumentationThread(final Callable<Boolean> callabl
e) |
| 579 throws Exception { | 590 throws Exception { |
| 580 CriteriaHelper.pollInstrumentationThread(new Criteria() { | 591 CriteriaHelper.pollInstrumentationThread(new Criteria() { |
| 581 @Override | 592 @Override |
| 582 public boolean isSatisfied() { | 593 public boolean isSatisfied() { |
| 583 try { | 594 try { |
| 584 return callable.call(); | 595 return callable.call(); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 int titleCallCount = onReceivedTitleHelper.getCallCount(); | 760 int titleCallCount = onReceivedTitleHelper.getCallCount(); |
| 750 | 761 |
| 751 onPageFinishedHelper.waitForCallback(finishCallCount, 1, WAIT_TIMEOUT_MS
, | 762 onPageFinishedHelper.waitForCallback(finishCallCount, 1, WAIT_TIMEOUT_MS
, |
| 752 TimeUnit.MILLISECONDS); | 763 TimeUnit.MILLISECONDS); |
| 753 onReceivedTitleHelper.waitForCallback(titleCallCount, 1, WAIT_TIMEOUT_MS
, | 764 onReceivedTitleHelper.waitForCallback(titleCallCount, 1, WAIT_TIMEOUT_MS
, |
| 754 TimeUnit.MILLISECONDS); | 765 TimeUnit.MILLISECONDS); |
| 755 | 766 |
| 756 return new PopupInfo(popupContentsClient, popupContainerView, popupConte
nts); | 767 return new PopupInfo(popupContentsClient, popupContainerView, popupConte
nts); |
| 757 } | 768 } |
| 758 } | 769 } |
| OLD | NEW |