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
3 // found in the LICENSE file.
5 package org.chromium.chrome.browser.share;
7 import android.content.Intent;
8 import android.test.suitebuilder.annotation.SmallTest;
10 import org.chromium.chrome.shell.ChromeShellTestBase;
11 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils;
14 * Tests sharing URLs in reader mode (DOM distiller)
16 public class ShareUrlTest extends ChromeShellTestBase {
17 private static final String HTTP_URL = "http://www.google.com/";
18 private static final String HTTPS_URL = "https://www.google.com/";
21 protected void setUp() throws Exception {
24 // load native methods in DomDistillerUrlUtils
25 startChromeBrowserProcessSync(getInstrumentation().getTargetContext());
28 private void assertCorrectUrl(String originalUrl, String sharedUrl) {
29 Intent intent = ShareHelper.getShareIntent("", sharedUrl, null, 0);
30 assert (intent.hasExtra(Intent.EXTRA_TEXT));
31 String url = intent.getStringExtra(Intent.EXTRA_TEXT);
32 assertEquals(originalUrl, url);
36 public void testNormalUrl() {
37 assertCorrectUrl(HTTP_URL, HTTP_URL);
38 assertCorrectUrl(HTTPS_URL, HTTPS_URL);
42 public void testDistilledUrl() {
43 final String DomDistillerScheme = "chrome-distiller";
44 String distilledHttpUrl =
45 DomDistillerUrlUtils.getDistillerViewUrlFromUrl(DomDistillerScheme, HTTP_URL);
46 String distilledHttpsUrl =
47 DomDistillerUrlUtils.getDistillerViewUrlFromUrl(DomDistillerScheme, HTTPS_URL);
49 assertCorrectUrl(HTTP_URL, distilledHttpUrl);
50 assertCorrectUrl(HTTPS_URL, distilledHttpsUrl);