Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "chrome/browser/content_settings/host_content_settings_map.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 8 #include "chrome/browser/history/history.h" | 8 #include "chrome/browser/history/history.h" |
| 9 #include "chrome/browser/history/history_service_factory.h" | 9 #include "chrome/browser/history/history_service_factory.h" |
| 10 #include "chrome/browser/instant/instant_controller.h" | 10 #include "chrome/browser/instant/instant_controller.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 // Before the commit, the active tab is the NTP (i.e., not Instant). | 230 // Before the commit, the active tab is the NTP (i.e., not Instant). |
| 231 TabContents* active_tab = chrome::GetActiveTabContents(browser()); | 231 TabContents* active_tab = chrome::GetActiveTabContents(browser()); |
| 232 EXPECT_NE(preview_tab, active_tab); | 232 EXPECT_NE(preview_tab, active_tab); |
| 233 EXPECT_EQ(1, active_tab->web_contents()->GetController().GetEntryCount()); | 233 EXPECT_EQ(1, active_tab->web_contents()->GetController().GetEntryCount()); |
| 234 EXPECT_EQ(std::string(chrome::kAboutBlankURL), | 234 EXPECT_EQ(std::string(chrome::kAboutBlankURL), |
| 235 omnibox()->model()->PermanentURL().spec()); | 235 omnibox()->model()->PermanentURL().spec()); |
| 236 | 236 |
| 237 // Commit the search by pressing Enter. | 237 // Commit the search by pressing Enter. |
| 238 browser()->window()->GetLocationBar()->AcceptInput(); | 238 browser()->window()->GetLocationBar()->AcceptInput(); |
| 239 | 239 |
| 240 // After the commit, Instant should not be showing, or even have a preview. | 240 // After the commit, Instant should not be showing. |
| 241 EXPECT_FALSE(instant()->GetPreviewContents()); | |
| 242 EXPECT_FALSE(instant()->IsCurrent()); | 241 EXPECT_FALSE(instant()->IsCurrent()); |
| 243 EXPECT_FALSE(instant()->is_showing()); | 242 EXPECT_FALSE(instant()->is_showing()); |
| 244 | 243 |
| 244 // The old loader is deleted and a new one is created. | |
| 245 EXPECT_TRUE(instant()->GetPreviewContents()); | |
| 246 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); | |
| 247 | |
| 245 // Check that the current active tab is indeed what was once the preview. | 248 // Check that the current active tab is indeed what was once the preview. |
| 246 EXPECT_EQ(preview_tab, chrome::GetActiveTabContents(browser())); | 249 EXPECT_EQ(preview_tab, chrome::GetActiveTabContents(browser())); |
| 247 | 250 |
| 248 // We should have two navigation entries, one for the NTP, and one for the | 251 // We should have two navigation entries, one for the NTP, and one for the |
| 249 // Instant search that was committed. | 252 // Instant search that was committed. |
| 250 EXPECT_EQ(2, preview_tab->web_contents()->GetController().GetEntryCount()); | 253 EXPECT_EQ(2, preview_tab->web_contents()->GetController().GetEntryCount()); |
| 251 | 254 |
| 252 // Check that the omnibox contains the Instant URL we loaded. | 255 // Check that the omnibox contains the Instant URL we loaded. |
| 253 std::string instant_url = TemplateURLServiceFactory::GetForProfile( | 256 std::string instant_url = TemplateURLServiceFactory::GetForProfile( |
| 254 browser()->profile())->GetDefaultSearchProvider()->instant_url_ref(). | 257 browser()->profile())->GetDefaultSearchProvider()->instant_url_ref(). |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 TabContents* active_tab = chrome::GetActiveTabContents(browser()); | 291 TabContents* active_tab = chrome::GetActiveTabContents(browser()); |
| 289 EXPECT_NE(preview_tab, active_tab); | 292 EXPECT_NE(preview_tab, active_tab); |
| 290 EXPECT_EQ(1, active_tab->web_contents()->GetController().GetEntryCount()); | 293 EXPECT_EQ(1, active_tab->web_contents()->GetController().GetEntryCount()); |
| 291 EXPECT_EQ(std::string(chrome::kAboutBlankURL), | 294 EXPECT_EQ(std::string(chrome::kAboutBlankURL), |
| 292 omnibox()->model()->PermanentURL().spec()); | 295 omnibox()->model()->PermanentURL().spec()); |
| 293 | 296 |
| 294 // Commit the search by clicking on the preview. | 297 // Commit the search by clicking on the preview. |
| 295 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 298 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 296 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 299 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 297 | 300 |
| 298 // After the commit, Instant should not be showing, or even have a preview. | 301 // After the commit, Instant should not be showing. |
| 299 EXPECT_FALSE(instant()->GetPreviewContents()); | |
| 300 EXPECT_FALSE(instant()->IsCurrent()); | 302 EXPECT_FALSE(instant()->IsCurrent()); |
| 301 EXPECT_FALSE(instant()->is_showing()); | 303 EXPECT_FALSE(instant()->is_showing()); |
| 302 | 304 |
| 305 // The old loader is deleted and a new one is created. | |
| 306 EXPECT_TRUE(instant()->GetPreviewContents()); | |
| 307 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); | |
| 308 | |
| 303 // Check that the current active tab is indeed what was once the preview. | 309 // Check that the current active tab is indeed what was once the preview. |
| 304 EXPECT_EQ(preview_tab, chrome::GetActiveTabContents(browser())); | 310 EXPECT_EQ(preview_tab, chrome::GetActiveTabContents(browser())); |
| 305 | 311 |
| 306 // We should have two navigation entries, one for the NTP, and one for the | 312 // We should have two navigation entries, one for the NTP, and one for the |
| 307 // Instant search that was committed. | 313 // Instant search that was committed. |
| 308 EXPECT_EQ(2, preview_tab->web_contents()->GetController().GetEntryCount()); | 314 EXPECT_EQ(2, preview_tab->web_contents()->GetController().GetEntryCount()); |
| 309 | 315 |
| 310 // Check that the omnibox contains the Instant URL we loaded. | 316 // Check that the omnibox contains the Instant URL we loaded. |
| 311 std::string instant_url = TemplateURLServiceFactory::GetForProfile( | 317 std::string instant_url = TemplateURLServiceFactory::GetForProfile( |
| 312 browser()->profile())->GetDefaultSearchProvider()->instant_url_ref(). | 318 browser()->profile())->GetDefaultSearchProvider()->instant_url_ref(). |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 343 // Type a query into the omnibox. This should cause an onresize() event, with | 349 // Type a query into the omnibox. This should cause an onresize() event, with |
| 344 // a valid (non-zero) height. | 350 // a valid (non-zero) height. |
| 345 SetOmniboxText("search"); | 351 SetOmniboxText("search"); |
| 346 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); | 352 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); |
| 347 | 353 |
| 348 EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents())); | 354 EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents())); |
| 349 EXPECT_EQ(2, onresizecalls_); | 355 EXPECT_EQ(2, onresizecalls_); |
| 350 EXPECT_LT(0, height_); | 356 EXPECT_LT(0, height_); |
| 351 } | 357 } |
| 352 | 358 |
| 359 // 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.
| |
| 360 // refreshed if it is showing. | |
| 361 IN_PROC_BROWSER_TEST_F(InstantTest, InstantLoaderRefresh) { | |
| 362 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); | |
| 363 instant()->OnAutocompleteGotFocus(); | |
| 364 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); | |
| 365 | |
| 366 // 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.
| |
| 367 // contents. | |
| 368 instant()->RefreshLoader(); | |
| 369 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.
| |
| 370 | |
| 371 // Show instant. | |
|
sreeram
2012/08/22 17:39:35
instant -> Instant
Shishir
2012/08/23 18:26:33
Done.
| |
| 372 SetOmniboxText("query"); | |
| 373 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); | |
| 374 TabContents* preview_tab = instant()->GetPreviewContents(); | |
| 375 | |
| 376 // Refresh the loader, the preview contents should remain the same. | |
| 377 instant()->RefreshLoader(); | |
| 378 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | |
| 379 } | |
| 380 | |
| 353 // Test that the INSTANT_COMPLETE_NOW behavior works as expected. | 381 // Test that the INSTANT_COMPLETE_NOW behavior works as expected. |
| 354 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNow) { | 382 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNow) { |
| 355 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); | 383 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); |
| 356 instant()->OnAutocompleteGotFocus(); | 384 instant()->OnAutocompleteGotFocus(); |
| 357 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); | 385 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); |
| 358 | 386 |
| 359 // Tell the JS to request for the given behavior. | 387 // Tell the JS to request for the given behavior. |
| 360 EXPECT_TRUE(ExecuteScript("behavior = 'now'")); | 388 EXPECT_TRUE(ExecuteScript("behavior = 'now'")); |
| 361 | 389 |
| 362 SetOmniboxText("query"); | 390 SetOmniboxText("query"); |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 819 content::WindowedNotificationObserver observer( | 847 content::WindowedNotificationObserver observer( |
| 820 chrome::NOTIFICATION_INSTANT_CONTROLLER_HIDDEN, | 848 chrome::NOTIFICATION_INSTANT_CONTROLLER_HIDDEN, |
| 821 content::NotificationService::AllSources()); | 849 content::NotificationService::AllSources()); |
| 822 chrome::NewEmptyWindow(browser()->profile()); | 850 chrome::NewEmptyWindow(browser()->profile()); |
| 823 observer.Wait(); | 851 observer.Wait(); |
| 824 EXPECT_TRUE(instant()->GetPreviewContents()); | 852 EXPECT_TRUE(instant()->GetPreviewContents()); |
| 825 EXPECT_FALSE(instant()->IsCurrent()); | 853 EXPECT_FALSE(instant()->IsCurrent()); |
| 826 EXPECT_FALSE(instant()->is_showing()); | 854 EXPECT_FALSE(instant()->is_showing()); |
| 827 } | 855 } |
| 828 #endif | 856 #endif |
| OLD | NEW |