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

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

Issue 1582513003: Add a testing restriction for whether Google Play Services is up-to-date. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 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 2015 The Chromium Authors. All rights reserved. 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 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; 5 package org.chromium.chrome.browser;
6 6
7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_PHONE;
8
9 import android.test.suitebuilder.annotation.MediumTest; 7 import android.test.suitebuilder.annotation.MediumTest;
10 import android.widget.ImageButton; 8 import android.widget.ImageButton;
11 9
12 import org.chromium.base.test.util.Feature; 10 import org.chromium.base.test.util.Feature;
13 import org.chromium.base.test.util.Restriction;
14 import org.chromium.chrome.R; 11 import org.chromium.chrome.R;
15 import org.chromium.chrome.browser.toolbar.TabSwitcherDrawable; 12 import org.chromium.chrome.browser.toolbar.TabSwitcherDrawable;
16 import org.chromium.chrome.test.ChromeTabbedActivityTestBase; 13 import org.chromium.chrome.test.ChromeTabbedActivityTestBase;
14 import org.chromium.chrome.test.util.ChromeRestriction;
17 import org.chromium.chrome.test.util.ChromeTabUtils; 15 import org.chromium.chrome.test.util.ChromeTabUtils;
18 16
19 /** 17 /**
20 * Test suite for the tab count widget on the phone toolbar. 18 * Test suite for the tab count widget on the phone toolbar.
21 */ 19 */
22 20
23 public class TabCountLabelTest extends ChromeTabbedActivityTestBase { 21 public class TabCountLabelTest extends ChromeTabbedActivityTestBase {
24 22
25 /** 23 /**
26 * Check the tabCount string against an expected value. 24 * Check the tabCount string against an expected value.
27 */ 25 */
28 private void tabCountLabelCheck(String stepName, int tabCountExpected) { 26 private void tabCountLabelCheck(String stepName, int tabCountExpected) {
29 ImageButton tabSwitcherBtn = 27 ImageButton tabSwitcherBtn =
30 (ImageButton) getActivity().findViewById(R.id.tab_switcher_butto n); 28 (ImageButton) getActivity().findViewById(R.id.tab_switcher_butto n);
31 TabSwitcherDrawable drawable = (TabSwitcherDrawable) tabSwitcherBtn.getD rawable(); 29 TabSwitcherDrawable drawable = (TabSwitcherDrawable) tabSwitcherBtn.getD rawable();
32 int tabCountFromDrawable = drawable.getTabCount(); 30 int tabCountFromDrawable = drawable.getTabCount();
33 assertTrue(stepName + ", " + tabCountExpected + " tab[s] expected, label shows " 31 assertTrue(stepName + ", " + tabCountExpected + " tab[s] expected, label shows "
34 + tabCountFromDrawable, tabCountExpected == tabCountFromDrawable ); 32 + tabCountFromDrawable, tabCountExpected == tabCountFromDrawable );
35 } 33 }
36 34
37 /** 35 /**
38 * Verify displayed Tab Count matches the actual number of tabs. 36 * Verify displayed Tab Count matches the actual number of tabs.
39 */ 37 */
40 @MediumTest 38 @MediumTest
41 @Feature({"Browser", "Main"}) 39 @Feature({"Browser", "Main"})
42 @Restriction(RESTRICTION_TYPE_PHONE) 40 @ChromeRestriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
43 public void testTabCountLabel() throws InterruptedException { 41 public void testTabCountLabel() throws InterruptedException {
44 final int tabCount = getActivity().getCurrentTabModel().getCount(); 42 final int tabCount = getActivity().getCurrentTabModel().getCount();
45 tabCountLabelCheck("Initial state", tabCount); 43 tabCountLabelCheck("Initial state", tabCount);
46 ChromeTabUtils.newTabFromMenu(getInstrumentation(), getActivity()); 44 ChromeTabUtils.newTabFromMenu(getInstrumentation(), getActivity());
47 // Make sure the TAB_CREATED notification went through 45 // Make sure the TAB_CREATED notification went through
48 getInstrumentation().waitForIdleSync(); 46 getInstrumentation().waitForIdleSync();
49 tabCountLabelCheck("After new tab", tabCount + 1); 47 tabCountLabelCheck("After new tab", tabCount + 1);
50 ChromeTabUtils.closeCurrentTab(getInstrumentation(), getActivity()); 48 ChromeTabUtils.closeCurrentTab(getInstrumentation(), getActivity());
51 // Make sure the TAB_CLOSED notification went through 49 // Make sure the TAB_CLOSED notification went through
52 getInstrumentation().waitForIdleSync(); 50 getInstrumentation().waitForIdleSync();
53 tabCountLabelCheck("After close tab", tabCount); 51 tabCountLabelCheck("After close tab", tabCount);
54 } 52 }
55 53
56 @Override 54 @Override
57 public void startMainActivity() throws InterruptedException { 55 public void startMainActivity() throws InterruptedException {
58 startMainActivityOnBlankPage(); 56 startMainActivityOnBlankPage();
59 } 57 }
60 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698