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