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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/ChromeTabCreatorTest.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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
(Empty)
1 // Copyright 2015 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.
4
5 package org.chromium.chrome.browser.tabmodel;
6
7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_LOW_END_D EVICE;
8 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E ND_DEVICE;
9
10 import android.test.suitebuilder.annotation.MediumTest;
11
12 import org.chromium.base.ThreadUtils;
13 import org.chromium.base.test.util.Feature;
14 import org.chromium.base.test.util.Restriction;
15 import org.chromium.chrome.browser.tab.ChromeTab;
16 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
17 import org.chromium.chrome.test.ChromeTabbedActivityTestBase;
18 import org.chromium.chrome.test.util.ChromeTabUtils;
19 import org.chromium.chrome.test.util.TestHttpServerClient;
20 import org.chromium.content_public.browser.LoadUrlParams;
21
22 import java.util.concurrent.Callable;
23 import java.util.concurrent.ExecutionException;
24
25 /**
26 * Tests for ChromeTabCreator.
27 */
28 public class ChromeTabCreatorTest extends ChromeTabbedActivityTestBase {
29 private static final String TEST_URL =
30 TestHttpServerClient.getUrl("chrome/test/data/android/about.html");
31
32 /**
33 * Verify that tabs opened in background on low-end are loaded lazily.
34 */
35 @Restriction(RESTRICTION_TYPE_LOW_END_DEVICE)
36 @MediumTest
37 @Feature({"Browser"})
38 public void testCreateNewTabInBackgroundLowEnd()
39 throws ExecutionException, InterruptedException {
40 final ChromeTab fgTab = ChromeTab.fromTab(getActivity().getActivityTab() );
41 final ChromeTab bgTab = ThreadUtils.runOnUiThreadBlocking(new Callable<C hromeTab>() {
42 @Override
43 public ChromeTab call() {
44 return getActivity().getCurrentTabCreator().createNewTab(
45 new LoadUrlParams(TEST_URL), TabLaunchType.FROM_LONGPRES S_BACKGROUND,
46 fgTab);
47 }
48 });
49
50 // Verify that the background tab is not loading.
51 assertFalse(bgTab.isLoading());
52
53 // Switch tabs and verify that the tab is loaded as it gets foregrounded .
54 ChromeTabUtils.waitForTabPageLoaded(bgTab, new Runnable() {
55 @Override
56 public void run() {
57 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
58 @Override
59 public void run() {
60 TabModelUtils.setIndex(getActivity().getCurrentTabModel( ), indexOf(bgTab));
61 }
62 });
63 }
64 });
65 assertNotNull(bgTab.getView());
66 }
67
68 /**
69 * Verify that tabs opened in background on regular devices are loaded eager ly.
70 */
71 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
72 @MediumTest
73 @Feature({"Browser"})
74 public void testCreateNewTabInBackground()
75 throws ExecutionException, InterruptedException {
76 final ChromeTab fgTab = ChromeTab.fromTab(getActivity().getActivityTab() );
77 ChromeTab bgTab = ThreadUtils.runOnUiThreadBlocking(new Callable<ChromeT ab>() {
78 @Override
79 public ChromeTab call() {
80 return getActivity().getCurrentTabCreator().createNewTab(
81 new LoadUrlParams(TEST_URL), TabLaunchType.FROM_LONGPRES S_BACKGROUND,
82 fgTab);
83 }
84 });
85
86 // Verify that the background tab is loaded.
87 assertNotNull(bgTab.getView());
88 ChromeTabUtils.waitForTabPageLoaded(bgTab, TEST_URL);
89 }
90
91 /**
92 * @return the index of the given tab in the current tab model
93 */
94 private int indexOf(ChromeTab tab) {
95 return getActivity().getCurrentTabModel().indexOf(tab);
96 }
97
98
99 @Override
100 public void startMainActivity() throws InterruptedException {
101 startMainActivityOnBlankPage();
102 }
103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698