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

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

Issue 1413003007: [Contextual Search] Fix test annotations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 throws InterruptedException { 596 throws InterruptedException {
597 boolean success = 597 boolean success =
598 CriteriaHelper.pollForCriteria(new Criteria() { 598 CriteriaHelper.pollForCriteria(new Criteria() {
599 @Override 599 @Override
600 public boolean isSatisfied() { 600 public boolean isSatisfied() {
601 return mPanel != null 601 return mPanel != null
602 && mPanel.getPanelState() == state; 602 && mPanel.getPanelState() == state;
603 } 603 }
604 }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL); 604 }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL);
605 assertTrue("Panel did not enter " + state + " state. " 605 assertTrue("Panel did not enter " + state + " state. "
606 + "Instead, the current state is " + mPanel.getPanelState(), suc cess); 606 + "Instead, the current state is " + mPanel.getPanelState() + ". ", success);
607 } 607 }
608 608
609 /** 609 /**
610 * Waits for the manager to finish processing a gesture. 610 * Waits for the manager to finish processing a gesture.
611 * Tells the manager that a gesture has started, and then waits for it to co mplete. 611 * Tells the manager that a gesture has started, and then waits for it to co mplete.
612 * @throws InterruptedException 612 * @throws InterruptedException
613 */ 613 */
614 private void waitForGestureProcessingAndAssert() throws InterruptedException { 614 private void waitForGestureProcessingAndAssert() throws InterruptedException {
615 assertTrue("Gesture processing did not complete.", 615 assertTrue("Gesture processing did not complete.",
616 CriteriaHelper.pollForCriteria(new Criteria() { 616 CriteriaHelper.pollForCriteria(new Criteria() {
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
2240 2240
2241 //========================================================================== ================== 2241 //========================================================================== ==================
2242 // Content Tests 2242 // Content Tests
2243 //========================================================================== ================== 2243 //========================================================================== ==================
2244 2244
2245 /** 2245 /**
2246 * Tests that tap followed by expand makes Content visible. 2246 * Tests that tap followed by expand makes Content visible.
2247 */ 2247 */
2248 @SmallTest 2248 @SmallTest
2249 @Feature({"ContextualSearch"}) 2249 @Feature({"ContextualSearch"})
2250 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 2250 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE})
2251 public void testTapContentVisibility() throws InterruptedException, TimeoutE xception { 2251 public void testTapContentVisibility() throws InterruptedException, TimeoutE xception {
2252 // Simulate a tap and make sure Content is not visible. 2252 // Simulate a tap and make sure Content is not visible.
2253 simulateTapSearch("search"); 2253 simulateTapSearch("search");
2254 assertContentViewCoreCreatedButNeverMadeVisible(); 2254 assertContentViewCoreCreatedButNeverMadeVisible();
2255 2255
2256 // Expanding the Panel should make the Content visible. 2256 // Expanding the Panel should make the Content visible.
2257 tapPeekingBarToExpandAndAssert(); 2257 tapPeekingBarToExpandAndAssert();
2258 assertContentViewCoreVisible(); 2258 assertContentViewCoreVisible();
2259 2259
2260 // Closing the Panel should destroy the Content. 2260 // Closing the Panel should destroy the Content.
2261 tapBasePageToClosePanel(); 2261 tapBasePageToClosePanel();
2262 assertNoContentViewCore(); 2262 assertNoContentViewCore();
2263 } 2263 }
2264 2264
2265 /** 2265 /**
2266 * Tests that long press followed by expand creates Content and makes it vis ible. 2266 * Tests that long press followed by expand creates Content and makes it vis ible.
2267 * 2267 *
2268 */ 2268 */
2269 @SmallTest 2269 @SmallTest
2270 @Feature({"ContextualSearch"}) 2270 @Feature({"ContextualSearch"})
2271 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 2271 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE})
2272 public void testLongPressContentVisibility() throws InterruptedException, Ti meoutException { 2272 public void testLongPressContentVisibility() throws InterruptedException, Ti meoutException {
2273 // Simulate a long press and make sure no Content is created. 2273 // Simulate a long press and make sure no Content is created.
2274 simulateLongPressSearch("search"); 2274 simulateLongPressSearch("search");
2275 assertNoContentViewCore(); 2275 assertNoContentViewCore();
2276 assertNoSearchesLoaded(); 2276 assertNoSearchesLoaded();
2277 2277
2278 // Expanding the Panel should make the Content visible. 2278 // Expanding the Panel should make the Content visible.
2279 tapPeekingBarToExpandAndAssert(); 2279 tapPeekingBarToExpandAndAssert();
2280 assertContentViewCoreCreated(); 2280 assertContentViewCoreCreated();
2281 assertContentViewCoreVisible(); 2281 assertContentViewCoreVisible();
2282 2282
2283 // Closing the Panel should destroy the Content. 2283 // Closing the Panel should destroy the Content.
2284 tapBasePageToClosePanel(); 2284 tapBasePageToClosePanel();
2285 assertNoContentViewCore(); 2285 assertNoContentViewCore();
2286 } 2286 }
2287 2287
2288 /** 2288 /**
2289 * Tests swiping panel up and down after a tap search will only load the Con tent once. 2289 * Tests swiping panel up and down after a tap search will only load the Con tent once.
2290 */ 2290 */
2291 @SmallTest 2291 @SmallTest
2292 @Feature({"ContextualSearch"}) 2292 @Feature({"ContextualSearch"})
2293 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 2293 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
2294 public void testTapMultipleSwipeOnlyLoadsContentOnce() 2294 public void testTapMultipleSwipeOnlyLoadsContentOnce()
2295 throws InterruptedException, TimeoutException { 2295 throws InterruptedException, TimeoutException {
2296 // Simulate a tap and make sure Content is not visible. 2296 // Simulate a tap and make sure Content is not visible.
2297 simulateTapSearch("search"); 2297 simulateTapSearch("search");
2298 assertContentViewCoreCreatedButNeverMadeVisible(); 2298 assertContentViewCoreCreatedButNeverMadeVisible();
2299 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2299 assertEquals(1, mFakeServer.getLoadedUrlCount());
2300 2300
2301 // Swiping the Panel should make the Content visible. 2301 // Expanding the Panel should make the Content visible.
2302 tapPeekingBarToExpandAndAssert(); 2302 tapPeekingBarToExpandAndAssert();
2303 assertContentViewCoreVisible(); 2303 assertContentViewCoreVisible();
2304 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2304 assertEquals(1, mFakeServer.getLoadedUrlCount());
2305 2305
2306 // Swiping the Panel down should not change the visibility or load conte nt again. 2306 // Swiping the Panel down should not change the visibility or load conte nt again.
2307 swipePanelDown(); 2307 swipePanelDown();
2308 waitForPanelToPeekAndAssert(); 2308 waitForPanelToPeekAndAssert();
2309 assertContentViewCoreVisible(); 2309 assertContentViewCoreVisible();
2310 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2310 assertEquals(1, mFakeServer.getLoadedUrlCount());
2311 2311
2312 // Swiping the Panel up should not change the visibility or load content again. 2312 // Expanding the Panel should not change the visibility or load content again.
2313 tapPeekingBarToExpandAndAssert(); 2313 tapPeekingBarToExpandAndAssert();
2314 assertContentViewCoreVisible(); 2314 assertContentViewCoreVisible();
2315 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2315 assertEquals(1, mFakeServer.getLoadedUrlCount());
2316 2316
2317 // Closing the Panel should destroy the Content. 2317 // Closing the Panel should destroy the Content.
2318 tapBasePageToClosePanel(); 2318 tapBasePageToClosePanel();
2319 assertNoContentViewCore(); 2319 assertNoContentViewCore();
2320 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2320 assertEquals(1, mFakeServer.getLoadedUrlCount());
2321 } 2321 }
2322 2322
2323 /** 2323 /**
2324 * Tests swiping panel up and down after a long press search will only load the Content once. 2324 * Tests swiping panel up and down after a long press search will only load the Content once.
2325 */ 2325 */
2326 @SmallTest 2326 @SmallTest
2327 @Feature({"ContextualSearch"}) 2327 @Feature({"ContextualSearch"})
2328 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 2328 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
2329 public void testLongPressMultipleSwipeOnlyLoadsContentOnce() 2329 public void testLongPressMultipleSwipeOnlyLoadsContentOnce()
2330 throws InterruptedException, TimeoutException { 2330 throws InterruptedException, TimeoutException {
2331 // Simulate a long press and make sure no Content is created. 2331 // Simulate a long press and make sure no Content is created.
2332 simulateLongPressSearch("search"); 2332 simulateLongPressSearch("search");
2333 assertNoContentViewCore(); 2333 assertNoContentViewCore();
2334 assertNoSearchesLoaded(); 2334 assertNoSearchesLoaded();
2335 2335
2336 // Swiping the Panel should load the URL and make the Content visible. 2336 // Expanding the Panel should load the URL and make the Content visible.
2337 tapPeekingBarToExpandAndAssert(); 2337 tapPeekingBarToExpandAndAssert();
2338 assertContentViewCoreCreated(); 2338 assertContentViewCoreCreated();
2339 assertContentViewCoreVisible(); 2339 assertContentViewCoreVisible();
2340 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2340 assertEquals(1, mFakeServer.getLoadedUrlCount());
2341 2341
2342 // Swiping the Panel down should not change the visibility or load conte nt again. 2342 // Swiping the Panel down should not change the visibility or load conte nt again.
2343 swipePanelDown(); 2343 swipePanelDown();
2344 waitForPanelToPeekAndAssert(); 2344 waitForPanelToPeekAndAssert();
2345 assertContentViewCoreVisible(); 2345 assertContentViewCoreVisible();
2346 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2346 assertEquals(1, mFakeServer.getLoadedUrlCount());
2347 2347
2348 // Swiping the Panel up should not change the visibility or load content again. 2348 // Expanding the Panel should not change the visibility or load content again.
2349 tapPeekingBarToExpandAndAssert(); 2349 tapPeekingBarToExpandAndAssert();
2350 assertContentViewCoreVisible(); 2350 assertContentViewCoreVisible();
2351 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2351 assertEquals(1, mFakeServer.getLoadedUrlCount());
2352 2352
2353 // Closing the Panel should destroy the Content. 2353 // Closing the Panel should destroy the Content.
2354 tapBasePageToClosePanel(); 2354 tapBasePageToClosePanel();
2355 assertNoContentViewCore(); 2355 assertNoContentViewCore();
2356 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2356 assertEquals(1, mFakeServer.getLoadedUrlCount());
2357 } 2357 }
2358 2358
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2401 @Feature({"ContextualSearch"}) 2401 @Feature({"ContextualSearch"})
2402 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 2402 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
2403 public void testChainedSearchLoadsCorrectSearchTerm() 2403 public void testChainedSearchLoadsCorrectSearchTerm()
2404 throws InterruptedException, TimeoutException { 2404 throws InterruptedException, TimeoutException {
2405 // Simulate a tap and make sure Content is not visible. 2405 // Simulate a tap and make sure Content is not visible.
2406 simulateTapSearch("search"); 2406 simulateTapSearch("search");
2407 assertContentViewCoreCreatedButNeverMadeVisible(); 2407 assertContentViewCoreCreatedButNeverMadeVisible();
2408 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2408 assertEquals(1, mFakeServer.getLoadedUrlCount());
2409 ContentViewCore cvc1 = getPanelContentViewCore(); 2409 ContentViewCore cvc1 = getPanelContentViewCore();
2410 2410
2411 // Swiping the Panel should make the Content visible. 2411 // Expanding the Panel should make the Content visible.
2412 tapPeekingBarToExpandAndAssert(); 2412 tapPeekingBarToExpandAndAssert();
2413 assertContentViewCoreVisible(); 2413 assertContentViewCoreVisible();
2414 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2414 assertEquals(1, mFakeServer.getLoadedUrlCount());
2415 2415
2416 // Swiping the Panel down should not change the visibility or load conte nt again. 2416 // Swiping the Panel down should not change the visibility or load conte nt again.
2417 swipePanelDown(); 2417 swipePanelDown();
2418 waitForPanelToPeekAndAssert(); 2418 waitForPanelToPeekAndAssert();
2419 assertContentViewCoreVisible(); 2419 assertContentViewCoreVisible();
2420 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2420 assertEquals(1, mFakeServer.getLoadedUrlCount());
2421 2421
2422 waitToPreventDoubleTapRecognition(); 2422 waitToPreventDoubleTapRecognition();
2423 2423
2424 // Now simulate a long press, leaving the Panel peeking. 2424 // Now simulate a long press, leaving the Panel peeking.
2425 simulateLongPressSearch("resolution"); 2425 simulateLongPressSearch("resolution");
2426 2426
2427 // Swiping the Panel up should load and display the new search. 2427 // Expanding the Panel should load and display the new search.
2428 tapPeekingBarToExpandAndAssert(); 2428 tapPeekingBarToExpandAndAssert();
2429 assertContentViewCoreCreated(); 2429 assertContentViewCoreCreated();
2430 assertContentViewCoreVisible(); 2430 assertContentViewCoreVisible();
2431 assertEquals(2, mFakeServer.getLoadedUrlCount()); 2431 assertEquals(2, mFakeServer.getLoadedUrlCount());
2432 assertLoadedSearchTermMatches("Resolution"); 2432 assertLoadedSearchTermMatches("Resolution");
2433 ContentViewCore cvc2 = getPanelContentViewCore(); 2433 ContentViewCore cvc2 = getPanelContentViewCore();
2434 assertNotSame(cvc1, cvc2); 2434 assertNotSame(cvc1, cvc2);
2435 2435
2436 // Closing the Panel should destroy the Content. 2436 // Closing the Panel should destroy the Content.
2437 tapBasePageToClosePanel(); 2437 tapBasePageToClosePanel();
2438 assertNoContentViewCore(); 2438 assertNoContentViewCore();
2439 assertEquals(2, mFakeServer.getLoadedUrlCount()); 2439 assertEquals(2, mFakeServer.getLoadedUrlCount());
2440 } 2440 }
2441 2441
2442 /** 2442 /**
2443 * Tests that chained searches make Content visible when opening the Panel. 2443 * Tests that chained searches make Content visible when opening the Panel.
2444 */ 2444 */
2445 @SmallTest 2445 @SmallTest
2446 @Feature({"ContextualSearch"}) 2446 @Feature({"ContextualSearch"})
2447 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 2447 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE})
2448 public void testChainedSearchContentVisibility() 2448 public void testChainedSearchContentVisibility()
2449 throws InterruptedException, TimeoutException { 2449 throws InterruptedException, TimeoutException {
2450 // Simulate a tap and make sure Content is not visible. 2450 // Simulate a tap and make sure Content is not visible.
2451 simulateTapSearch("search"); 2451 simulateTapSearch("search");
2452 assertContentViewCoreCreatedButNeverMadeVisible(); 2452 assertContentViewCoreCreatedButNeverMadeVisible();
2453 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2453 assertEquals(1, mFakeServer.getLoadedUrlCount());
2454 ContentViewCore cvc1 = getPanelContentViewCore(); 2454 ContentViewCore cvc1 = getPanelContentViewCore();
2455 2455
2456 waitToPreventDoubleTapRecognition(); 2456 waitToPreventDoubleTapRecognition();
2457 2457
2458 // Now simulate a long press, leaving the Panel peeking. 2458 // Now simulate a long press, leaving the Panel peeking.
2459 simulateLongPressSearch("resolution"); 2459 simulateLongPressSearch("resolution");
2460 assertNeverCalledContentViewCoreOnShow(); 2460 assertNeverCalledContentViewCoreOnShow();
2461 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2461 assertEquals(1, mFakeServer.getLoadedUrlCount());
2462 2462
2463 // Swiping the Panel up should load and display the new search. 2463 // Expanding the Panel should load and display the new search.
2464 flingPanelUp(); 2464 tapPeekingBarToExpandAndAssert();
2465 waitForPanelToExpandAndAssert();
2466 assertContentViewCoreCreated(); 2465 assertContentViewCoreCreated();
2467 assertContentViewCoreVisible(); 2466 assertContentViewCoreVisible();
2468 assertEquals(2, mFakeServer.getLoadedUrlCount()); 2467 assertEquals(2, mFakeServer.getLoadedUrlCount());
2469 assertLoadedSearchTermMatches("Resolution"); 2468 assertLoadedSearchTermMatches("Resolution");
2470 ContentViewCore cvc2 = getPanelContentViewCore(); 2469 ContentViewCore cvc2 = getPanelContentViewCore();
2471 assertNotSame(cvc1, cvc2); 2470 assertNotSame(cvc1, cvc2);
2472 } 2471 }
2473 2472
2474 //========================================================================== ================== 2473 //========================================================================== ==================
2475 // History Removal Tests 2474 // History Removal Tests
(...skipping 17 matching lines...) Expand all
2493 2492
2494 // Now check that the URL has been removed from history. 2493 // Now check that the URL has been removed from history.
2495 assertTrue(mFakeServer.hasRemovedUrl(url)); 2494 assertTrue(mFakeServer.hasRemovedUrl(url));
2496 } 2495 }
2497 2496
2498 /** 2497 /**
2499 * Tests that a tap followed by opening the Panel does not remove the loaded URL from history. 2498 * Tests that a tap followed by opening the Panel does not remove the loaded URL from history.
2500 */ 2499 */
2501 @SmallTest 2500 @SmallTest
2502 @Feature({"ContextualSearch"}) 2501 @Feature({"ContextualSearch"})
2503 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 2502 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE})
2504 public void testTapExpandNotRemovedFromHistory() 2503 public void testTapExpandNotRemovedFromHistory()
2505 throws InterruptedException, TimeoutException { 2504 throws InterruptedException, TimeoutException {
2506 // Simulate a tap and make sure a URL was loaded. 2505 // Simulate a tap and make sure a URL was loaded.
2507 simulateTapSearch("search"); 2506 simulateTapSearch("search");
2508 assertEquals(1, mFakeServer.getLoadedUrlCount()); 2507 assertEquals(1, mFakeServer.getLoadedUrlCount());
2509 String url = mFakeServer.getLoadedUrl(); 2508 String url = mFakeServer.getLoadedUrl();
2510 2509
2511 // Expand Panel so that the Content becomes visible. 2510 // Expand Panel so that the Content becomes visible.
2512 tapPeekingBarToExpandAndAssert(); 2511 tapPeekingBarToExpandAndAssert();
2513 2512
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2548 // Close the Panel without seeing any Content. 2547 // Close the Panel without seeing any Content.
2549 tapBasePageToClosePanel(); 2548 tapBasePageToClosePanel();
2550 2549
2551 // Now check that all three URLs have been removed from history. 2550 // Now check that all three URLs have been removed from history.
2552 assertEquals(3, mFakeServer.getLoadedUrlCount()); 2551 assertEquals(3, mFakeServer.getLoadedUrlCount());
2553 assertTrue(mFakeServer.hasRemovedUrl(url1)); 2552 assertTrue(mFakeServer.hasRemovedUrl(url1));
2554 assertTrue(mFakeServer.hasRemovedUrl(url2)); 2553 assertTrue(mFakeServer.hasRemovedUrl(url2));
2555 assertTrue(mFakeServer.hasRemovedUrl(url3)); 2554 assertTrue(mFakeServer.hasRemovedUrl(url3));
2556 } 2555 }
2557 } 2556 }
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