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

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

Powered by Google App Engine
This is Rietveld 408576698