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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/ToolbarModelTest.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.toolbar;
6
7 import android.test.suitebuilder.annotation.MediumTest;
8
9 import com.google.android.apps.chrome.R;
10
11 import junit.framework.Assert;
12
13 import org.chromium.base.test.util.Feature;
14 import org.chromium.chrome.browser.ChromeTabbedActivity;
15 import org.chromium.chrome.browser.Tab;
16 import org.chromium.chrome.test.ChromeTabbedActivityTestBase;
17 import org.chromium.chrome.test.util.ChromeTabUtils;
18
19 /**
20 * Tests for ToolbarModel.
21 */
22 public class ToolbarModelTest extends ChromeTabbedActivityTestBase {
23 @Override
24 public void startMainActivity() throws InterruptedException {
25 startMainActivityOnBlankPage();
26 }
27
28 /**
29 * After closing all {@link Tab}s, the {@link ToolbarModelImpl} should know that it is not
30 * showing any {@link Tab}.
31 * @throws InterruptedException
32 */
33 @Feature({"Android-Toolbar"})
34 @MediumTest
35 public void testClosingLastTabReflectedInModel() throws InterruptedException {
36 assertNotSame("No current tab", Tab.INVALID_TAB_ID,
37 getCurrentTabId(getActivity()));
38 ChromeTabUtils.closeCurrentTab(getInstrumentation(), getActivity());
39 assertEquals("Didn't close all tabs.", 0, ChromeTabUtils.getNumOpenTabs( getActivity()));
40 assertEquals("ToolbarModel is still trying to show a tab.", Tab.INVALID_ TAB_ID,
41 getCurrentTabId(getActivity()));
42 }
43
44 /**
45 * @param activity A reference to {@link ChromeTabbedActivity} to pull
46 * {@link android.view.View} data from.
47 * @return The id of the current {@link Tab} as far as the {@link ToolbarMod elImpl} sees it.
48 */
49 public static int getCurrentTabId(final ChromeTabbedActivity activity) {
50 ToolbarLayout toolbar = (ToolbarLayout) activity.findViewById(R.id.toolb ar);
51 Assert.assertNotNull("Toolbar is null", toolbar);
52
53 ToolbarDataProvider dataProvider = toolbar.getToolbarDataProvider();
54 Tab tab = dataProvider.getTab();
55 return tab != null ? tab.getId() : Tab.INVALID_TAB_ID;
56 }
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698