OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser.document; | 5 package org.chromium.chrome.browser.document; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.app.Instrumentation; | 8 import android.app.Instrumentation; |
9 import android.app.PendingIntent; | 9 import android.app.PendingIntent; |
10 import android.content.Intent; | 10 import android.content.Intent; |
11 import android.net.Uri; | 11 import android.net.Uri; |
12 import android.os.Build; | 12 import android.os.Build; |
13 import android.test.FlakyTest; | 13 import android.test.FlakyTest; |
14 import android.test.suitebuilder.annotation.MediumTest; | 14 import android.test.suitebuilder.annotation.MediumTest; |
| 15 import android.test.suitebuilder.annotation.SmallTest; |
15 import android.text.TextUtils; | 16 import android.text.TextUtils; |
16 import android.view.View; | 17 import android.view.View; |
17 | 18 |
18 import org.chromium.base.ApplicationStatus; | 19 import org.chromium.base.ApplicationStatus; |
19 import org.chromium.base.ThreadUtils; | 20 import org.chromium.base.ThreadUtils; |
| 21 import org.chromium.base.test.util.CommandLineFlags; |
20 import org.chromium.base.test.util.MinAndroidSdkLevel; | 22 import org.chromium.base.test.util.MinAndroidSdkLevel; |
21 import org.chromium.base.test.util.UrlUtils; | 23 import org.chromium.base.test.util.UrlUtils; |
22 import org.chromium.chrome.browser.ChromeActivity; | 24 import org.chromium.chrome.browser.ChromeActivity; |
23 import org.chromium.chrome.browser.ChromeApplication; | 25 import org.chromium.chrome.browser.ChromeApplication; |
24 import org.chromium.chrome.browser.ChromeTabbedActivity; | 26 import org.chromium.chrome.browser.ChromeTabbedActivity; |
25 import org.chromium.chrome.browser.IntentHandler; | 27 import org.chromium.chrome.browser.IntentHandler; |
26 import org.chromium.chrome.browser.ShortcutHelper; | 28 import org.chromium.chrome.browser.ShortcutHelper; |
27 import org.chromium.chrome.browser.tab.Tab; | 29 import org.chromium.chrome.browser.tab.Tab; |
28 import org.chromium.chrome.browser.tabmodel.TabModel; | 30 import org.chromium.chrome.browser.tabmodel.TabModel; |
| 31 import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
29 import org.chromium.chrome.browser.tabmodel.TabModelUtils; | 32 import org.chromium.chrome.browser.tabmodel.TabModelUtils; |
30 import org.chromium.chrome.browser.tabmodel.document.DocumentTabModelSelector; | 33 import org.chromium.chrome.browser.tabmodel.document.DocumentTabModelSelector; |
31 import org.chromium.chrome.browser.tabmodel.document.OffTheRecordDocumentTabMode
l; | 34 import org.chromium.chrome.browser.tabmodel.document.OffTheRecordDocumentTabMode
l; |
32 import org.chromium.chrome.test.util.ActivityUtils; | 35 import org.chromium.chrome.test.util.ActivityUtils; |
33 import org.chromium.chrome.test.util.ApplicationTestUtils; | 36 import org.chromium.chrome.test.util.ApplicationTestUtils; |
34 import org.chromium.chrome.test.util.DisableInTabbedMode; | 37 import org.chromium.chrome.test.util.DisableInTabbedMode; |
| 38 import org.chromium.chrome.test.util.TestHttpServerClient; |
35 import org.chromium.content.browser.test.util.Criteria; | 39 import org.chromium.content.browser.test.util.Criteria; |
36 import org.chromium.content.browser.test.util.CriteriaHelper; | 40 import org.chromium.content.browser.test.util.CriteriaHelper; |
37 import org.chromium.content.browser.test.util.TouchCommon; | 41 import org.chromium.content.browser.test.util.TouchCommon; |
38 import org.chromium.content_public.browser.LoadUrlParams; | 42 import org.chromium.content_public.browser.LoadUrlParams; |
39 | 43 |
40 import java.lang.ref.WeakReference; | 44 import java.lang.ref.WeakReference; |
41 import java.util.List; | 45 import java.util.List; |
42 | 46 |
43 /** | 47 /** |
44 * General tests for how Document mode Activities interact with each other. | 48 * General tests for how Document mode Activities interact with each other. |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 * set to null immediately afterward. | 647 * set to null immediately afterward. |
644 */ | 648 */ |
645 @MediumTest | 649 @MediumTest |
646 public void testWindowOpenWithOpenerSuppressed() throws Exception { | 650 public void testWindowOpenWithOpenerSuppressed() throws Exception { |
647 Intent lastIntent = performNewWindowTest(ONCLICK_NO_REFERRER_LINK, | 651 Intent lastIntent = performNewWindowTest(ONCLICK_NO_REFERRER_LINK, |
648 "window.open page, opener set to null", true, "Page 4", false); | 652 "window.open page, opener set to null", true, "Page 4", false); |
649 assertEquals("Intent wasn't fired with about:blank", | 653 assertEquals("Intent wasn't fired with about:blank", |
650 "about:blank", IntentHandler.getUrlFromIntent(lastIntent)); | 654 "about:blank", IntentHandler.getUrlFromIntent(lastIntent)); |
651 } | 655 } |
652 | 656 |
| 657 /** |
| 658 * Tests that a Weblite url from an external app uses the lite_url param whe
n Data Reduction |
| 659 * Proxy previews are being used. |
| 660 */ |
| 661 @SmallTest |
| 662 @CommandLineFlags.Add({"enable-spdy-proxy-auth", "data-reduction-proxy-lo-fi
=always-on", |
| 663 "enable-data-reduction-proxy-lo-fi-preview"}) |
| 664 public void testLaunchWebLiteURL() throws Exception { |
| 665 String url = TestHttpServerClient.getUrl("chrome/test/data/android/about
.html"); |
| 666 launchViaViewIntent(false, "http://googleweblight.com/?lite_url=" + url, |
| 667 "Page 1"); |
| 668 |
| 669 TabModelSelector selector = ChromeApplication.getDocumentTabModelSelecto
r(); |
| 670 assertEquals(1, selector.getTotalTabCount()); |
| 671 assertEquals(url, selector.getModel(false).getTabAt(0).getUrl()); |
| 672 } |
| 673 |
| 674 /** |
| 675 * Tests that a Weblite url from an external app does not use the lite_url p
aram when Data |
| 676 * Reduction Proxy previews are not being used. |
| 677 */ |
| 678 @SmallTest |
| 679 public void testLaunchWebLiteURLNoPreviews() throws Exception { |
| 680 String url = TestHttpServerClient.getUrl( |
| 681 "http://googleweblight.com/?lite_url=chrome/test/data/android/ab
out.html"); |
| 682 launchViaViewIntent(false, url, "Page 1"); |
| 683 |
| 684 TabModelSelector selector = ChromeApplication.getDocumentTabModelSelecto
r(); |
| 685 assertEquals(1, selector.getTotalTabCount()); |
| 686 assertEquals(url, selector.getModel(false).getTabAt(0).getUrl()); |
| 687 } |
| 688 |
653 private Intent performNewWindowTest(String url, String title, boolean checkW
indowOpenSuccess, | 689 private Intent performNewWindowTest(String url, String title, boolean checkW
indowOpenSuccess, |
654 String openTitle, boolean waitLongerForOpenedPage) throws Exception
{ | 690 String openTitle, boolean waitLongerForOpenedPage) throws Exception
{ |
655 launchViaLaunchDocumentInstance(false, url, title); | 691 launchViaLaunchDocumentInstance(false, url, title); |
656 | 692 |
657 final DocumentActivity firstActivity = | 693 final DocumentActivity firstActivity = |
658 (DocumentActivity) ApplicationStatus.getLastTrackedFocusedActivi
ty(); | 694 (DocumentActivity) ApplicationStatus.getLastTrackedFocusedActivi
ty(); |
659 | 695 |
660 // Save the current tab ID. | 696 // Save the current tab ID. |
661 final DocumentTabModelSelector selector = | 697 final DocumentTabModelSelector selector = |
662 ChromeApplication.getDocumentTabModelSelector(); | 698 ChromeApplication.getDocumentTabModelSelector(); |
(...skipping 25 matching lines...) Expand all Loading... |
688 firstActivity, ApplicationStatus.getLastTrackedFocusedActivity()
); | 724 firstActivity, ApplicationStatus.getLastTrackedFocusedActivity()
); |
689 | 725 |
690 if (checkWindowOpenSuccess) { | 726 if (checkWindowOpenSuccess) { |
691 assertEquals("New WebContents was not created", | 727 assertEquals("New WebContents was not created", |
692 SUCCESS_URL, firstActivity.getActivityTab().getUrl()); | 728 SUCCESS_URL, firstActivity.getActivityTab().getUrl()); |
693 } | 729 } |
694 | 730 |
695 return lastActivity.getIntent(); | 731 return lastActivity.getIntent(); |
696 } | 732 } |
697 } | 733 } |
OLD | NEW |