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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/ToolbarModelTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/ToolbarModelTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/ToolbarModelTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..a7c892d73750c00d79219f6be6ddaf308861962f
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/ToolbarModelTest.java
@@ -0,0 +1,57 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.toolbar;
+
+import android.test.suitebuilder.annotation.MediumTest;
+
+import com.google.android.apps.chrome.R;
+
+import junit.framework.Assert;
+
+import org.chromium.base.test.util.Feature;
+import org.chromium.chrome.browser.ChromeTabbedActivity;
+import org.chromium.chrome.browser.Tab;
+import org.chromium.chrome.test.ChromeTabbedActivityTestBase;
+import org.chromium.chrome.test.util.ChromeTabUtils;
+
+/**
+ * Tests for ToolbarModel.
+ */
+public class ToolbarModelTest extends ChromeTabbedActivityTestBase {
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ startMainActivityOnBlankPage();
+ }
+
+ /**
+ * After closing all {@link Tab}s, the {@link ToolbarModelImpl} should know that it is not
+ * showing any {@link Tab}.
+ * @throws InterruptedException
+ */
+ @Feature({"Android-Toolbar"})
+ @MediumTest
+ public void testClosingLastTabReflectedInModel() throws InterruptedException {
+ assertNotSame("No current tab", Tab.INVALID_TAB_ID,
+ getCurrentTabId(getActivity()));
+ ChromeTabUtils.closeCurrentTab(getInstrumentation(), getActivity());
+ assertEquals("Didn't close all tabs.", 0, ChromeTabUtils.getNumOpenTabs(getActivity()));
+ assertEquals("ToolbarModel is still trying to show a tab.", Tab.INVALID_TAB_ID,
+ getCurrentTabId(getActivity()));
+ }
+
+ /**
+ * @param activity A reference to {@link ChromeTabbedActivity} to pull
+ * {@link android.view.View} data from.
+ * @return The id of the current {@link Tab} as far as the {@link ToolbarModelImpl} sees it.
+ */
+ public static int getCurrentTabId(final ChromeTabbedActivity activity) {
+ ToolbarLayout toolbar = (ToolbarLayout) activity.findViewById(R.id.toolbar);
+ Assert.assertNotNull("Toolbar is null", toolbar);
+
+ ToolbarDataProvider dataProvider = toolbar.getToolbarDataProvider();
+ Tab tab = dataProvider.getTab();
+ return tab != null ? tab.getId() : Tab.INVALID_TAB_ID;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698