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