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

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

Issue 2290133002: Make WebView keep keyboard when losing focus (Closed)
Patch Set: Add some tests Created 4 years, 3 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_NON_LOW_E ND_DEVICE; 7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E ND_DEVICE;
8 8
9 import android.content.DialogInterface; 9 import android.content.DialogInterface;
10 import android.content.pm.ActivityInfo; 10 import android.content.pm.ActivityInfo;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 import org.chromium.chrome.test.util.ApplicationTestUtils; 55 import org.chromium.chrome.test.util.ApplicationTestUtils;
56 import org.chromium.chrome.test.util.ChromeRestriction; 56 import org.chromium.chrome.test.util.ChromeRestriction;
57 import org.chromium.chrome.test.util.ChromeTabUtils; 57 import org.chromium.chrome.test.util.ChromeTabUtils;
58 import org.chromium.chrome.test.util.MenuUtils; 58 import org.chromium.chrome.test.util.MenuUtils;
59 import org.chromium.chrome.test.util.NewTabPageTestUtils; 59 import org.chromium.chrome.test.util.NewTabPageTestUtils;
60 import org.chromium.chrome.test.util.OverviewModeBehaviorWatcher; 60 import org.chromium.chrome.test.util.OverviewModeBehaviorWatcher;
61 import org.chromium.content.browser.ContentViewCore; 61 import org.chromium.content.browser.ContentViewCore;
62 import org.chromium.content.browser.test.util.CallbackHelper; 62 import org.chromium.content.browser.test.util.CallbackHelper;
63 import org.chromium.content.browser.test.util.Criteria; 63 import org.chromium.content.browser.test.util.Criteria;
64 import org.chromium.content.browser.test.util.CriteriaHelper; 64 import org.chromium.content.browser.test.util.CriteriaHelper;
65 import org.chromium.content.browser.test.util.DOMUtils;
65 import org.chromium.content.browser.test.util.JavaScriptUtils; 66 import org.chromium.content.browser.test.util.JavaScriptUtils;
66 import org.chromium.content.browser.test.util.UiUtils; 67 import org.chromium.content.browser.test.util.UiUtils;
67 import org.chromium.content.common.ContentSwitches; 68 import org.chromium.content.common.ContentSwitches;
68 import org.chromium.content_public.browser.WebContents; 69 import org.chromium.content_public.browser.WebContents;
69 import org.chromium.content_public.browser.WebContentsObserver; 70 import org.chromium.content_public.browser.WebContentsObserver;
70 import org.chromium.net.test.EmbeddedTestServer; 71 import org.chromium.net.test.EmbeddedTestServer;
71 72
72 import java.io.File; 73 import java.io.File;
73 import java.util.Locale; 74 import java.util.Locale;
74 import java.util.concurrent.Callable; 75 import java.util.concurrent.Callable;
75 import java.util.concurrent.TimeUnit; 76 import java.util.concurrent.TimeUnit;
76 import java.util.concurrent.TimeoutException; 77 import java.util.concurrent.TimeoutException;
77 import java.util.concurrent.atomic.AtomicBoolean; 78 import java.util.concurrent.atomic.AtomicBoolean;
78 import java.util.concurrent.atomic.AtomicReference; 79 import java.util.concurrent.atomic.AtomicReference;
79 80
80 /** 81 /**
81 * General Tab tests. 82 * General Tab tests.
82 */ 83 */
83 public class TabsTest extends ChromeTabbedActivityTestBase { 84 public class TabsTest extends ChromeTabbedActivityTestBase {
84 85
85 private static final String TEST_FILE_PATH = 86 private static final String TEST_FILE_PATH =
86 "/chrome/test/data/android/tabstest/tabs_test.html"; 87 "/chrome/test/data/android/tabstest/tabs_test.html";
87 private static final String TEST_PAGE_FILE_PATH = "/chrome/test/data/google/ google.html"; 88 private static final String TEST_PAGE_FILE_PATH = "/chrome/test/data/google/ google.html";
89 private static final String TEST_INPUT_FILE_PATH =
90 "/chrome/test/data/android/very_long_google.html";
88 91
89 private EmbeddedTestServer mTestServer; 92 private EmbeddedTestServer mTestServer;
90 93
91 private float mPxToDp = 1.0f; 94 private float mPxToDp = 1.0f;
92 private float mTabsViewHeightDp; 95 private float mTabsViewHeightDp;
93 private float mTabsViewWidthDp; 96 private float mTabsViewWidthDp;
94 97
95 private boolean mNotifyChangedCalled; 98 private boolean mNotifyChangedCalled;
96 99
97 private static final int SWIPE_TO_RIGHT_DIRECTION = 1; 100 private static final int SWIPE_TO_RIGHT_DIRECTION = 1;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 274
272 ChromeTabUtils.closeCurrentTab(getInstrumentation(), getActivity()); 275 ChromeTabUtils.closeCurrentTab(getInstrumentation(), getActivity());
273 getInstrumentation().runOnMainSync(new Runnable() { 276 getInstrumentation().runOnMainSync(new Runnable() {
274 @Override 277 @Override
275 public void run() { 278 public void run() {
276 assertEquals(tabCount, getActivity().getCurrentTabModel().getCou nt()); 279 assertEquals(tabCount, getActivity().getCurrentTabModel().getCou nt());
277 } 280 }
278 }); 281 });
279 } 282 }
280 283
284 private void assertWaitForKeyboardStatus(final boolean show) throws Interrup tedException {
285 CriteriaHelper.pollUiThread(new Criteria() {
286 @Override
287 public boolean isSatisfied() {
288 updateFailureReason("expected keyboard show: " + show);
289 return show
290 == org.chromium.ui.UiUtils.isKeyboardShowing(
291 getActivity(), getActivity().getTabsView());
292 }
293 });
294 }
295
296 /**
297 * Verify that opening a new tab, switching to an existing tab and closing c urrent tab hide
298 * keyboard.
299 */
300 @MediumTest
301 public void testHideKeyboard() throws Exception {
302 mTestServer = EmbeddedTestServer.createAndStartFileServer(
303 getInstrumentation().getContext(), Environment.getExternalStorag eDirectory());
304
305 startMainActivityWithURL(mTestServer.getURL(TEST_INPUT_FILE_PATH));
306 DOMUtils.clickNode(this, getActivity().getActivityTab().getContentViewCo re(), "textField");
307 assertWaitForKeyboardStatus(true);
308
309 // Opens a new tab.
310 startMainActivityWithURL(mTestServer.getURL(TEST_INPUT_FILE_PATH));
311 assertWaitForKeyboardStatus(false);
312
313 DOMUtils.clickNode(this, getActivity().getActivityTab().getContentViewCo re(), "textField");
314 assertWaitForKeyboardStatus(true);
315
316 // Switches to an existing tab.
317 ChromeTabUtils.switchTabInCurrentTabModel(getActivity(), 1);
318 assertWaitForKeyboardStatus(false);
319
320 DOMUtils.clickNode(this, getActivity().getActivityTab().getContentViewCo re(), "textField");
321 assertWaitForKeyboardStatus(true);
322
323 // Closes current tab.
324 ChromeTabUtils.closeCurrentTab(getInstrumentation(), getActivity());
325 assertWaitForKeyboardStatus(false);
326 }
327
281 /** 328 /**
282 * Verify that opening a new tab and navigating immediately sets a size on t he newly created 329 * Verify that opening a new tab and navigating immediately sets a size on t he newly created
283 * renderer. https://crbug.com/434477. 330 * renderer. https://crbug.com/434477.
284 * @throws InterruptedException 331 * @throws InterruptedException
285 * @throws TimeoutException 332 * @throws TimeoutException
286 */ 333 */
287 @SmallTest 334 @SmallTest
288 public void testNewTabSetsContentViewSize() throws InterruptedException, Tim eoutException { 335 public void testNewTabSetsContentViewSize() throws InterruptedException, Tim eoutException {
289 ChromeTabUtils.newTabFromMenu(getInstrumentation(), getActivity()); 336 ChromeTabUtils.newTabFromMenu(getInstrumentation(), getActivity());
290 getInstrumentation().waitForIdleSync(); 337 getInstrumentation().waitForIdleSync();
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 if (getName().equals("testOpenAndCloseNewTabButton") 1734 if (getName().equals("testOpenAndCloseNewTabButton")
1688 || getName().equals("testSwitchToTabThatDoesNotHaveThumbnail") 1735 || getName().equals("testSwitchToTabThatDoesNotHaveThumbnail")
1689 || getName().equals("testCloseTabPortrait") 1736 || getName().equals("testCloseTabPortrait")
1690 || getName().equals("testCloseTabLandscape") 1737 || getName().equals("testCloseTabLandscape")
1691 || getName().equals("testTabsAreDestroyedOnModelDestruction")) { 1738 || getName().equals("testTabsAreDestroyedOnModelDestruction")) {
1692 return; 1739 return;
1693 } 1740 }
1694 startMainActivityFromLauncher(); 1741 startMainActivityFromLauncher();
1695 } 1742 }
1696 } 1743 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698