OLD | NEW |
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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 */ | 300 */ |
301 private void waitForPanelToPeekAndAssert() throws InterruptedException { | 301 private void waitForPanelToPeekAndAssert() throws InterruptedException { |
302 assertTrue("Search Bar did not peek.", waitForPanelToEnterState(PanelSta
te.PEEKED)); | 302 assertTrue("Search Bar did not peek.", waitForPanelToEnterState(PanelSta
te.PEEKED)); |
303 } | 303 } |
304 | 304 |
305 /** | 305 /** |
306 * Waits for the Search Panel to expand, and asserts that it did expand. | 306 * Waits for the Search Panel to expand, and asserts that it did expand. |
307 * @throws InterruptedException | 307 * @throws InterruptedException |
308 */ | 308 */ |
309 private void waitForPanelToExpandAndAssert() throws InterruptedException { | 309 private void waitForPanelToExpandAndAssert() throws InterruptedException { |
310 assertTrue("Search Bar did not expand.", waitForPanelToEnterState(PanelS
tate.EXPANDED)); | 310 assertTrue("Search Panel did not expand.", waitForPanelToEnterState(Pane
lState.EXPANDED)); |
311 } | 311 } |
312 | 312 |
313 /** | 313 /** |
314 * Waits for the Search Panel to maximize, and asserts that it did maximize. | 314 * Waits for the Search Panel to maximize, and asserts that it did maximize. |
315 * @throws InterruptedException | 315 * @throws InterruptedException |
316 */ | 316 */ |
317 private void waitForPanelToMaximizeAndAssert() throws InterruptedException { | 317 private void waitForPanelToMaximizeAndAssert() throws InterruptedException { |
318 assertTrue("Search Bar did not maximize.", waitForPanelToEnterState(Pane
lState.MAXIMIZED)); | 318 assertTrue( |
| 319 "Search Panel did not maximize.", waitForPanelToEnterState(Panel
State.MAXIMIZED)); |
319 } | 320 } |
320 | 321 |
321 /** | 322 /** |
322 * Waits for the Search Panel to close, and asserts that it did close. | 323 * Waits for the Search Panel to close, and asserts that it did close. |
323 * @throws InterruptedException | 324 * @throws InterruptedException |
324 */ | 325 */ |
325 private void waitForPanelToCloseAndAssert() throws InterruptedException { | 326 private void waitForPanelToCloseAndAssert() throws InterruptedException { |
326 // TODO(donnd): figure out why using waitForPanelToEnterState here doesn
't work. | 327 assertTrue("Search Panel did not close.", waitForPanelToEnterState(Panel
State.CLOSED)); |
327 assertTrue("Search Bar did not close.", | |
328 CriteriaHelper.pollForCriteria(new Criteria() { | |
329 @Override | |
330 public boolean isSatisfied() { | |
331 return !mManager.isSearchPanelShowing(); | |
332 } | |
333 }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL)); | |
334 } | 328 } |
335 | 329 |
336 /** | 330 /** |
| 331 * Asserts that the panel was never opened. |
| 332 * @throws InterruptedException |
| 333 */ |
| 334 private void assertPanelNeverOpened() throws InterruptedException { |
| 335 assertTrue( |
| 336 "Search Panel actually did open.", waitForPanelToEnterState(Pane
lState.UNDEFINED)); |
| 337 } |
| 338 |
| 339 /** |
337 * Waits for the Search Panel to enter the given {@code PanelState}. | 340 * Waits for the Search Panel to enter the given {@code PanelState}. |
338 * @throws InterruptedException | 341 * @throws InterruptedException |
339 */ | 342 */ |
340 private boolean waitForPanelToEnterState(final PanelState state) throws Inte
rruptedException { | 343 private boolean waitForPanelToEnterState(final PanelState state) throws Inte
rruptedException { |
341 return CriteriaHelper.pollForCriteria(new Criteria() { | 344 return CriteriaHelper.pollForCriteria(new Criteria() { |
342 @Override | 345 @Override |
343 public boolean isSatisfied() { | 346 public boolean isSatisfied() { |
344 return mPanelDelegate != null | 347 return mPanelDelegate != null |
345 && mPanelDelegate.getPanelState() == state; | 348 && mPanelDelegate.getPanelState() == state; |
346 } | 349 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 CriteriaHelper.pollForCriteria(new Criteria() { | 388 CriteriaHelper.pollForCriteria(new Criteria() { |
386 @Override | 389 @Override |
387 public boolean isSatisfied() { | 390 public boolean isSatisfied() { |
388 return TextUtils.equals(text, getSelectedText()); | 391 return TextUtils.equals(text, getSelectedText()); |
389 } | 392 } |
390 }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL)); | 393 }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL)); |
391 } | 394 } |
392 | 395 |
393 /** | 396 /** |
394 * Waits for the selection to be dissolved. | 397 * Waits for the selection to be dissolved. |
| 398 * Use this method any time a test repeatedly establishes and dissolves a se
lection to ensure |
| 399 * that the selection has been completely dissolved before simulating the ne
xt selection event. |
395 * This is needed because the renderer's notification of a selection going a
way is async, | 400 * This is needed because the renderer's notification of a selection going a
way is async, |
396 * and a subsequent tap may think there's a current selection until it has b
een dissolved. | 401 * and a subsequent tap may think there's a current selection until it has b
een dissolved. |
397 */ | 402 */ |
398 private void waitForSelectionDissolved() throws InterruptedException { | 403 private void waitForSelectionDissolved() throws InterruptedException { |
399 assertTrue("Selection never dissolved.", CriteriaHelper.pollForCriteria(
new Criteria() { | 404 assertTrue("Selection never dissolved.", CriteriaHelper.pollForCriteria(
new Criteria() { |
400 @Override | 405 @Override |
401 public boolean isSatisfied() { | 406 public boolean isSatisfied() { |
402 return !mSelectionController.isSelectionEstablished(); | 407 return !mSelectionController.isSelectionEstablished(); |
403 } | 408 } |
404 }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL)); | 409 }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL)); |
405 } | 410 } |
406 | 411 |
407 /** | 412 /** |
| 413 * Waits for the panel to close and then waits for the selection to dissolve
. |
| 414 */ |
| 415 private void waitForPanelToCloseAndSelectionDissolved() throws InterruptedEx
ception { |
| 416 waitForPanelToCloseAndAssert(); |
| 417 waitForSelectionDissolved(); |
| 418 } |
| 419 |
| 420 /** |
408 * A ContentViewCore that has some methods stubbed out for testing. | 421 * A ContentViewCore that has some methods stubbed out for testing. |
409 */ | 422 */ |
410 private static final class StubbedContentViewCore extends ContentViewCore { | 423 private static final class StubbedContentViewCore extends ContentViewCore { |
411 private boolean mIsFocusedNodeEditable; | 424 private boolean mIsFocusedNodeEditable; |
412 | 425 |
413 public StubbedContentViewCore(Context context) { | 426 public StubbedContentViewCore(Context context) { |
414 super(context); | 427 super(context); |
415 } | 428 } |
416 | 429 |
417 public void setIsFocusedNodeEditableForTest(boolean isFocusedNodeEditabl
e) { | 430 public void setIsFocusedNodeEditableForTest(boolean isFocusedNodeEditabl
e) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 /** | 471 /** |
459 * Scrolls the base page. | 472 * Scrolls the base page. |
460 */ | 473 */ |
461 private void scrollBasePage() { | 474 private void scrollBasePage() { |
462 swipe(0.f, 0.75f, 0.f, 0.7f, 100); | 475 swipe(0.f, 0.75f, 0.f, 0.7f, 100); |
463 } | 476 } |
464 | 477 |
465 /** | 478 /** |
466 * Taps the base page near the top. | 479 * Taps the base page near the top. |
467 */ | 480 */ |
468 private void tapBasePage() throws InterruptedException { | 481 private void tapBasePageToClosePanel() throws InterruptedException { |
469 tapBasePage(0.1f, 0.1f); | 482 tapBasePage(0.1f, 0.1f); |
| 483 waitForPanelToCloseAndAssert(); |
470 } | 484 } |
471 | 485 |
472 /** | 486 /** |
473 * Taps the base page at the given x, y position. | 487 * Taps the base page at the given x, y position. |
474 */ | 488 */ |
475 private void tapBasePage(float x, float y) throws InterruptedException { | 489 private void tapBasePage(float x, float y) { |
476 Point size = new Point(); | 490 Point size = new Point(); |
477 getActivity().getWindowManager().getDefaultDisplay().getSize(size); | 491 getActivity().getWindowManager().getDefaultDisplay().getSize(size); |
478 x *= size.x; | 492 x *= size.x; |
479 y *= size.y; | 493 y *= size.y; |
480 singleClick(x, y); | 494 singleClick(x, y); |
481 waitForPanelToCloseAndAssert(); | |
482 } | 495 } |
483 | 496 |
484 /** | 497 /** |
485 * Click various places to cause the panel to show, expand, then close. | 498 * Click various places to cause the panel to show, expand, then close. |
486 */ | 499 */ |
487 private void clickToExpandAndClosePanel() throws InterruptedException, Timeo
utException { | 500 private void clickToExpandAndClosePanel() throws InterruptedException, Timeo
utException { |
488 clickWordNode("states"); | 501 clickWordNode("states"); |
489 tapPeekingBarToExpandAndAssert(); | 502 tapBarToExpandAndClosePanel(); |
490 tapBasePage(); | 503 waitForSelectionDissolved(); |
491 waitForPanelToCloseAndAssert(); | |
492 } | 504 } |
493 | 505 |
494 /** | 506 /** |
| 507 * Tap on the peeking Bar to expand the panel, then taps on the base page to
close it. |
| 508 */ |
| 509 private void tapBarToExpandAndClosePanel() throws InterruptedException { |
| 510 tapPeekingBarToExpandAndAssert(); |
| 511 tapBasePageToClosePanel(); |
| 512 } |
| 513 |
| 514 /** |
495 * Generate a click in the panel's bar. | 515 * Generate a click in the panel's bar. |
496 * @barHeight The vertical position where the click should take place as a p
ercentage | 516 * @barHeight The vertical position where the click should take place as a p
ercentage |
497 * of the screen size. | 517 * of the screen size. |
498 */ | 518 */ |
499 private void clickPanelBar(float barPositionVertical) { | 519 private void clickPanelBar(float barPositionVertical) { |
500 Point size = new Point(); | 520 Point size = new Point(); |
501 getActivity().getWindowManager().getDefaultDisplay().getSize(size); | 521 getActivity().getWindowManager().getDefaultDisplay().getSize(size); |
502 float w = size.x; | 522 float w = size.x; |
503 float h = size.y; | 523 float h = size.y; |
504 boolean landscape = w > h; | 524 boolean landscape = w > h; |
(...skipping 14 matching lines...) Expand all Loading... |
519 /** | 539 /** |
520 * Simple sequence useful for checking if a Search Term Resolution request i
s sent. | 540 * Simple sequence useful for checking if a Search Term Resolution request i
s sent. |
521 * Resets the fake server and clicks near to cause a search, then clicks far
to let the panel | 541 * Resets the fake server and clicks near to cause a search, then clicks far
to let the panel |
522 * drop down (taking us back to the same state). | 542 * drop down (taking us back to the same state). |
523 */ | 543 */ |
524 private void clickToTriggerSearchTermResolution() | 544 private void clickToTriggerSearchTermResolution() |
525 throws InterruptedException, TimeoutException { | 545 throws InterruptedException, TimeoutException { |
526 mFakeServer.reset(); | 546 mFakeServer.reset(); |
527 clickWordNode("states"); | 547 clickWordNode("states"); |
528 clickNode("states-far"); | 548 clickNode("states-far"); |
529 waitForPanelToCloseAndAssert(); | 549 waitForPanelToCloseAndSelectionDissolved(); |
530 } | 550 } |
531 | 551 |
532 /** | 552 /** |
533 * Simple sequence useful for checking if a Search Request is prefetched. | 553 * Simple sequence useful for checking if a Search Request is prefetched. |
534 * Resets the fake server and clicks near to cause a search, fakes a server
response to | 554 * Resets the fake server and clicks near to cause a search, fakes a server
response to |
535 * trigger a prefetch, then clicks far to let the panel drop down | 555 * trigger a prefetch, then clicks far to let the panel drop down |
536 * which takes us back to the starting state except the the fake server know
s | 556 * which takes us back to the starting state except the the fake server know
s |
537 * if a prefetch occurred. | 557 * if a prefetch occurred. |
538 */ | 558 */ |
539 private void clickToTriggerPrefetch() throws InterruptedException, TimeoutEx
ception { | 559 private void clickToTriggerPrefetch() throws InterruptedException, TimeoutEx
ception { |
540 mFakeServer.reset(); | 560 mFakeServer.reset(); |
541 clickWordNode("states"); | 561 clickWordNode("states"); |
542 assertSearchTermRequested(); | 562 assertSearchTermRequested(); |
543 fakeResponse(false, 200, "States", "display-text", "alternate-term", fal
se); | 563 fakeResponse(false, 200, "States", "display-text", "alternate-term", fal
se); |
544 waitForPanelToPeekAndAssert(); | 564 waitForPanelToPeekAndAssert(); |
545 clickNode("states-far"); | 565 clickNode("states-far"); |
546 waitForPanelToCloseAndAssert(); | 566 waitForPanelToCloseAndSelectionDissolved(); |
547 } | 567 } |
548 | 568 |
549 /** | 569 /** |
550 * Simple sequence to click, resolve, and prefetch. Verifies a prefetch occ
urred. | 570 * Simple sequence to click, resolve, and prefetch. Verifies a prefetch occ
urred. |
551 */ | 571 */ |
552 private void clickToResolveAndAssertPrefetch() throws InterruptedException,
TimeoutException { | 572 private void clickToResolveAndAssertPrefetch() throws InterruptedException,
TimeoutException { |
553 clickWordNode("states"); | 573 clickWordNode("states"); |
554 assertLoadedNoUrl(); | 574 assertLoadedNoUrl(); |
555 assertSearchTermRequested(); | 575 assertSearchTermRequested(); |
556 | 576 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 waitForPanelToPeekAndAssert(); | 741 waitForPanelToPeekAndAssert(); |
722 assertLoadedNoUrl(); | 742 assertLoadedNoUrl(); |
723 assertNoContentViewCore(); | 743 assertNoContentViewCore(); |
724 swipePanelUp(); | 744 swipePanelUp(); |
725 waitForPanelToExpandAndAssert(); | 745 waitForPanelToExpandAndAssert(); |
726 assertContentViewCoreCreated(); | 746 assertContentViewCoreCreated(); |
727 assertLoadedNormalPriorityUrl(); | 747 assertLoadedNormalPriorityUrl(); |
728 assertEquals(1, mFakeServer.loadedUrlCount()); | 748 assertEquals(1, mFakeServer.loadedUrlCount()); |
729 | 749 |
730 // tap the base page to close. | 750 // tap the base page to close. |
731 tapBasePage(); | 751 tapBasePageToClosePanel(); |
732 waitForPanelToCloseAndAssert(); | |
733 assertEquals(1, mFakeServer.loadedUrlCount()); | 752 assertEquals(1, mFakeServer.loadedUrlCount()); |
734 assertNoContentViewCore(); | 753 assertNoContentViewCore(); |
735 } | 754 } |
736 | 755 |
737 /** | 756 /** |
738 * Tests a sequence in landscape orientation: swiping the overlay open, afte
r an | 757 * Tests a sequence in landscape orientation: swiping the overlay open, afte
r an |
739 * initial tap that activates the peeking card. | 758 * initial tap that activates the peeking card. |
740 */ | 759 */ |
741 @SmallTest | 760 @SmallTest |
742 @Feature({"ContextualSearch"}) | 761 @Feature({"ContextualSearch"}) |
(...skipping 22 matching lines...) Expand all Loading... |
765 fakeResponse(false, 200, "states", "United States Intelligence", "altern
ate-term", false); | 784 fakeResponse(false, 200, "states", "United States Intelligence", "altern
ate-term", false); |
766 assertContainsParameters("states", "alternate-term"); | 785 assertContainsParameters("states", "alternate-term"); |
767 assertEquals(1, mFakeServer.loadedUrlCount()); | 786 assertEquals(1, mFakeServer.loadedUrlCount()); |
768 assertLoadedLowPriorityUrl(); | 787 assertLoadedLowPriorityUrl(); |
769 assertContentViewCoreCreated(); | 788 assertContentViewCoreCreated(); |
770 tapPeekingBarToExpandAndAssert(); | 789 tapPeekingBarToExpandAndAssert(); |
771 assertLoadedLowPriorityUrl(); | 790 assertLoadedLowPriorityUrl(); |
772 assertEquals(1, mFakeServer.loadedUrlCount()); | 791 assertEquals(1, mFakeServer.loadedUrlCount()); |
773 | 792 |
774 // tap the base page to close. | 793 // tap the base page to close. |
775 tapBasePage(); | 794 tapBasePageToClosePanel(); |
776 waitForPanelToCloseAndAssert(); | |
777 assertEquals(1, mFakeServer.loadedUrlCount()); | 795 assertEquals(1, mFakeServer.loadedUrlCount()); |
778 assertNoContentViewCore(); | 796 assertNoContentViewCore(); |
779 } | 797 } |
780 | 798 |
781 /** | 799 /** |
782 * Tests that only a single low-priority request is issued for a Tap/Open se
quence. | 800 * Tests that only a single low-priority request is issued for a Tap/Open se
quence. |
783 */ | 801 */ |
784 @SmallTest | 802 @SmallTest |
785 @Feature({"ContextualSearch"}) | 803 @Feature({"ContextualSearch"}) |
786 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 804 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 } | 1189 } |
1172 | 1190 |
1173 /** | 1191 /** |
1174 * Tests that a Tap gesture on an element with an ARIA role does not trigger
. | 1192 * Tests that a Tap gesture on an element with an ARIA role does not trigger
. |
1175 */ | 1193 */ |
1176 @SmallTest | 1194 @SmallTest |
1177 @Feature({"ContextualSearch"}) | 1195 @Feature({"ContextualSearch"}) |
1178 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1196 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
1179 public void testTapOnRoleIgnored() throws InterruptedException, TimeoutExcep
tion { | 1197 public void testTapOnRoleIgnored() throws InterruptedException, TimeoutExcep
tion { |
1180 clickNode("role"); | 1198 clickNode("role"); |
1181 waitForGestureToClosePanelAndAssertNoSelection(); | 1199 assertPanelNeverOpened(); |
1182 } | 1200 } |
1183 | 1201 |
1184 /** | 1202 /** |
1185 * Tests that a Tap gesture on an element with an ARIA attribute does not tr
igger. | 1203 * Tests that a Tap gesture on an element with an ARIA attribute does not tr
igger. |
1186 */ | 1204 */ |
1187 @SmallTest | 1205 @SmallTest |
1188 @Feature({"ContextualSearch"}) | 1206 @Feature({"ContextualSearch"}) |
1189 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1207 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
1190 public void testTapOnARIAIgnored() throws InterruptedException, TimeoutExcep
tion { | 1208 public void testTapOnARIAIgnored() throws InterruptedException, TimeoutExcep
tion { |
1191 clickNode("aria"); | 1209 clickNode("aria"); |
1192 waitForGestureToClosePanelAndAssertNoSelection(); | 1210 assertPanelNeverOpened(); |
1193 } | 1211 } |
1194 | 1212 |
1195 /** | 1213 /** |
1196 * Tests that a Tap gesture on an element that is focusable does not trigger
. | 1214 * Tests that a Tap gesture on an element that is focusable does not trigger
. |
1197 */ | 1215 */ |
1198 @SmallTest | 1216 @SmallTest |
1199 @Feature({"ContextualSearch"}) | 1217 @Feature({"ContextualSearch"}) |
1200 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1218 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
1201 public void testTapOnFocusableIgnored() throws InterruptedException, Timeout
Exception { | 1219 public void testTapOnFocusableIgnored() throws InterruptedException, Timeout
Exception { |
1202 clickNode("focusable"); | 1220 clickNode("focusable"); |
1203 waitForGestureToClosePanelAndAssertNoSelection(); | 1221 assertPanelNeverOpened(); |
1204 } | 1222 } |
1205 | 1223 |
1206 /** | 1224 /** |
1207 * Tests that taps can be resolve-limited for decided users. | 1225 * Tests that taps can be resolve-limited for decided users. |
1208 * | 1226 * |
1209 * @SmallTest | 1227 * @SmallTest |
1210 * @Feature({"ContextualSearch"}) | 1228 * @Feature({"ContextualSearch"}) |
1211 * crbug.com/487759 | 1229 * crbug.com/487759 |
1212 */ | 1230 */ |
1213 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1231 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 @CommandLineFlags.Add({ | 1348 @CommandLineFlags.Add({ |
1331 ContextualSearchFieldTrial.PROMO_ON_LIMITED_TAPS + "=true", | 1349 ContextualSearchFieldTrial.PROMO_ON_LIMITED_TAPS + "=true", |
1332 ContextualSearchFieldTrial.TAP_TRIGGERED_PROMO_LIMIT + "=2"}) | 1350 ContextualSearchFieldTrial.TAP_TRIGGERED_PROMO_LIMIT + "=2"}) |
1333 @FlakyTest | 1351 @FlakyTest |
1334 public void testTapTriggeredPromoLimitForOptOut() | 1352 public void testTapTriggeredPromoLimitForOptOut() |
1335 throws InterruptedException, TimeoutException { | 1353 throws InterruptedException, TimeoutException { |
1336 mPolicy.overrideDecidedStateForTesting(false); | 1354 mPolicy.overrideDecidedStateForTesting(false); |
1337 | 1355 |
1338 clickWordNode("states"); | 1356 clickWordNode("states"); |
1339 clickNode("states-far"); | 1357 clickNode("states-far"); |
1340 waitForPanelToCloseAndAssert(); | 1358 waitForPanelToCloseAndSelectionDissolved(); |
1341 clickWordNode("states"); | 1359 clickWordNode("states"); |
1342 clickNode("states-far"); | 1360 clickNode("states-far"); |
1343 waitForPanelToCloseAndAssert(); | 1361 waitForPanelToCloseAndSelectionDissolved(); |
1344 | 1362 |
1345 // 3rd click won't peek the panel. | 1363 // 3rd click won't peek the panel. |
1346 clickNode("states"); | 1364 clickNode("states"); |
1347 assertPanelClosedOrUndefined(); | 1365 assertPanelClosedOrUndefined(); |
1348 // The Tap should not select any text either! | 1366 // The Tap should not select any text either! |
1349 assertNull(getSelectedText()); | 1367 assertNull(getSelectedText()); |
1350 | 1368 |
1351 // A long-press should still show the promo bar. | 1369 // A long-press should still show the promo bar. |
1352 longPressNode("states"); | 1370 longPressNode("states"); |
1353 waitForPanelToPeekAndAssert(); | 1371 waitForPanelToPeekAndAssert(); |
1354 | 1372 |
1355 // Expanding the panel should deactivate the limit. | 1373 // Expanding the panel should deactivate the limit. |
1356 clickToExpandAndClosePanel(); | 1374 tapBarToExpandAndClosePanel(); |
| 1375 // Clear the long-press selection. |
| 1376 clickNode("states-far"); |
1357 | 1377 |
1358 // Three taps should work now. | 1378 // Three taps should work now. |
1359 clickWordNode("states"); | 1379 clickWordNode("states"); |
1360 clickNode("states-far"); | 1380 clickNode("states-far"); |
1361 waitForPanelToCloseAndAssert(); | 1381 waitForPanelToCloseAndSelectionDissolved(); |
1362 clickWordNode("states"); | 1382 clickWordNode("states"); |
1363 clickNode("states-far"); | 1383 clickNode("states-far"); |
1364 waitForPanelToCloseAndAssert(); | 1384 waitForPanelToCloseAndSelectionDissolved(); |
1365 clickWordNode("states"); | 1385 clickWordNode("states"); |
1366 clickNode("states-far"); | 1386 clickNode("states-far"); |
1367 waitForPanelToCloseAndAssert(); | 1387 waitForPanelToCloseAndSelectionDissolved(); |
1368 } | 1388 } |
1369 | 1389 |
1370 /** | 1390 /** |
1371 * This is a test that happens to create a separate bar without any content
area! | 1391 * This is a test that happens to create a separate bar without any content
area! |
1372 * | 1392 * |
1373 * @SmallTest | 1393 * @SmallTest |
1374 * @Feature({"ContextualSearch"}) | 1394 * @Feature({"ContextualSearch"}) |
1375 */ | 1395 */ |
1376 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1396 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
1377 @CommandLineFlags.Add( | 1397 @CommandLineFlags.Add( |
1378 ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_DECIDED + "=2") | 1398 ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_DECIDED + "=2") |
1379 @FlakyTest | 1399 @FlakyTest |
1380 public void testDisembodiedBar() throws InterruptedException, TimeoutExcepti
on { | 1400 public void testDisembodiedBar() throws InterruptedException, TimeoutExcepti
on { |
1381 clickToTriggerPrefetch(); | 1401 clickToTriggerPrefetch(); |
1382 assertLoadedLowPriorityUrl(); | 1402 assertLoadedLowPriorityUrl(); |
1383 clickToTriggerPrefetch(); | 1403 clickToTriggerPrefetch(); |
1384 assertLoadedLowPriorityUrl(); | 1404 assertLoadedLowPriorityUrl(); |
1385 // 3rd click should not preload. | 1405 // 3rd click should not preload. |
1386 clickToTriggerPrefetch(); | 1406 clickToTriggerPrefetch(); |
1387 assertLoadedNoUrl(); | 1407 assertLoadedNoUrl(); |
1388 | 1408 |
1389 // Expanding the panel should reset the limit. | 1409 // Expanding the panel should reset the limit. |
1390 swipePanelUp(); | 1410 swipePanelUp(); |
1391 singleClick(0.5f, 0.5f); | 1411 singleClick(0.5f, 0.5f); |
1392 waitForPanelToCloseAndAssert(); | 1412 waitForPanelToCloseAndSelectionDissolved(); |
1393 | 1413 |
1394 // Click should preload again. | 1414 // Click should preload again. |
1395 clickToTriggerPrefetch(); | 1415 clickToTriggerPrefetch(); |
1396 assertLoadedLowPriorityUrl(); | 1416 assertLoadedLowPriorityUrl(); |
1397 } | 1417 } |
1398 | 1418 |
1399 /** | 1419 /** |
1400 * Tests expanding the panel before the search term has resolved, verifies t
hat nothing | 1420 * Tests expanding the panel before the search term has resolved, verifies t
hat nothing |
1401 * loads until the resolve completes and that it's now a normal priority URL
. | 1421 * loads until the resolve completes and that it's now a normal priority URL
. |
1402 */ | 1422 */ |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 @SmallTest | 1542 @SmallTest |
1523 @Feature({"ContextualSearch"}) | 1543 @Feature({"ContextualSearch"}) |
1524 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1544 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
1525 public void testAppMenuSuppressedWhenExpanded() throws InterruptedException,
TimeoutException { | 1545 public void testAppMenuSuppressedWhenExpanded() throws InterruptedException,
TimeoutException { |
1526 clickWordNode("states"); | 1546 clickWordNode("states"); |
1527 tapPeekingBarToExpandAndAssert(); | 1547 tapPeekingBarToExpandAndAssert(); |
1528 | 1548 |
1529 pressAppMenuKey(); | 1549 pressAppMenuKey(); |
1530 assertAppMenuVisibility(false); | 1550 assertAppMenuVisibility(false); |
1531 | 1551 |
1532 tapBasePage(); | 1552 tapBasePageToClosePanel(); |
1533 waitForPanelToCloseAndAssert(); | |
1534 | 1553 |
1535 pressAppMenuKey(); | 1554 pressAppMenuKey(); |
1536 assertAppMenuVisibility(true); | 1555 assertAppMenuVisibility(true); |
1537 } | 1556 } |
1538 | 1557 |
1539 /** | 1558 /** |
1540 * Tests that the App Menu gets suppressed when Search Panel is maximized. | 1559 * Tests that the App Menu gets suppressed when Search Panel is maximized. |
1541 */ | 1560 */ |
1542 @SmallTest | 1561 @SmallTest |
1543 @Feature({"ContextualSearch"}) | 1562 @Feature({"ContextualSearch"}) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1587 // A simple Tap should change the counter. | 1606 // A simple Tap should change the counter. |
1588 clickToTriggerPrefetch(); | 1607 clickToTriggerPrefetch(); |
1589 assertTapPromoCounterEnabledAt(1); | 1608 assertTapPromoCounterEnabledAt(1); |
1590 | 1609 |
1591 // Another Tap should increase the counter. | 1610 // Another Tap should increase the counter. |
1592 clickToTriggerPrefetch(); | 1611 clickToTriggerPrefetch(); |
1593 assertTapPromoCounterEnabledAt(2); | 1612 assertTapPromoCounterEnabledAt(2); |
1594 | 1613 |
1595 // Now we're at the limit, a tap should be ignored. | 1614 // Now we're at the limit, a tap should be ignored. |
1596 clickNode("states"); | 1615 clickNode("states"); |
1597 waitForPanelToCloseAndAssert(); | 1616 waitForPanelToCloseAndSelectionDissolved(); |
1598 assertTapPromoCounterEnabledAt(2); | 1617 assertTapPromoCounterEnabledAt(2); |
1599 | 1618 |
1600 // An open should disable the counter, but we need to use long-press (ta
p is now disabled). | 1619 // An open should disable the counter, but we need to use long-press (ta
p is now disabled). |
1601 longPressNode("states-far"); | 1620 longPressNode("states-far"); |
1602 tapPeekingBarToExpandAndAssert(); | 1621 tapPeekingBarToExpandAndAssert(); |
1603 tapBasePage(); | 1622 tapBasePageToClosePanel(); |
1604 waitForPanelToCloseAndAssert(); | |
1605 assertTapPromoCounterDisabledAt(2); | 1623 assertTapPromoCounterDisabledAt(2); |
1606 | 1624 |
1607 // Even though we closed the panel, the long-press selection is still th
ere. | 1625 // Even though we closed the panel, the long-press selection is still th
ere. |
1608 // Tap on the question mark to dismiss the long-press selection. | 1626 // Tap on the question mark to dismiss the long-press selection. |
1609 clickNode("question-mark"); | 1627 clickNode("question-mark"); |
1610 waitForSelectionToBe(null); | 1628 waitForSelectionToBe(null); |
1611 | 1629 |
1612 // Now taps should work and not change the counter. | 1630 // Now taps should work and not change the counter. |
1613 clickToTriggerPrefetch(); | 1631 clickToTriggerPrefetch(); |
1614 assertTapPromoCounterDisabledAt(2); | 1632 assertTapPromoCounterDisabledAt(2); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1708 @SmallTest | 1726 @SmallTest |
1709 @Feature({"ContextualSearch"}) | 1727 @Feature({"ContextualSearch"}) |
1710 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1728 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
1711 public void testNotifyObserverHideAfterLongPress() | 1729 public void testNotifyObserverHideAfterLongPress() |
1712 throws InterruptedException, TimeoutException { | 1730 throws InterruptedException, TimeoutException { |
1713 TestContextualSearchObserver observer = new TestContextualSearchObserver
(); | 1731 TestContextualSearchObserver observer = new TestContextualSearchObserver
(); |
1714 mManager.addObserver(observer); | 1732 mManager.addObserver(observer); |
1715 longPressNode("states"); | 1733 longPressNode("states"); |
1716 assertEquals(0, observer.hideCount); | 1734 assertEquals(0, observer.hideCount); |
1717 | 1735 |
1718 tapBasePage(); | 1736 tapBasePageToClosePanel(); |
1719 waitForPanelToCloseAndAssert(); | |
1720 assertEquals(1, observer.hideCount); | 1737 assertEquals(1, observer.hideCount); |
1721 } | 1738 } |
1722 | 1739 |
1723 /** | 1740 /** |
1724 * Tests that ContextualSearchObserver gets notified when user brings up con
textual search | 1741 * Tests that ContextualSearchObserver gets notified when user brings up con
textual search |
1725 * panel via tap and then dismisses the panel by tapping on the base page. | 1742 * panel via tap and then dismisses the panel by tapping on the base page. |
1726 */ | 1743 */ |
1727 @SmallTest | 1744 @SmallTest |
1728 @Feature({"ContextualSearch"}) | 1745 @Feature({"ContextualSearch"}) |
1729 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1746 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
1730 public void testNotifyObserverHideAfterTap() throws InterruptedException, Ti
meoutException { | 1747 public void testNotifyObserverHideAfterTap() throws InterruptedException, Ti
meoutException { |
1731 TestContextualSearchObserver observer = new TestContextualSearchObserver
(); | 1748 TestContextualSearchObserver observer = new TestContextualSearchObserver
(); |
1732 mManager.addObserver(observer); | 1749 mManager.addObserver(observer); |
1733 clickWordNode("states"); | 1750 clickWordNode("states"); |
1734 assertEquals(0, observer.hideCount); | 1751 assertEquals(0, observer.hideCount); |
1735 | 1752 |
1736 tapBasePage(); | 1753 tapBasePageToClosePanel(); |
1737 waitForPanelToCloseAndAssert(); | |
1738 assertEquals(1, observer.hideCount); | 1754 assertEquals(1, observer.hideCount); |
1739 } | 1755 } |
1740 | 1756 |
1741 private void assertWaitForSelectActionBarVisible(final boolean visible) | 1757 private void assertWaitForSelectActionBarVisible(final boolean visible) |
1742 throws InterruptedException { | 1758 throws InterruptedException { |
1743 assertTrue(CriteriaHelper.pollForUIThreadCriteria(new Criteria() { | 1759 assertTrue(CriteriaHelper.pollForUIThreadCriteria(new Criteria() { |
1744 @Override | 1760 @Override |
1745 public boolean isSatisfied() { | 1761 public boolean isSatisfied() { |
1746 return visible == getActivity().getActivityTab().getContentViewC
ore() | 1762 return visible == getActivity().getActivityTab().getContentViewC
ore() |
1747 .isSelectActionBarShowing(); | 1763 .isSelectActionBarShowing(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 mManager.onSelectionEvent(SelectionEventType.SELECTION_HANDLE_DRAG_STOPP
ED, 303, 450); | 1817 mManager.onSelectionEvent(SelectionEventType.SELECTION_HANDLE_DRAG_STOPP
ED, 303, 450); |
1802 assertPanelClosedOrUndefined(); | 1818 assertPanelClosedOrUndefined(); |
1803 | 1819 |
1804 // Select a different word and assert that the panel has appeared. | 1820 // Select a different word and assert that the panel has appeared. |
1805 longPressNode("states-far"); | 1821 longPressNode("states-far"); |
1806 waitForPanelToPeekAndAssert(); | 1822 waitForPanelToPeekAndAssert(); |
1807 } | 1823 } |
1808 | 1824 |
1809 /** | 1825 /** |
1810 * Tests a bunch of taps in a row. | 1826 * Tests a bunch of taps in a row. |
1811 * We've had reliability problems with simple taps due to async clearing | 1827 * We've had reliability problems with a sequence of simple taps, due to asy
nc dissolving |
1812 * of selection bounds, so this helps prevent a regression with that. | 1828 * of selection bounds, so this helps prevent a regression with that. |
1813 */ | 1829 */ |
1814 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1830 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
1815 @CommandLineFlags.Add({ContextualSearchFieldTrial.TAP_RESOLVE_LIMIT_FOR_DECI
DED + "=200", | 1831 @CommandLineFlags.Add({ContextualSearchFieldTrial.TAP_RESOLVE_LIMIT_FOR_DECI
DED + "=200", |
1816 ContextualSearchFieldTrial.TAP_RESOLVE_LIMIT_FOR_UNDECIDED + "=200", | 1832 ContextualSearchFieldTrial.TAP_RESOLVE_LIMIT_FOR_UNDECIDED + "=200", |
1817 ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_DECIDED + "=200", | 1833 ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_DECIDED + "=200", |
1818 ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_UNDECIDED + "=200"
}) | 1834 ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_UNDECIDED + "=200"
}) |
1819 public void testTapALot() throws InterruptedException, TimeoutException { | 1835 public void testTapALot() throws InterruptedException, TimeoutException { |
1820 for (int i = 0; i < 50; i++) { | 1836 for (int i = 0; i < 50; i++) { |
1821 clickToTriggerSearchTermResolution(); | 1837 clickToTriggerSearchTermResolution(); |
1822 waitForSelectionDissolved(); | 1838 waitForSelectionDissolved(); |
1823 assertSearchTermRequested(); | 1839 assertSearchTermRequested(); |
1824 } | 1840 } |
1825 } | 1841 } |
1826 } | 1842 } |
OLD | NEW |