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/stringprintf.h" | 5 #include "base/stringprintf.h" |
6 #include "chrome/browser/content_settings/host_content_settings_map.h" | 6 #include "chrome/browser/content_settings/host_content_settings_map.h" |
7 #include "chrome/browser/history/history_service_factory.h" | 7 #include "chrome/browser/history/history_service_factory.h" |
8 #include "chrome/browser/instant/instant_controller.h" | 8 #include "chrome/browser/instant/instant_controller.h" |
9 #include "chrome/browser/instant/instant_loader.h" | 9 #include "chrome/browser/instant/instant_loader.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 | 687 |
688 TabContents* active_tab = chrome::GetActiveTabContents(browser()); | 688 TabContents* active_tab = chrome::GetActiveTabContents(browser()); |
689 TabContents* preview_tab = instant()->GetPreviewContents(); | 689 TabContents* preview_tab = instant()->GetPreviewContents(); |
690 | 690 |
691 // Inititally, the active tab is showing; the preview is not. | 691 // Inititally, the active tab is showing; the preview is not. |
692 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); | 692 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); |
693 EXPECT_TRUE(CheckVisibilityIs(preview_tab, false)); | 693 EXPECT_TRUE(CheckVisibilityIs(preview_tab, false)); |
694 | 694 |
695 // Type a query and wait for Instant to show. | 695 // Type a query and wait for Instant to show. |
696 SetOmniboxTextAndWaitForInstantToShow("query"); | 696 SetOmniboxTextAndWaitForInstantToShow("query"); |
697 EXPECT_TRUE(CheckVisibilityIs(active_tab, false)); | 697 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); |
698 EXPECT_TRUE(CheckVisibilityIs(preview_tab, true)); | 698 EXPECT_TRUE(CheckVisibilityIs(preview_tab, true)); |
699 | 699 |
700 // Deleting the omnibox text should hide the preview. | 700 // Deleting the omnibox text should hide the preview. |
701 SetOmniboxText(""); | 701 SetOmniboxText(""); |
702 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); | 702 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); |
703 EXPECT_TRUE(CheckVisibilityIs(preview_tab, false)); | 703 EXPECT_TRUE(CheckVisibilityIs(preview_tab, false)); |
704 | 704 |
705 // Typing a query should show the preview again. | 705 // Typing a query should show the preview again. |
706 SetOmniboxTextAndWaitForInstantToShow("query"); | 706 SetOmniboxTextAndWaitForInstantToShow("query"); |
707 EXPECT_TRUE(CheckVisibilityIs(active_tab, false)); | 707 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); |
708 EXPECT_TRUE(CheckVisibilityIs(preview_tab, true)); | 708 EXPECT_TRUE(CheckVisibilityIs(preview_tab, true)); |
709 | 709 |
710 // Commit the preview. | 710 // Commit the preview. |
711 browser()->window()->GetLocationBar()->AcceptInput(); | 711 browser()->window()->GetLocationBar()->AcceptInput(); |
712 EXPECT_EQ(preview_tab, chrome::GetActiveTabContents(browser())); | 712 EXPECT_EQ(preview_tab, chrome::GetActiveTabContents(browser())); |
713 EXPECT_TRUE(CheckVisibilityIs(preview_tab, true)); | 713 EXPECT_TRUE(CheckVisibilityIs(preview_tab, true)); |
714 } | 714 } |
715 | 715 |
716 // Test that the task manager identifies Instant's preview tab correctly. | 716 // Test that the task manager identifies Instant's preview tab correctly. |
717 IN_PROC_BROWSER_TEST_F(InstantTest, TaskManagerPrefix) { | 717 IN_PROC_BROWSER_TEST_F(InstantTest, TaskManagerPrefix) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 base::RunLoop run_loop3; | 810 base::RunLoop run_loop3; |
811 std::vector<string16> queries; | 811 std::vector<string16> queries; |
812 history->GetMostRecentKeywordSearchTerms(template_url->id(), | 812 history->GetMostRecentKeywordSearchTerms(template_url->id(), |
813 ASCIIToUTF16("s"), 1, &consumer, | 813 ASCIIToUTF16("s"), 1, &consumer, |
814 base::Bind(&KeywordQueryDone, &run_loop3, &queries)); | 814 base::Bind(&KeywordQueryDone, &run_loop3, &queries)); |
815 run_loop3.Run(); | 815 run_loop3.Run(); |
816 ASSERT_TRUE(queries.size()); | 816 ASSERT_TRUE(queries.size()); |
817 EXPECT_EQ(ASCIIToUTF16("search"), queries[0]); | 817 EXPECT_EQ(ASCIIToUTF16("search"), queries[0]); |
818 } | 818 } |
819 | 819 |
820 #if defined(OS_WIN) | |
821 // On Windows, NewEmptyWindow() fails the "GetBackingStore called while hidden" | |
822 // CHECK(). TODO(sreeram): Fix it. | |
823 #define MAYBE_NewWindowDismissesInstant DISABLED_NewWindowDismissesInstant | |
824 #else | |
825 #define MAYBE_NewWindowDismissesInstant NewWindowDismissesInstant | |
826 #endif | |
827 // Test that creating a new window hides any currently showing Instant preview. | 820 // Test that creating a new window hides any currently showing Instant preview. |
828 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_NewWindowDismissesInstant) { | 821 IN_PROC_BROWSER_TEST_F(InstantTest, NewWindowDismissesInstant) { |
829 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); | 822 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); |
830 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 823 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
831 SetOmniboxTextAndWaitForInstantToShow("search"); | 824 SetOmniboxTextAndWaitForInstantToShow("search"); |
832 | 825 |
833 Browser* previous_window = browser(); | 826 Browser* previous_window = browser(); |
834 EXPECT_TRUE(instant()->IsCurrent()); | 827 EXPECT_TRUE(instant()->IsCurrent()); |
835 EXPECT_TRUE(instant()->is_showing()); | 828 EXPECT_TRUE(instant()->is_showing()); |
836 | 829 |
837 content::WindowedNotificationObserver instant_hidden_observer( | 830 content::WindowedNotificationObserver instant_hidden_observer( |
838 chrome::NOTIFICATION_INSTANT_CONTROLLER_HIDDEN, | 831 chrome::NOTIFICATION_INSTANT_CONTROLLER_HIDDEN, |
(...skipping 27 matching lines...) Expand all Loading... |
866 // Instant is showing, so OnStaleLoader() shouldn't kill the preview. | 859 // Instant is showing, so OnStaleLoader() shouldn't kill the preview. |
867 instant()->stale_loader_timer_.Stop(); | 860 instant()->stale_loader_timer_.Stop(); |
868 instant()->OnStaleLoader(); | 861 instant()->OnStaleLoader(); |
869 EXPECT_TRUE(instant()->is_showing()); | 862 EXPECT_TRUE(instant()->is_showing()); |
870 | 863 |
871 // The preview should be recreated once the omnibox loses focus. | 864 // The preview should be recreated once the omnibox loses focus. |
872 EXPECT_TRUE(instant()->loader()->supports_instant()); | 865 EXPECT_TRUE(instant()->loader()->supports_instant()); |
873 instant()->OnAutocompleteLostFocus(NULL); | 866 instant()->OnAutocompleteLostFocus(NULL); |
874 EXPECT_FALSE(instant()->loader()->supports_instant()); | 867 EXPECT_FALSE(instant()->loader()->supports_instant()); |
875 } | 868 } |
OLD | NEW |