OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.share; | 5 package org.chromium.chrome.browser.share; |
6 | 6 |
7 import android.content.Intent; | 7 import android.content.Intent; |
8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
9 | 9 |
10 import org.chromium.chrome.shell.ChromeShellTestBase; | 10 import org.chromium.chrome.shell.ChromeShellTestBase; |
11 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; | 11 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; |
12 | 12 |
13 /** | 13 /** |
14 * Tests sharing URLs in reader mode (DOM distiller) | 14 * Tests sharing URLs in reader mode (DOM distiller) |
15 */ | 15 */ |
16 public class ShareUrlTest extends ChromeShellTestBase { | 16 public class ShareUrlTest extends ChromeShellTestBase { |
17 private static final String HTTP_URL = "http://www.google.com/"; | 17 private static final String HTTP_URL = "http://www.google.com/"; |
18 private static final String HTTPS_URL = "https://www.google.com/"; | 18 private static final String HTTPS_URL = "https://www.google.com/"; |
19 | 19 |
20 @Override | 20 @Override |
21 protected void setUp() throws Exception { | 21 protected void setUp() throws Exception { |
22 super.setUp(); | 22 super.setUp(); |
23 | 23 |
24 // load native methods in DomDistillerUrlUtils | 24 // load native methods in DomDistillerUrlUtils |
25 startChromeBrowserProcessSync(getInstrumentation().getTargetContext()); | 25 startChromeBrowserProcessSync(getInstrumentation().getTargetContext()); |
26 } | 26 } |
27 | 27 |
28 private void assertCorrectUrl(String originalUrl, String sharedUrl) { | 28 private void assertCorrectUrl(String originalUrl, String sharedUrl) { |
29 Intent intent = ShareHelper.getShareIntent( | 29 Intent intent = ShareHelper.getShareIntent("", sharedUrl, null); |
30 getInstrumentation().getTargetContext(), "", sharedUrl, null); | |
31 assert (intent.hasExtra(Intent.EXTRA_TEXT)); | 30 assert (intent.hasExtra(Intent.EXTRA_TEXT)); |
32 String url = intent.getStringExtra(Intent.EXTRA_TEXT); | 31 String url = intent.getStringExtra(Intent.EXTRA_TEXT); |
33 assertEquals(originalUrl, url); | 32 assertEquals(originalUrl, url); |
34 } | 33 } |
35 | 34 |
36 @SmallTest | 35 @SmallTest |
37 public void testNormalUrl() { | 36 public void testNormalUrl() { |
38 assertCorrectUrl(HTTP_URL, HTTP_URL); | 37 assertCorrectUrl(HTTP_URL, HTTP_URL); |
39 assertCorrectUrl(HTTPS_URL, HTTPS_URL); | 38 assertCorrectUrl(HTTPS_URL, HTTPS_URL); |
40 } | 39 } |
41 | 40 |
42 @SmallTest | 41 @SmallTest |
43 public void testDistilledUrl() { | 42 public void testDistilledUrl() { |
44 final String DomDistillerScheme = "chrome-distiller"; | 43 final String DomDistillerScheme = "chrome-distiller"; |
45 String distilledHttpUrl = | 44 String distilledHttpUrl = |
46 DomDistillerUrlUtils.getDistillerViewUrlFromUrl(DomDistillerSche
me, HTTP_URL); | 45 DomDistillerUrlUtils.getDistillerViewUrlFromUrl(DomDistillerSche
me, HTTP_URL); |
47 String distilledHttpsUrl = | 46 String distilledHttpsUrl = |
48 DomDistillerUrlUtils.getDistillerViewUrlFromUrl(DomDistillerSche
me, HTTPS_URL); | 47 DomDistillerUrlUtils.getDistillerViewUrlFromUrl(DomDistillerSche
me, HTTPS_URL); |
49 | 48 |
50 assertCorrectUrl(HTTP_URL, distilledHttpUrl); | 49 assertCorrectUrl(HTTP_URL, distilledHttpUrl); |
51 assertCorrectUrl(HTTPS_URL, distilledHttpsUrl); | 50 assertCorrectUrl(HTTPS_URL, distilledHttpsUrl); |
52 } | 51 } |
53 } | 52 } |
OLD | NEW |