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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/tab/UndoIntegrationTest.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/tab/UndoIntegrationTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/tab/UndoIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/tab/UndoIntegrationTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..5c40c490892faa366eba349f3d73bf200c61b999
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/tab/UndoIntegrationTest.java
@@ -0,0 +1,91 @@
+// 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.tab;
+
+import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_END_DEVICE;
+
+import android.test.suitebuilder.annotation.LargeTest;
+
+import org.chromium.base.CommandLine;
+import org.chromium.base.ThreadUtils;
+import org.chromium.base.test.util.Restriction;
+import org.chromium.base.test.util.UrlUtils;
+import org.chromium.chrome.browser.ChromeSwitches;
+import org.chromium.chrome.browser.Tab;
+import org.chromium.chrome.browser.snackbar.SnackbarManager;
+import org.chromium.chrome.browser.tabmodel.TabModel;
+import org.chromium.chrome.browser.tabmodel.TabModelUtils;
+import org.chromium.chrome.test.ChromeTabbedActivityTestBase;
+import org.chromium.content.browser.test.util.Criteria;
+import org.chromium.content.browser.test.util.CriteriaHelper;
+import org.chromium.content.browser.test.util.DOMUtils;
+
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Tests undo and it's interactions with the UI.
+ */
+public class UndoIntegrationTest extends ChromeTabbedActivityTestBase {
+ private static final String WINDOW_OPEN_BUTTON_URL = UrlUtils.encodeHtmlDataUri(
+ "<html>"
+ + " <head>"
+ + " <script>"
+ + " function openWindow() {"
+ + " window.open('about:blank');"
+ + " }"
+ + " </script>"
+ + " </head>"
+ + " <body>"
+ + " <a id=\"link\" onclick=\"setTimeout(openWindow, 500);\">Open</a>"
+ + " </body>"
+ + "</html>"
+ );
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ CommandLine.getInstance().appendSwitch(ChromeSwitches.ENABLE_HIGH_END_UI_UNDO);
+ SnackbarManager.setTimeoutForTesting(1500);
+ startMainActivityOnBlankPage();
+ }
+
+ /**
+ * Test that a tab that is closing can't open other windows.
+ * @throws InterruptedException
+ * @throws TimeoutException
+ */
+ @LargeTest
+ @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
+ public void testAddNewContentsFromClosingTab() throws InterruptedException, TimeoutException {
+ loadUrl(WINDOW_OPEN_BUTTON_URL);
+
+ final TabModel model = getActivity().getTabModelSelector().getCurrentModel();
+ final Tab tab = TabModelUtils.getCurrentTab(model);
+
+ // Clock on the link that will trigger a delayed window popup.
+ DOMUtils.clickNode(this, tab.getContentViewCore(), "link");
+
+ // Attempt to close the tab, which will delay closing until the undo timeout goes away.
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ TabModelUtils.closeTabById(model, tab.getId(), true);
+ assertTrue("Tab was not marked as closing", tab.isClosing());
+ assertTrue("Tab is not actually closing", model.isClosurePending(tab.getId()));
+ }
+ });
+
+ // Give the model a chance to process the undo and close the tab.
+ CriteriaHelper.pollForUIThreadCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return !model.isClosurePending(tab.getId()) && model.getCount() == 0;
+ }
+ });
+
+ // Validate that the model doesn't contain the original tab or any newly opened tabs.
+ assertFalse("Model is still waiting to close the tab", model.isClosurePending(tab.getId()));
+ assertEquals("Model still has tabs", 0, model.getCount());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698