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

Unified Diff: chrome/browser/instant/instant_browsertest.cc

Issue 10829436: Recreate the loader as soon as it is deleted and ensure that it does not become stale. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Spelling fix. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/instant/instant_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/instant/instant_browsertest.cc
diff --git a/chrome/browser/instant/instant_browsertest.cc b/chrome/browser/instant/instant_browsertest.cc
index 1c210afd3a9e469918418c15c1176d6cdcfb6b5b..9d931fbe69d06080a7984b1d9fe6ebf9e25a436f 100644
--- a/chrome/browser/instant/instant_browsertest.cc
+++ b/chrome/browser/instant/instant_browsertest.cc
@@ -237,11 +237,14 @@ IN_PROC_BROWSER_TEST_F(InstantTest, OnSubmitEvent) {
// Commit the search by pressing Enter.
browser()->window()->GetLocationBar()->AcceptInput();
- // After the commit, Instant should not be showing, or even have a preview.
- EXPECT_FALSE(instant()->GetPreviewContents());
+ // After the commit, Instant should not be showing.
EXPECT_FALSE(instant()->IsCurrent());
EXPECT_FALSE(instant()->is_showing());
+ // The old loader is deleted and a new one is created.
+ EXPECT_TRUE(instant()->GetPreviewContents());
+ EXPECT_NE(instant()->GetPreviewContents(), preview_tab);
+
// Check that the current active tab is indeed what was once the preview.
EXPECT_EQ(preview_tab, chrome::GetActiveTabContents(browser()));
@@ -295,11 +298,14 @@ IN_PROC_BROWSER_TEST_F(InstantTest, OnCancelEvent) {
EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
- // After the commit, Instant should not be showing, or even have a preview.
- EXPECT_FALSE(instant()->GetPreviewContents());
+ // After the commit, Instant should not be showing.
EXPECT_FALSE(instant()->IsCurrent());
EXPECT_FALSE(instant()->is_showing());
+ // The old loader is deleted and a new one is created.
+ EXPECT_TRUE(instant()->GetPreviewContents());
+ EXPECT_NE(instant()->GetPreviewContents(), preview_tab);
+
// Check that the current active tab is indeed what was once the preview.
EXPECT_EQ(preview_tab, chrome::GetActiveTabContents(browser()));
@@ -825,3 +831,34 @@ IN_PROC_BROWSER_TEST_F(InstantTest, NewWindowDismissesInstant) {
EXPECT_FALSE(instant()->is_showing());
}
#endif
+
+// Tests that:
+// - Instant loader is recreated on OnStaleLoader call when it is hidden.
+// - Instant loader is not recreated on OnStaleLoader call when it is visible.
+// - Instant loader will be recreated when omnibox loses focus after the timer
+// has stopped.
+IN_PROC_BROWSER_TEST_F(InstantTest, InstantLoaderRefresh) {
+ ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html"));
+ instant()->OnAutocompleteGotFocus();
+ WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED);
+
+ // Instant is not showing, so a refresh should create a new preview contents.
+ EXPECT_TRUE(instant()->loader()->supports_instant());
+ instant()->OnStaleLoader();
+ EXPECT_FALSE(instant()->loader()->supports_instant());
+ WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED);
+
+ // Show Instant.
+ SetOmniboxText("query");
+ WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN);
+
+ // Refresh the loader, the preview contents should remain the same.
+ instant()->OnStaleLoader();
+ EXPECT_TRUE(instant()->is_showing());
+
+ instant()->stale_loader_timer_.Stop();
+ // The refresh should happen once the omnibox loses focus.
+ EXPECT_TRUE(instant()->loader()->supports_instant());
+ instant()->OnAutocompleteLostFocus(NULL);
+ EXPECT_FALSE(instant()->loader()->supports_instant());
+}
« no previous file with comments | « no previous file | chrome/browser/instant/instant_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698