OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 8 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
10 #include "chrome/browser/instant/instant_controller.h" | 10 #include "chrome/browser/instant/instant_controller.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 #define MAYBE_NonSearchToSearch DISABLED_NonSearchToSearch | 52 #define MAYBE_NonSearchToSearch DISABLED_NonSearchToSearch |
53 #define MAYBE_SearchToNonSearch DISABLED_SearchToNonSearch | 53 #define MAYBE_SearchToNonSearch DISABLED_SearchToNonSearch |
54 #define MAYBE_ValidHeight DISABLED_ValidHeight | 54 #define MAYBE_ValidHeight DISABLED_ValidHeight |
55 #define MAYBE_OnSubmitEvent DISABLED_OnSubmitEvent | 55 #define MAYBE_OnSubmitEvent DISABLED_OnSubmitEvent |
56 #define MAYBE_OnCancelEvent DISABLED_OnCancelEvent | 56 #define MAYBE_OnCancelEvent DISABLED_OnCancelEvent |
57 #define MAYBE_InstantCompleteNever DISABLED_InstantCompleteNever | 57 #define MAYBE_InstantCompleteNever DISABLED_InstantCompleteNever |
58 #define MAYBE_InstantCompleteDelayed DISABLED_InstantCompleteDelayed | 58 #define MAYBE_InstantCompleteDelayed DISABLED_InstantCompleteDelayed |
59 #define MAYBE_DontCrashOnBlockedJS DISABLED_DontCrashOnBlockedJS | 59 #define MAYBE_DontCrashOnBlockedJS DISABLED_DontCrashOnBlockedJS |
60 #define MAYBE_DontPersistSearchbox DISABLED_DontPersistSearchbox | 60 #define MAYBE_DontPersistSearchbox DISABLED_DontPersistSearchbox |
61 #define MAYBE_PreloadsInstant DISABLED_PreloadsInstant | 61 #define MAYBE_PreloadsInstant DISABLED_PreloadsInstant |
62 #define MAYBE_PageVisibilityTest DISABLED_PageVisibilityTest | |
62 #define MAYBE_ExperimentEnabled DISABLED_ExperimentEnabled | 63 #define MAYBE_ExperimentEnabled DISABLED_ExperimentEnabled |
63 #else | 64 #else |
64 #define MAYBE_OnChangeEvent OnChangeEvent | 65 #define MAYBE_OnChangeEvent OnChangeEvent |
65 #define MAYBE_SetSuggestionsArrayOfStrings SetSuggestionsArrayOfStrings | 66 #define MAYBE_SetSuggestionsArrayOfStrings SetSuggestionsArrayOfStrings |
66 #define MAYBE_SetSuggestionsEmptyArray SetSuggestionsEmptyArray | 67 #define MAYBE_SetSuggestionsEmptyArray SetSuggestionsEmptyArray |
67 #define MAYBE_SetSuggestionsValidJson SetSuggestionsValidJson | 68 #define MAYBE_SetSuggestionsValidJson SetSuggestionsValidJson |
68 #define MAYBE_SetSuggestionsInvalidSuggestions SetSuggestionsInvalidSuggestions | 69 #define MAYBE_SetSuggestionsInvalidSuggestions SetSuggestionsInvalidSuggestions |
69 #define MAYBE_SetSuggestionsEmptyJson SetSuggestionsEmptyJson | 70 #define MAYBE_SetSuggestionsEmptyJson SetSuggestionsEmptyJson |
70 #define MAYBE_SetSuggestionsEmptySuggestions SetSuggestionsEmptySuggestions | 71 #define MAYBE_SetSuggestionsEmptySuggestions SetSuggestionsEmptySuggestions |
71 #define MAYBE_SetSuggestionsEmptySuggestion SetSuggestionsEmptySuggestion | 72 #define MAYBE_SetSuggestionsEmptySuggestion SetSuggestionsEmptySuggestion |
72 #define MAYBE_ShowPreviewNonSearch ShowPreviewNonSearch | 73 #define MAYBE_ShowPreviewNonSearch ShowPreviewNonSearch |
73 #define MAYBE_NonSearchToSearch NonSearchToSearch | 74 #define MAYBE_NonSearchToSearch NonSearchToSearch |
74 #define MAYBE_SearchToNonSearch SearchToNonSearch | 75 #define MAYBE_SearchToNonSearch SearchToNonSearch |
75 #define MAYBE_ValidHeight ValidHeight | 76 #define MAYBE_ValidHeight ValidHeight |
76 #define MAYBE_OnSubmitEvent OnSubmitEvent | 77 #define MAYBE_OnSubmitEvent OnSubmitEvent |
77 #define MAYBE_OnCancelEvent OnCancelEvent | 78 #define MAYBE_OnCancelEvent OnCancelEvent |
78 #define MAYBE_InstantCompleteNever InstantCompleteNever | 79 #define MAYBE_InstantCompleteNever InstantCompleteNever |
79 #define MAYBE_InstantCompleteDelayed InstantCompleteDelayed | 80 #define MAYBE_InstantCompleteDelayed InstantCompleteDelayed |
80 #define MAYBE_DontCrashOnBlockedJS DontCrashOnBlockedJS | 81 #define MAYBE_DontCrashOnBlockedJS DontCrashOnBlockedJS |
81 #define MAYBE_DontPersistSearchbox DontPersistSearchbox | 82 #define MAYBE_DontPersistSearchbox DontPersistSearchbox |
82 #define MAYBE_PreloadsInstant PreloadsInstant | 83 #define MAYBE_PreloadsInstant PreloadsInstant |
84 #define MAYBE_PageVisibilityTest PageVisibilityTest | |
83 #define MAYBE_ExperimentEnabled ExperimentEnabled | 85 #define MAYBE_ExperimentEnabled ExperimentEnabled |
84 #endif | 86 #endif |
85 | 87 |
86 #if defined(OS_MACOSX) || defined(OS_LINUX) | 88 #if defined(OS_MACOSX) || defined(OS_LINUX) |
87 // Showing as flaky on Mac and Linux. | 89 // Showing as flaky on Mac and Linux. |
88 // http://crbug.com/70860 | 90 // http://crbug.com/70860 |
89 #define MAYBE_SearchServerDoesntSupportInstant \ | 91 #define MAYBE_SearchServerDoesntSupportInstant \ |
90 DISABLED_SearchServerDoesntSupportInstant | 92 DISABLED_SearchServerDoesntSupportInstant |
91 #define MAYBE_NonSearchToSearchDoesntSupportInstant \ | 93 #define MAYBE_NonSearchToSearchDoesntSupportInstant \ |
92 DISABLED_NonSearchToSearchDoesntSupportInstant | 94 DISABLED_NonSearchToSearchDoesntSupportInstant |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 "window.domAutomationController.send(%s)", function.c_str()); | 250 "window.domAutomationController.send(%s)", function.c_str()); |
249 return ui_test_utils::ExecuteJavaScriptAndExtractBool( | 251 return ui_test_utils::ExecuteJavaScriptAndExtractBool( |
250 tab_contents->render_view_host(), | 252 tab_contents->render_view_host(), |
251 std::wstring(), UTF8ToWide(script), result); | 253 std::wstring(), UTF8ToWide(script), result); |
252 } | 254 } |
253 | 255 |
254 bool HasPreview() { | 256 bool HasPreview() { |
255 return browser()->instant()->GetPreviewContents() != NULL; | 257 return browser()->instant()->GetPreviewContents() != NULL; |
256 } | 258 } |
257 | 259 |
260 bool IsTabContentsPageVisibiltyVisible(TabContents* tab_contents) { | |
sreeram
2011/10/25 23:26:48
Typo in "Visibilty". In any case, I'd recommend gi
Shishir
2011/10/25 23:46:26
Done.
| |
261 std::string visibility; | |
262 if (!GetStringFromJavascript(tab_contents, "document.webkitVisibilityState", | |
263 &visibility)) | |
264 return false; | |
265 return visibility == "visible"; | |
266 } | |
267 | |
258 // Returns the state of the search box as a string. This consists of the | 268 // Returns the state of the search box as a string. This consists of the |
259 // following: | 269 // following: |
260 // window.chrome.sv | 270 // window.chrome.sv |
261 // window.onsubmitcalls | 271 // window.onsubmitcalls |
262 // window.oncancelcalls | 272 // window.oncancelcalls |
263 // window.onchangecalls | 273 // window.onchangecalls |
264 // 'true' if window.onresizecalls has been sent, otherwise false. | 274 // 'true' if window.onresizecalls has been sent, otherwise false. |
265 // window.beforeLoadSearchBox.value | 275 // window.beforeLoadSearchBox.value |
266 // window.beforeLoadSearchBox.verbatim | 276 // window.beforeLoadSearchBox.verbatim |
267 // window.chrome.searchBox.value | 277 // window.chrome.searchBox.value |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
881 FindLocationBar(); | 891 FindLocationBar(); |
882 location_bar_->FocusLocation(false); | 892 location_bar_->FocusLocation(false); |
883 TabContentsWrapper* tab_contents = browser()->instant()->GetPreviewContents(); | 893 TabContentsWrapper* tab_contents = browser()->instant()->GetPreviewContents(); |
884 EXPECT_TRUE(tab_contents); | 894 EXPECT_TRUE(tab_contents); |
885 | 895 |
886 instant_support_observer.Wait(); | 896 instant_support_observer.Wait(); |
887 | 897 |
888 // Instant should have a preview, but not display it. | 898 // Instant should have a preview, but not display it. |
889 EXPECT_TRUE(HasPreview()); | 899 EXPECT_TRUE(HasPreview()); |
890 EXPECT_FALSE(browser()->instant()->is_displayable()); | 900 EXPECT_FALSE(browser()->instant()->is_displayable()); |
901 EXPECT_FALSE(IsTabContentsPageVisibiltyVisible(tab_contents->tab_contents())); | |
891 | 902 |
892 // Adding a new tab shouldn't delete (or recreate) the TabContentsWrapper. | 903 // Adding a new tab shouldn't delete (or recreate) the TabContentsWrapper. |
893 AddBlankTabAndShow(browser()); | 904 AddBlankTabAndShow(browser()); |
894 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents()); | 905 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents()); |
895 | 906 |
896 // Doing a search should still use the same loader for the preview. | 907 // Doing a search should still use the same loader for the preview. |
897 SetLocationBarText("def"); | 908 SetLocationBarText("def"); |
898 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents()); | 909 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents()); |
899 | 910 |
900 // Verify that the preview is in fact showing instant search. | 911 // Verify that the preview is in fact showing instant search. |
901 EXPECT_TRUE(HasPreview()); | 912 EXPECT_TRUE(HasPreview()); |
902 EXPECT_TRUE(browser()->instant()->is_displayable()); | 913 EXPECT_TRUE(browser()->instant()->is_displayable()); |
903 EXPECT_TRUE(browser()->instant()->IsCurrent()); | 914 EXPECT_TRUE(browser()->instant()->IsCurrent()); |
904 } | 915 } |
905 | 916 |
917 // Tests that the instant search page's visibility is set correctly. | |
918 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_PageVisibilityTest) { | |
919 ASSERT_TRUE(test_server()->Start()); | |
920 EnableInstant(); | |
921 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); | |
922 | |
923 // Initially navigate to the empty page which should be visible. | |
924 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); | |
925 location_bar_->location_entry()->SetUserText(ASCIIToUTF16( | |
926 test_server()->GetURL("files/instant/empty.html").spec())); | |
927 TabContents* initial_contents = browser()->GetSelectedTabContents(); | |
928 TestNavigationObserver observer(content::Source<NavigationController>( | |
929 &initial_contents->controller()), NULL, 1); | |
930 SendKey(ui::VKEY_RETURN); | |
931 observer.WaitForObservation(); | |
sreeram
2011/10/25 23:26:48
This seems like a lot of trouble. Why not this?
A
Shishir
2011/10/25 23:46:26
Done.
| |
932 EXPECT_TRUE(IsTabContentsPageVisibiltyVisible(initial_contents)); | |
933 | |
934 // Type something for instant to trigger and wait for preview to navigate. | |
935 location_bar_->FocusLocation(false); | |
936 SetupLocationBar(); | |
937 SetupPreview(); | |
938 SetLocationBarText("def"); | |
939 TabContents* preview_contents = | |
940 browser()->instant()->GetPreviewContents()->tab_contents(); | |
941 EXPECT_TRUE(IsTabContentsPageVisibiltyVisible(preview_contents)); | |
942 EXPECT_FALSE(IsTabContentsPageVisibiltyVisible(initial_contents)); | |
943 | |
944 // Delete the user text we should show the previous page. | |
945 location_bar_->location_entry()->SetUserText(UTF8ToUTF16("")); | |
946 EXPECT_FALSE(IsTabContentsPageVisibiltyVisible(preview_contents)); | |
947 EXPECT_TRUE(IsTabContentsPageVisibiltyVisible(initial_contents)); | |
948 | |
949 // Set the user text back and we should see the preview again. | |
950 location_bar_->location_entry()->SetUserText(UTF8ToUTF16("def")); | |
951 EXPECT_TRUE(IsTabContentsPageVisibiltyVisible(preview_contents)); | |
sreeram
2011/10/25 23:26:48
Just FYI: At first glance, I wouldn't have expecte
Shishir
2011/10/25 23:46:26
Do you suggest something else here to increase rob
sreeram
2011/10/26 04:29:52
I would normally have said to put in a call to Wai
| |
952 EXPECT_FALSE(IsTabContentsPageVisibiltyVisible(initial_contents)); | |
953 | |
954 // Commit the preview. | |
955 SendKey(ui::VKEY_RETURN); | |
956 EXPECT_EQ(preview_contents, browser()->GetSelectedTabContents()); | |
957 EXPECT_TRUE(IsTabContentsPageVisibiltyVisible(preview_contents)); | |
958 } | |
959 | |
960 | |
906 // Tests the INSTANT experiment of the field trial. | 961 // Tests the INSTANT experiment of the field trial. |
907 class InstantFieldTrialInstantTest : public InstantTest { | 962 class InstantFieldTrialInstantTest : public InstantTest { |
908 public: | 963 public: |
909 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 964 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
910 command_line->AppendSwitchASCII(switches::kInstantFieldTrial, | 965 command_line->AppendSwitchASCII(switches::kInstantFieldTrial, |
911 switches::kInstantFieldTrialInstant); | 966 switches::kInstantFieldTrialInstant); |
912 } | 967 } |
913 }; | 968 }; |
914 | 969 |
915 // Tests that instant is active, even without calling EnableInstant(). | 970 // Tests that instant is active, even without calling EnableInstant(). |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
995 | 1050 |
996 // Wait for the preview to navigate. | 1051 // Wait for the preview to navigate. |
997 WaitForPreviewToNavigate(); | 1052 WaitForPreviewToNavigate(); |
998 instant_support_observer.Wait(); | 1053 instant_support_observer.Wait(); |
999 | 1054 |
1000 // Instant should be active, but not displayable or committable. | 1055 // Instant should be active, but not displayable or committable. |
1001 EXPECT_TRUE(HasPreview()); | 1056 EXPECT_TRUE(HasPreview()); |
1002 EXPECT_FALSE(browser()->instant()->is_displayable()); | 1057 EXPECT_FALSE(browser()->instant()->is_displayable()); |
1003 EXPECT_FALSE(browser()->instant()->PrepareForCommit()); | 1058 EXPECT_FALSE(browser()->instant()->PrepareForCommit()); |
1004 } | 1059 } |
OLD | NEW |