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

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

Issue 1516323003: [Contextual Search] Update testTapOnARIAIgnored. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@6t
Patch Set: Updated description. Created 4 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.contextualsearch; 5 package org.chromium.chrome.browser.contextualsearch;
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 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_PHONE; 8 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_PHONE;
9 import static org.chromium.content.browser.test.util.CriteriaHelper.DEFAULT_POLL ING_INTERVAL; 9 import static org.chromium.content.browser.test.util.CriteriaHelper.DEFAULT_POLL ING_INTERVAL;
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 /** 70 /**
71 * Tests the Contextual Search Manager using instrumentation tests. 71 * Tests the Contextual Search Manager using instrumentation tests.
72 */ 72 */
73 @CommandLineFlags.Add(ChromeSwitches.ENABLE_CONTEXTUAL_SEARCH_FOR_TESTING) 73 @CommandLineFlags.Add(ChromeSwitches.ENABLE_CONTEXTUAL_SEARCH_FOR_TESTING)
74 public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro meActivity> { 74 public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro meActivity> {
75 75
76 private static final String TEST_PAGE = 76 private static final String TEST_PAGE =
77 TestHttpServerClient.getUrl("chrome/test/data/android/contextualsear ch/tap_test.html"); 77 TestHttpServerClient.getUrl("chrome/test/data/android/contextualsear ch/tap_test.html");
78 private static final int TEST_TIMEOUT = 15000; 78 private static final int TEST_TIMEOUT = 15000;
79 private static final int TEST_EXPECTED_FAILURE_TIMEOUT = 1000;
79 80
80 // TODO(donnd): get these from TemplateURL once the low-priority or Contextu al Search API 81 // TODO(donnd): get these from TemplateURL once the low-priority or Contextu al Search API
81 // is fully supported. 82 // is fully supported.
82 private static final String NORMAL_PRIORITY_SEARCH_ENDPOINT = "/search?"; 83 private static final String NORMAL_PRIORITY_SEARCH_ENDPOINT = "/search?";
83 private static final String LOW_PRIORITY_SEARCH_ENDPOINT = "/s?"; 84 private static final String LOW_PRIORITY_SEARCH_ENDPOINT = "/s?";
84 private static final String CONTEXTUAL_SEARCH_PREFETCH_PARAM = "&pf=c"; 85 private static final String CONTEXTUAL_SEARCH_PREFETCH_PARAM = "&pf=c";
85 86
86 private ContextualSearchManager mManager; 87 private ContextualSearchManager mManager;
87 private ContextualSearchFakeServer mFakeServer; 88 private ContextualSearchFakeServer mFakeServer;
88 private ContextualSearchPanel mPanel; 89 private ContextualSearchPanel mPanel;
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 /** 570 /**
570 * Asserts that the panel was never opened. 571 * Asserts that the panel was never opened.
571 * @throws InterruptedException 572 * @throws InterruptedException
572 */ 573 */
573 private void assertPanelNeverOpened() throws InterruptedException { 574 private void assertPanelNeverOpened() throws InterruptedException {
574 waitForPanelToEnterState(PanelState.UNDEFINED); 575 waitForPanelToEnterState(PanelState.UNDEFINED);
575 } 576 }
576 577
577 /** 578 /**
578 * Waits for the Search Panel to enter the given {@code PanelState} and asse rt. 579 * Waits for the Search Panel to enter the given {@code PanelState} and asse rt.
580 * @param state The {@link PanelState} to wait for.
579 * @throws InterruptedException 581 * @throws InterruptedException
580 */ 582 */
581 private void waitForPanelToEnterState(final PanelState state) 583 private void waitForPanelToEnterState(final PanelState state)
582 throws InterruptedException { 584 throws InterruptedException {
583 CriteriaHelper.pollForCriteria(new Criteria() { 585 CriteriaHelper.pollForCriteria(new Criteria() {
584 @Override 586 @Override
585 public boolean isSatisfied() { 587 public boolean isSatisfied() {
586 if (mPanel == null) return false; 588 if (mPanel == null) return false;
587 updateFailureReason("Panel did not enter " + state + " state. " 589 updateFailureReason("Panel did not enter " + state + " state. "
588 + "Instead, the current state is " + mPanel.getPanelStat e() + "."); 590 + "Instead, the current state is " + mPanel.getPanelStat e() + ".");
589 return mPanel.getPanelState() == state; 591 return mPanel.getPanelState() == state;
590 } 592 }
591 }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL); 593 }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL);
592 } 594 }
593 595
594 /** 596 /**
597 * Asserts that the panel is still in the given state and continues to stay that way
598 * for a while.
599 * Waits for a reasonable amount of time for the panel to change to a differ ent state,
600 * and verifies that it did not change state while this method is executing.
601 * Note that it's quite possible for the panel to transition through some ot her state and
602 * back to the initial state before this method is called without that being detected,
603 * because this method only monitors state during its own execution.
604 * @param initialState The initial state of the panel at the beginning of an operation that
605 * should not change the panel state.
606 * @throws InterruptedException
607 */
608 private void assertPanelStillInState(final PanelState initialState)
609 throws InterruptedException {
610 boolean didChangeState = false;
611 long startTime = SystemClock.uptimeMillis();
612 while (!didChangeState
613 && SystemClock.uptimeMillis() - startTime < TEST_EXPECTED_FAILUR E_TIMEOUT) {
614 Thread.sleep(DEFAULT_POLLING_INTERVAL);
615 didChangeState = mPanel.getPanelState() != initialState;
Theresa 2016/01/13 23:15:12 Do we want to break if didChangeState is true so t
Donn Denman 2016/01/13 23:41:27 That's already being done by the "while" condition
Theresa 2016/01/13 23:44:04 Nope, my mistake, I didn't read the while closely
616 }
617 assertFalse(didChangeState);
618 }
619
620 /**
595 * Waits for the manager to finish processing a gesture. 621 * Waits for the manager to finish processing a gesture.
596 * Tells the manager that a gesture has started, and then waits for it to co mplete. 622 * Tells the manager that a gesture has started, and then waits for it to co mplete.
597 * @throws InterruptedException 623 * @throws InterruptedException
598 */ 624 */
599 private void waitForGestureProcessing() throws InterruptedException { 625 private void waitForGestureProcessing() throws InterruptedException {
600 CriteriaHelper.pollForCriteria(new Criteria("Gesture processing did not complete.") { 626 CriteriaHelper.pollForCriteria(new Criteria("Gesture processing did not complete.") {
601 @Override 627 @Override
602 public boolean isSatisfied() { 628 public boolean isSatisfied() {
603 return !mSelectionController.wasAnyTapGestureDetected(); 629 return !mSelectionController.wasAnyTapGestureDetected();
604 } 630 }
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 getActivity().getTabModelSelector().removeObserver(observer); 1421 getActivity().getTabModelSelector().removeObserver(observer);
1396 } 1422 }
1397 1423
1398 /** 1424 /**
1399 * Tests that a Tap gesture on an element with an ARIA role does not trigger . 1425 * Tests that a Tap gesture on an element with an ARIA role does not trigger .
1400 */ 1426 */
1401 @SmallTest 1427 @SmallTest
1402 @Feature({"ContextualSearch"}) 1428 @Feature({"ContextualSearch"})
1403 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 1429 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
1404 public void testTapOnRoleIgnored() throws InterruptedException, TimeoutExcep tion { 1430 public void testTapOnRoleIgnored() throws InterruptedException, TimeoutExcep tion {
1431 PanelState initialState = mPanel.getPanelState();
1405 clickNode("role"); 1432 clickNode("role");
1406 assertPanelNeverOpened(); 1433 assertPanelStillInState(initialState);
1407 } 1434 }
1408 1435
1409 /** 1436 /**
1410 * Tests that a Tap gesture on an element with an ARIA attribute does not tr igger. 1437 * Tests that a Tap gesture on an element with an ARIA attribute does not tr igger.
1411 * http://crbug.com/542874 1438 * http://crbug.com/542874
1439 */
1412 @SmallTest 1440 @SmallTest
1413 @Feature({"ContextualSearch"}) 1441 @Feature({"ContextualSearch"})
1414 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 1442 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
1415 */
1416 @DisabledTest
1417 public void testTapOnARIAIgnored() throws InterruptedException, TimeoutExcep tion { 1443 public void testTapOnARIAIgnored() throws InterruptedException, TimeoutExcep tion {
1444 PanelState initialState = mPanel.getPanelState();
1418 clickNode("aria"); 1445 clickNode("aria");
1419 assertPanelNeverOpened(); 1446 assertPanelStillInState(initialState);
1420 } 1447 }
1421 1448
1422 /** 1449 /**
1423 * Tests that a Tap gesture on an element that is focusable does not trigger . 1450 * Tests that a Tap gesture on an element that is focusable does not trigger .
1424 */ 1451 */
1425 @SmallTest 1452 @SmallTest
1426 @Feature({"ContextualSearch"}) 1453 @Feature({"ContextualSearch"})
1427 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 1454 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
1428 public void testTapOnFocusableIgnored() throws InterruptedException, Timeout Exception { 1455 public void testTapOnFocusableIgnored() throws InterruptedException, Timeout Exception {
1456 PanelState initialState = mPanel.getPanelState();
1429 clickNode("focusable"); 1457 clickNode("focusable");
1430 assertPanelNeverOpened(); 1458 assertPanelStillInState(initialState);
1431 } 1459 }
1432 1460
1433 /** 1461 /**
1434 * Tests that taps can be resolve-limited for decided users. 1462 * Tests that taps can be resolve-limited for decided users.
1435 */ 1463 */
1436 @SmallTest 1464 @SmallTest
1437 @Feature({"ContextualSearch"}) 1465 @Feature({"ContextualSearch"})
1438 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) 1466 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE})
1439 public void testTapResolveLimitForDecided() throws InterruptedException, Tim eoutException { 1467 public void testTapResolveLimitForDecided() throws InterruptedException, Tim eoutException {
1440 mPolicy.setTapResolveLimitForDecidedForTesting(2); 1468 mPolicy.setTapResolveLimitForDecidedForTesting(2);
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 ContextualSearchFieldTrial.DISABLE_FORCE_TRANSLATION_ONEBOX + "=true "}) 2558 ContextualSearchFieldTrial.DISABLE_FORCE_TRANSLATION_ONEBOX + "=true "})
2531 public void testLongpressTranslateDisabledDoesNotTranslate() 2559 public void testLongpressTranslateDisabledDoesNotTranslate()
2532 throws InterruptedException, TimeoutException { 2560 throws InterruptedException, TimeoutException {
2533 // Unless disabled, LongPress on any word should trigger translation. 2561 // Unless disabled, LongPress on any word should trigger translation.
2534 simulateLongPressSearch("search"); 2562 simulateLongPressSearch("search");
2535 2563
2536 // Make sure we did not try to trigger translate. 2564 // Make sure we did not try to trigger translate.
2537 assertFalse(mManager.getRequest().isTranslationForced()); 2565 assertFalse(mManager.getRequest().isTranslationForced());
2538 } 2566 }
2539 } 2567 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698