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/string_util.h" | 6 #include "base/string_util.h" |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 9 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 InstantTest() { | 50 InstantTest() { |
51 set_show_window(true); | 51 set_show_window(true); |
52 EnableDOMAutomation(); | 52 EnableDOMAutomation(); |
53 } | 53 } |
54 | 54 |
55 void EnableInstant() { | 55 void EnableInstant() { |
56 InstantController::Enable(browser()->profile()); | 56 InstantController::Enable(browser()->profile()); |
57 } | 57 } |
58 | 58 |
59 void SetupInstantProvider(const std::string& page) { | 59 void SetupInstantProvider(const std::string& page) { |
| 60 Profile* profile = browser()->profile(); |
60 TemplateURLService* model = | 61 TemplateURLService* model = |
61 TemplateURLServiceFactory::GetForProfile(browser()->profile()); | 62 TemplateURLServiceFactory::GetForProfile(profile); |
62 | 63 |
63 ui_test_utils::WindowedNotificationObserver observer( | 64 ui_test_utils::WindowedNotificationObserver observer( |
64 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, | 65 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, |
65 content::NotificationService::AllSources()); | 66 content::NotificationService::AllSources()); |
66 if (!model->loaded()) { | 67 if (!model->loaded()) { |
67 model->Load(); | 68 model->Load(); |
68 observer.Wait(); | 69 observer.Wait(); |
69 } | 70 } |
70 | 71 |
71 TemplateURLData data; | 72 TemplateURLData data; |
72 data.short_name = ASCIIToUTF16("foo"); | 73 data.short_name = ASCIIToUTF16("foo"); |
73 data.SetKeyword(ASCIIToUTF16("foo")); | 74 data.SetKeyword(ASCIIToUTF16("foo")); |
74 data.SetURL(base::StringPrintf("http://%s:%d/files/%s?q={searchTerms}", | 75 data.SetURL(base::StringPrintf("http://%s:%d/files/%s?q={searchTerms}", |
75 test_server()->host_port_pair().host().c_str(), | 76 test_server()->host_port_pair().host().c_str(), |
76 test_server()->host_port_pair().port(), page.c_str())); | 77 test_server()->host_port_pair().port(), page.c_str())); |
77 data.instant_url = data.url(); | 78 data.instant_url = data.url(); |
78 // TemplateURLService takes ownership of this. | 79 // TemplateURLService takes ownership of this. |
79 TemplateURL* template_url = new TemplateURL(data); | 80 TemplateURL* template_url = new TemplateURL(profile, data); |
80 model->Add(template_url); | 81 model->Add(template_url); |
81 model->SetDefaultSearchProvider(template_url); | 82 model->SetDefaultSearchProvider(template_url); |
82 } | 83 } |
83 | 84 |
84 // Type a character to get instant to trigger and determine instant support. | 85 // Type a character to get instant to trigger and determine instant support. |
85 void DetermineInstantSupport() { | 86 void DetermineInstantSupport() { |
86 ui_test_utils::WindowedNotificationObserver observer( | 87 ui_test_utils::WindowedNotificationObserver observer( |
87 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED, | 88 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED, |
88 content::NotificationService::AllSources()); | 89 content::NotificationService::AllSources()); |
89 // "a" triggers the "about:" provider. "b" begins the "bing.com" keyword. | 90 // "a" triggers the "about:" provider. "b" begins the "bing.com" keyword. |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 // Press <Enter> in the omnibox, causing the preview to be committed. | 998 // Press <Enter> in the omnibox, causing the preview to be committed. |
998 WebContents* preview_tab = preview()->web_contents(); | 999 WebContents* preview_tab = preview()->web_contents(); |
999 ASSERT_TRUE(PressEnter()); | 1000 ASSERT_TRUE(PressEnter()); |
1000 | 1001 |
1001 // The preview contents should now be the active tab contents. | 1002 // The preview contents should now be the active tab contents. |
1002 EXPECT_FALSE(preview()); | 1003 EXPECT_FALSE(preview()); |
1003 EXPECT_FALSE(instant()->is_displayable()); | 1004 EXPECT_FALSE(instant()->is_displayable()); |
1004 EXPECT_FALSE(instant()->IsCurrent()); | 1005 EXPECT_FALSE(instant()->IsCurrent()); |
1005 EXPECT_EQ(preview_tab, browser()->GetSelectedWebContents()); | 1006 EXPECT_EQ(preview_tab, browser()->GetSelectedWebContents()); |
1006 } | 1007 } |
OLD | NEW |