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

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: Adding tests. 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
Index: chrome/browser/instant/instant_browsertest.cc
diff --git a/chrome/browser/instant/instant_browsertest.cc b/chrome/browser/instant/instant_browsertest.cc
index f3f8271ae5163ed89666a0d0c633356cc1f2c7d1..e25e91bc8b2dc454a459503cb1cc91b075d5ce4b 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()));
@@ -350,6 +356,28 @@ IN_PROC_BROWSER_TEST_F(InstantTest, OnResizeEvent) {
EXPECT_LT(0, height_);
}
+// Tests that the instant loader is refreshed when it gets stale but is not
sreeram 2012/08/22 17:39:35 Also, why put this test here, in the middle of the
sreeram 2012/08/22 17:39:35 Tests -> Test instant -> Instant I'd reword this
Shishir 2012/08/23 18:26:33 Done.
Shishir 2012/08/23 18:26:33 Done.
+// refreshed if it is showing.
+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 the preview
sreeram 2012/08/22 17:39:35 a new the preview -> a new preview
Shishir 2012/08/23 18:26:33 Done.
+ // contents.
+ instant()->RefreshLoader();
+ WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED);
sreeram 2012/08/22 17:39:35 Put in a comment about why we are not checking EXP
Shishir 2012/08/23 18:26:33 Done.
+
+ // Show instant.
sreeram 2012/08/22 17:39:35 instant -> Instant
Shishir 2012/08/23 18:26:33 Done.
+ SetOmniboxText("query");
+ WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN);
+ TabContents* preview_tab = instant()->GetPreviewContents();
+
+ // Refresh the loader, the preview contents should remain the same.
+ instant()->RefreshLoader();
+ EXPECT_EQ(preview_tab, instant()->GetPreviewContents());
+}
+
// Test that the INSTANT_COMPLETE_NOW behavior works as expected.
IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNow) {
ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html"));
« no previous file with comments | « no previous file | chrome/browser/instant/instant_controller.h » ('j') | chrome/browser/instant/instant_controller.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698