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

Side by Side Diff: chrome/browser/instant/instant_browsertest.cc

Issue 8373010: Fixing visibility transitions for Instant. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Addressing Sreeram's comments. Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/instant/instant_loader.cc » ('j') | chrome/browser/ui/browser.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 IsVisible(TabContents* tab_contents) {
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
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(IsVisible(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 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(""));
925 TabContents* initial_contents = browser()->GetSelectedTabContents();
926 EXPECT_TRUE(IsVisible(initial_contents));
927
928 // Type something for instant to trigger and wait for preview to navigate.
929 ASSERT_NO_FATAL_FAILURE(FindLocationBar());
930 location_bar_->FocusLocation(false);
931 SetupLocationBar();
932 SetupPreview();
933 SetLocationBarText("def");
934 TabContents* preview_contents =
935 browser()->instant()->GetPreviewContents()->tab_contents();
936 EXPECT_TRUE(IsVisible(preview_contents));
937 EXPECT_FALSE(IsVisible(initial_contents));
938
939 // Delete the user text we should show the previous page.
940 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(""));
941 EXPECT_FALSE(IsVisible(preview_contents));
942 EXPECT_TRUE(IsVisible(initial_contents));
943
944 // Set the user text back and we should see the preview again.
945 location_bar_->location_entry()->SetUserText(UTF8ToUTF16("def"));
946 EXPECT_TRUE(IsVisible(preview_contents));
947 EXPECT_FALSE(IsVisible(initial_contents));
948
949 // Commit the preview.
950 SendKey(ui::VKEY_RETURN);
951 EXPECT_EQ(preview_contents, browser()->GetSelectedTabContents());
952 EXPECT_TRUE(IsVisible(preview_contents));
953 }
954
955
906 // Tests the INSTANT experiment of the field trial. 956 // Tests the INSTANT experiment of the field trial.
907 class InstantFieldTrialInstantTest : public InstantTest { 957 class InstantFieldTrialInstantTest : public InstantTest {
908 public: 958 public:
909 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 959 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
910 command_line->AppendSwitchASCII(switches::kInstantFieldTrial, 960 command_line->AppendSwitchASCII(switches::kInstantFieldTrial,
911 switches::kInstantFieldTrialInstant); 961 switches::kInstantFieldTrialInstant);
912 } 962 }
913 }; 963 };
914 964
915 // Tests that instant is active, even without calling EnableInstant(). 965 // Tests that instant is active, even without calling EnableInstant().
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 1045
996 // Wait for the preview to navigate. 1046 // Wait for the preview to navigate.
997 WaitForPreviewToNavigate(); 1047 WaitForPreviewToNavigate();
998 instant_support_observer.Wait(); 1048 instant_support_observer.Wait();
999 1049
1000 // Instant should be active, but not displayable or committable. 1050 // Instant should be active, but not displayable or committable.
1001 EXPECT_TRUE(HasPreview()); 1051 EXPECT_TRUE(HasPreview());
1002 EXPECT_FALSE(browser()->instant()->is_displayable()); 1052 EXPECT_FALSE(browser()->instant()->is_displayable());
1003 EXPECT_FALSE(browser()->instant()->PrepareForCommit()); 1053 EXPECT_FALSE(browser()->instant()->PrepareForCommit());
1004 } 1054 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/instant/instant_loader.cc » ('j') | chrome/browser/ui/browser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698