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

Side by Side Diff: chrome/browser/ui/search/instant_extended_interactive_uitest.cc

Issue 17291008: Added tests to verify back/forward button logic works as expected when instant extended enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 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 | Annotate | Revision Log
« 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include <sstream> 5 #include <sstream>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram_base.h" 9 #include "base/metrics/histogram_base.h"
10 #include "base/metrics/histogram_samples.h" 10 #include "base/metrics/histogram_samples.h"
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 browser()->tab_strip_model()->ActivateTabAt(0, false); 1381 browser()->tab_strip_model()->ActivateTabAt(0, false);
1382 1382
1383 // Switch back to new tab. 1383 // Switch back to new tab.
1384 browser()->tab_strip_model()->ActivateTabAt(1, false); 1384 browser()->tab_strip_model()->ActivateTabAt(1, false);
1385 1385
1386 // Confirm that new tab got no onmostvisitedchanged event. 1386 // Confirm that new tab got no onmostvisitedchanged event.
1387 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 1387 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
1388 EXPECT_TRUE(UpdateSearchState(active_tab)); 1388 EXPECT_TRUE(UpdateSearchState(active_tab));
1389 EXPECT_EQ(2, on_most_visited_change_calls_); 1389 EXPECT_EQ(2, on_most_visited_change_calls_);
1390 } 1390 }
1391
1392 // Flaky on Mac Tests bot.
1393 #if defined(OS_MACOSX)
1394 #define MAYBE_UpdateSearchQueryOnBackNavigation DISABLED_UpdateSearchQueryOnBack Navigation
1395 #else
1396 #define MAYBE_UpdateSearchQueryOnBackNavigation UpdateSearchQueryOnBackNavigatio n
1397 #endif
1398 // Test to verify that the omnibox search query is updated on browser
1399 // back button press event.
1400 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
1401 MAYBE_UpdateSearchQueryOnBackNavigation) {
1402 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1403
1404 // Focus omnibox and confirm overlay isn't shown.
1405 FocusOmniboxAndWaitForInstantNTPSupport();
1406
1407 // Create an observer to wait for the instant tab to support Instant.
1408 content::WindowedNotificationObserver observer(
1409 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
1410 content::NotificationService::AllSources());
1411
1412 SetOmniboxText("flowers");
1413 // Commit the search by pressing 'Enter'.
1414 PressEnterAndWaitForNavigation();
1415 observer.Wait();
1416
1417 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText());
1418
1419 // Typing in the new search query in omnibox.
1420 SetOmniboxText("cattles");
1421 // Commit the search by pressing 'Enter'.
1422 PressEnterAndWaitForNavigation();
1423 // 'Enter' commits the query as it was typed. This creates a navigation entry
1424 // in the history.
1425 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText());
1426
1427 content::WebContents* active_tab =
1428 browser()->tab_strip_model()->GetActiveWebContents();
1429 EXPECT_TRUE(active_tab->GetController().CanGoBack());
1430 content::WindowedNotificationObserver load_stop_observer(
1431 content::NOTIFICATION_LOAD_STOP,
1432 content::Source<content::NavigationController>(
1433 &active_tab->GetController()));
1434 active_tab->GetController().GoBack();
1435 load_stop_observer.Wait();
1436
1437 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText());
1438 // Commit the search by pressing 'Enter'.
1439 FocusOmnibox();
1440 PressEnterAndWaitForNavigation();
1441 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText());
1442 }
1443
1444 // Flaky on Mac Tests bot.
1445 #if defined(OS_MACOSX)
1446 #define MAYBE_UpdateSearchQueryOnForwardNavigation DISABLED_UpdateSearchQueryOnF orwardNavigation
1447 #else
1448 #define MAYBE_UpdateSearchQueryOnForwardNavigation UpdateSearchQueryOnForwardNav igation
1449 #endif
1450 // Test to verify that the omnibox search query is updated on browser
1451 // forward button press events.
1452 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
1453 MAYBE_UpdateSearchQueryOnForwardNavigation) {
1454 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1455
1456 // Focus omnibox and confirm overlay isn't shown.
1457 FocusOmniboxAndWaitForInstantNTPSupport();
1458
1459 // Create an observer to wait for the instant tab to support Instant.
1460 content::WindowedNotificationObserver observer(
1461 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
1462 content::NotificationService::AllSources());
1463
1464 SetOmniboxText("flowers");
1465 // Commit the search by pressing 'Enter'.
1466 PressEnterAndWaitForNavigation();
1467 observer.Wait();
1468
1469 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText());
1470
1471 // Typing in the new search query in omnibox.
1472 SetOmniboxText("cattles");
1473 // Commit the search by pressing 'Enter'.
1474 PressEnterAndWaitForNavigation();
1475 // 'Enter' commits the query as it was typed. This creates a navigation entry
1476 // in the history.
1477 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText());
1478
1479 content::WebContents* active_tab =
1480 browser()->tab_strip_model()->GetActiveWebContents();
1481 EXPECT_TRUE(active_tab->GetController().CanGoBack());
1482 content::WindowedNotificationObserver load_stop_observer(
1483 content::NOTIFICATION_LOAD_STOP,
1484 content::Source<content::NavigationController>(
1485 &active_tab->GetController()));
1486 active_tab->GetController().GoBack();
1487 load_stop_observer.Wait();
1488
1489 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText());
1490
1491 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
1492 EXPECT_TRUE(active_tab->GetController().CanGoForward());
1493 content::WindowedNotificationObserver load_stop_observer_2(
1494 content::NOTIFICATION_LOAD_STOP,
1495 content::Source<content::NavigationController>(
1496 &active_tab->GetController()));
1497 active_tab->GetController().GoForward();
1498 load_stop_observer_2.Wait();
1499
1500 // Commit the search by pressing 'Enter'.
1501 FocusOmnibox();
1502 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText());
1503 PressEnterAndWaitForNavigation();
1504 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText());
1505 }
1506
1507 // Flaky on Mac Tests bot.
1508 #if defined(OS_MACOSX)
1509 #define MAYBE_NavigateBackToNTP DISABLED_NavigateBackToNTP
1510 #else
1511 #define MAYBE_NavigateBackToNTP NavigateBackToNTP
1512 #endif
1513 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MAYBE_NavigateBackToNTP) {
1514 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1515 FocusOmniboxAndWaitForInstantNTPSupport();
1516
1517 // Open a new tab page.
1518 ui_test_utils::NavigateToURLWithDisposition(
1519 browser(),
1520 GURL(chrome::kChromeUINewTabURL),
1521 NEW_FOREGROUND_TAB,
1522 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
1523 EXPECT_EQ(2, browser()->tab_strip_model()->count());
1524
1525 content::WindowedNotificationObserver observer(
1526 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
1527 content::NotificationService::AllSources());
1528 SetOmniboxText("flowers");
1529 PressEnterAndWaitForNavigation();
1530 observer.Wait();
1531
1532 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText());
1533
1534 // Typing in the new search query in omnibox.
1535 // Commit the search by pressing 'Enter'.
1536 SetOmniboxText("cattles");
1537 PressEnterAndWaitForNavigation();
1538
1539 // 'Enter' commits the query as it was typed. This creates a navigation entry
1540 // in the history.
1541 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText());
1542
1543 // Navigate back to "flowers" search result page.
1544 content::WebContents* active_tab =
1545 browser()->tab_strip_model()->GetActiveWebContents();
1546 EXPECT_TRUE(active_tab->GetController().CanGoBack());
1547 content::WindowedNotificationObserver load_stop_observer(
1548 content::NOTIFICATION_LOAD_STOP,
1549 content::Source<content::NavigationController>(
1550 &active_tab->GetController()));
1551 active_tab->GetController().GoBack();
1552 load_stop_observer.Wait();
1553
1554 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText());
1555
1556 // Navigate back to NTP.
1557 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
1558 EXPECT_TRUE(active_tab->GetController().CanGoBack());
1559 content::WindowedNotificationObserver load_stop_observer_2(
1560 content::NOTIFICATION_LOAD_STOP,
1561 content::Source<content::NavigationController>(
1562 &active_tab->GetController()));
1563 active_tab->GetController().GoBack();
1564 load_stop_observer_2.Wait();
1565
1566 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
1567 EXPECT_TRUE(chrome::IsInstantNTP(active_tab));
1568 }
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