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

Side by Side Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java

Issue 970883002: [Android WebView] Synthesize a fake page loading event on page source modification (Re-land) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed findbugs warning Created 5 years, 9 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 unified diff | Download patch
OLDNEW
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 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.util.Log; 10 import android.util.Log;
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 enableJavaScriptOnUiThread(parentAwContents); 521 enableJavaScriptOnUiThread(parentAwContents);
522 getInstrumentation().runOnMainSync(new Runnable() { 522 getInstrumentation().runOnMainSync(new Runnable() {
523 @Override 523 @Override
524 public void run() { 524 public void run() {
525 parentAwContents.getSettings().setSupportMultipleWindows(true); 525 parentAwContents.getSettings().setSupportMultipleWindows(true);
526 parentAwContents.getSettings().setJavaScriptCanOpenWindowsAutoma tically(true); 526 parentAwContents.getSettings().setJavaScriptCanOpenWindowsAutoma tically(true);
527 } 527 }
528 }); 528 });
529 529
530 final String parentUrl = testWebServer.setResponse("/popupParent.html", mainHtml, null); 530 final String parentUrl = testWebServer.setResponse("/popupParent.html", mainHtml, null);
531 testWebServer.setResponse(popupPath, popupHtml, null); 531 if (popupHtml != null) {
532 testWebServer.setResponse(popupPath, popupHtml, null);
533 } else {
534 testWebServer.setResponseWithNoContentStatus(popupPath);
535 }
532 536
533 parentAwContentsClient.getOnCreateWindowHelper().setReturnValue(true); 537 parentAwContentsClient.getOnCreateWindowHelper().setReturnValue(true);
534 loadUrlSync(parentAwContents, parentAwContentsClient.getOnPageFinishedHe lper(), parentUrl); 538 loadUrlSync(parentAwContents, parentAwContentsClient.getOnPageFinishedHe lper(), parentUrl);
535 539
536 TestAwContentsClient.OnCreateWindowHelper onCreateWindowHelper = 540 TestAwContentsClient.OnCreateWindowHelper onCreateWindowHelper =
537 parentAwContentsClient.getOnCreateWindowHelper(); 541 parentAwContentsClient.getOnCreateWindowHelper();
538 int currentCallCount = onCreateWindowHelper.getCallCount(); 542 int currentCallCount = onCreateWindowHelper.getCallCount();
539 parentAwContents.evaluateJavaScript(triggerScript, null); 543 parentAwContents.evaluateJavaScript(triggerScript, null);
540 onCreateWindowHelper.waitForCallback( 544 onCreateWindowHelper.waitForCallback(
541 currentCallCount, 1, WAIT_TIMEOUT_MS, TimeUnit.MILLISECONDS); 545 currentCallCount, 1, WAIT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
542 } 546 }
543 547
544 /** 548 /**
549 * POD object for holding references to helper objects of a popup window.
550 */
551 public static class PopupInfo {
552 public final TestAwContentsClient popupContentsClient;
553 public final AwTestContainerView popupContainerView;
554 public final AwContents popupContents;
555 public PopupInfo(TestAwContentsClient popupContentsClient,
556 AwTestContainerView popupContainerView, AwContents popupContents ) {
557 this.popupContentsClient = popupContentsClient;
558 this.popupContainerView = popupContainerView;
559 this.popupContents = popupContents;
560 }
561 }
562
563 /**
545 * Supplies the popup window with AwContents then waits for the popup window to finish loading. 564 * Supplies the popup window with AwContents then waits for the popup window to finish loading.
546 */ 565 */
547 public AwContents connectPendingPopup(final AwContents parentAwContents) thr ows Exception { 566 public PopupInfo connectPendingPopup(final AwContents parentAwContents) thro ws Exception {
548 TestAwContentsClient popupContentsClient; 567 TestAwContentsClient popupContentsClient;
549 AwTestContainerView popupContainerView; 568 AwTestContainerView popupContainerView;
550 final AwContents popupContents; 569 final AwContents popupContents;
551 popupContentsClient = new TestAwContentsClient(); 570 popupContentsClient = new TestAwContentsClient();
552 popupContainerView = createAwTestContainerViewOnMainSync(popupContentsCl ient); 571 popupContainerView = createAwTestContainerViewOnMainSync(popupContentsCl ient);
553 popupContents = popupContainerView.getAwContents(); 572 popupContents = popupContainerView.getAwContents();
554 enableJavaScriptOnUiThread(popupContents); 573 enableJavaScriptOnUiThread(popupContents);
555 574
556 getInstrumentation().runOnMainSync(new Runnable() { 575 getInstrumentation().runOnMainSync(new Runnable() {
557 @Override 576 @Override
558 public void run() { 577 public void run() {
559 parentAwContents.supplyContentsForPopup(popupContents); 578 parentAwContents.supplyContentsForPopup(popupContents);
560 } 579 }
561 }); 580 });
562 581
563 OnPageFinishedHelper onPageFinishedHelper = popupContentsClient.getOnPag eFinishedHelper(); 582 OnPageFinishedHelper onPageFinishedHelper = popupContentsClient.getOnPag eFinishedHelper();
564 int callCount = onPageFinishedHelper.getCallCount(); 583 int callCount = onPageFinishedHelper.getCallCount();
565 onPageFinishedHelper.waitForCallback(callCount, 1, WAIT_TIMEOUT_MS, Time Unit.MILLISECONDS); 584 onPageFinishedHelper.waitForCallback(callCount, 1, WAIT_TIMEOUT_MS, Time Unit.MILLISECONDS);
566 585
567 return popupContents; 586 return new PopupInfo(popupContentsClient, popupContainerView, popupConte nts);
568 } 587 }
569 } 588 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698