Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/share/ShareUrlTest.java

Issue 2954393003: Fix test crashes related to AccountManagerHelper. (Closed)
Patch Set: . Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.support.test.filters.SmallTest; 9 import android.support.test.filters.SmallTest;
10 import android.support.test.rule.UiThreadTestRule;
11 10
12 import org.junit.Assert; 11 import org.junit.Assert;
13 import org.junit.Before;
14 import org.junit.Rule; 12 import org.junit.Rule;
15 import org.junit.Test; 13 import org.junit.Test;
16 import org.junit.runner.RunWith; 14 import org.junit.runner.RunWith;
17 15
16 import org.chromium.base.ThreadUtils;
18 import org.chromium.base.test.BaseJUnit4ClassRunner; 17 import org.chromium.base.test.BaseJUnit4ClassRunner;
18 import org.chromium.chrome.browser.test.ChromeBrowserTestRule;
19 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; 19 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils;
20 import org.chromium.content.browser.test.NativeLibraryTestRule;
21 20
22 /** 21 /**
23 * Tests sharing URLs in reader mode (DOM distiller) 22 * Tests sharing URLs in reader mode (DOM distiller)
24 */ 23 */
25 @RunWith(BaseJUnit4ClassRunner.class) 24 @RunWith(BaseJUnit4ClassRunner.class)
26 public class ShareUrlTest { 25 public class ShareUrlTest {
27 @Rule 26 @Rule
28 public NativeLibraryTestRule mActivityTestRule = new NativeLibraryTestRule() ; 27 public final ChromeBrowserTestRule mBrowserTestRule = new ChromeBrowserTestR ule();
29
30 @Rule
31 public UiThreadTestRule mUiThreadTestRule = new UiThreadTestRule();
32 28
33 private static final String HTTP_URL = "http://www.google.com/"; 29 private static final String HTTP_URL = "http://www.google.com/";
34 private static final String HTTPS_URL = "https://www.google.com/"; 30 private static final String HTTPS_URL = "https://www.google.com/";
35 31
36 @Before
37 public void setUp() throws Exception {
38 mActivityTestRule.loadNativeLibraryAndInitBrowserProcess();
39 }
40
41 private void assertCorrectUrl(final String originalUrl, final String sharedU rl) 32 private void assertCorrectUrl(final String originalUrl, final String sharedU rl)
42 throws Throwable { 33 throws Throwable {
43 mUiThreadTestRule.runOnUiThread(new Runnable() { 34 ThreadUtils.runOnUiThread(new Runnable() {
44 @Override 35 @Override
45 public void run() { 36 public void run() {
46 ShareParams params = 37 ShareParams params =
47 new ShareParams.Builder(new Activity(), "", sharedUrl).s etText("").build(); 38 new ShareParams.Builder(new Activity(), "", sharedUrl).s etText("").build();
48 Intent intent = ShareHelper.getShareLinkIntent(params); 39 Intent intent = ShareHelper.getShareLinkIntent(params);
49 Assert.assertTrue(intent.hasExtra(Intent.EXTRA_TEXT)); 40 Assert.assertTrue(intent.hasExtra(Intent.EXTRA_TEXT));
50 String url = intent.getStringExtra(Intent.EXTRA_TEXT); 41 String url = intent.getStringExtra(Intent.EXTRA_TEXT);
51 Assert.assertEquals(originalUrl, url); 42 Assert.assertEquals(originalUrl, url);
52 } 43 }
53 }); 44 });
(...skipping 12 matching lines...) Expand all
66 final String DomDistillerScheme = "chrome-distiller"; 57 final String DomDistillerScheme = "chrome-distiller";
67 String distilledHttpUrl = 58 String distilledHttpUrl =
68 DomDistillerUrlUtils.getDistillerViewUrlFromUrl(DomDistillerSche me, HTTP_URL); 59 DomDistillerUrlUtils.getDistillerViewUrlFromUrl(DomDistillerSche me, HTTP_URL);
69 String distilledHttpsUrl = 60 String distilledHttpsUrl =
70 DomDistillerUrlUtils.getDistillerViewUrlFromUrl(DomDistillerSche me, HTTPS_URL); 61 DomDistillerUrlUtils.getDistillerViewUrlFromUrl(DomDistillerSche me, HTTPS_URL);
71 62
72 assertCorrectUrl(HTTP_URL, distilledHttpUrl); 63 assertCorrectUrl(HTTP_URL, distilledHttpUrl);
73 assertCorrectUrl(HTTPS_URL, distilledHttpsUrl); 64 assertCorrectUrl(HTTPS_URL, distilledHttpsUrl);
74 } 65 }
75 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698