| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_ExperimentEnabled DISABLED_ExperimentEnabled | 62 #define MAYBE_ExperimentEnabled DISABLED_ExperimentEnabled |
| 63 #define MAYBE_IntranetPathLooksLikeSearch DISABLED_IntranetPathLooksLikeSearch |
| 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 |
| 83 #define MAYBE_ExperimentEnabled ExperimentEnabled | 84 #define MAYBE_ExperimentEnabled ExperimentEnabled |
| 85 #define MAYBE_IntranetPathLooksLikeSearch IntranetPathLooksLikeSearch |
| 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 |
| 93 #else | 95 #else |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 // Doing a search should still use the same loader for the preview. | 898 // Doing a search should still use the same loader for the preview. |
| 897 SetLocationBarText("def"); | 899 SetLocationBarText("def"); |
| 898 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents()); | 900 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents()); |
| 899 | 901 |
| 900 // Verify that the preview is in fact showing instant search. | 902 // Verify that the preview is in fact showing instant search. |
| 901 EXPECT_TRUE(HasPreview()); | 903 EXPECT_TRUE(HasPreview()); |
| 902 EXPECT_TRUE(browser()->instant()->is_displayable()); | 904 EXPECT_TRUE(browser()->instant()->is_displayable()); |
| 903 EXPECT_TRUE(browser()->instant()->IsCurrent()); | 905 EXPECT_TRUE(browser()->instant()->IsCurrent()); |
| 904 } | 906 } |
| 905 | 907 |
| 908 // Tests that instant doesn't fire for intranet paths that look like searches. |
| 909 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_IntranetPathLooksLikeSearch) { |
| 910 ASSERT_TRUE(test_server()->Start()); |
| 911 EnableInstant(); |
| 912 SetupInstantProvider("search.html"); |
| 913 |
| 914 // Unfocus the omnibox. This should delete any existing preview contents. |
| 915 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 916 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 917 |
| 918 EXPECT_TRUE(browser()->instant()); |
| 919 EXPECT_FALSE(HasPreview()); |
| 920 |
| 921 // Navigate to a URL that looks like a search (when the scheme is stripped). |
| 922 // It's okay if the host is bogus or the navigation fails, since we only care |
| 923 // that instant doesn't act on it. |
| 924 ui_test_utils::NavigateToURL(browser(), GURL("http://baby/beluga")); |
| 925 |
| 926 // Instant should not have tried to load a preview for this "search". |
| 927 EXPECT_FALSE(HasPreview()); |
| 928 } |
| 929 |
| 906 // Tests the INSTANT experiment of the field trial. | 930 // Tests the INSTANT experiment of the field trial. |
| 907 class InstantFieldTrialInstantTest : public InstantTest { | 931 class InstantFieldTrialInstantTest : public InstantTest { |
| 908 public: | 932 public: |
| 909 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 933 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 910 command_line->AppendSwitchASCII(switches::kInstantFieldTrial, | 934 command_line->AppendSwitchASCII(switches::kInstantFieldTrial, |
| 911 switches::kInstantFieldTrialInstant); | 935 switches::kInstantFieldTrialInstant); |
| 912 } | 936 } |
| 913 }; | 937 }; |
| 914 | 938 |
| 915 // Tests that instant is active, even without calling EnableInstant(). | 939 // Tests that instant is active, even without calling EnableInstant(). |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 | 1019 |
| 996 // Wait for the preview to navigate. | 1020 // Wait for the preview to navigate. |
| 997 WaitForPreviewToNavigate(); | 1021 WaitForPreviewToNavigate(); |
| 998 instant_support_observer.Wait(); | 1022 instant_support_observer.Wait(); |
| 999 | 1023 |
| 1000 // Instant should be active, but not displayable or committable. | 1024 // Instant should be active, but not displayable or committable. |
| 1001 EXPECT_TRUE(HasPreview()); | 1025 EXPECT_TRUE(HasPreview()); |
| 1002 EXPECT_FALSE(browser()->instant()->is_displayable()); | 1026 EXPECT_FALSE(browser()->instant()->is_displayable()); |
| 1003 EXPECT_FALSE(browser()->instant()->PrepareForCommit()); | 1027 EXPECT_FALSE(browser()->instant()->PrepareForCommit()); |
| 1004 } | 1028 } |
| OLD | NEW |