| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 TemplateURLServiceFactory::GetForProfile(browser()->profile()); | 61 TemplateURLServiceFactory::GetForProfile(browser()->profile()); |
| 62 | 62 |
| 63 ui_test_utils::WindowedNotificationObserver observer( | 63 ui_test_utils::WindowedNotificationObserver observer( |
| 64 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, | 64 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, |
| 65 content::NotificationService::AllSources()); | 65 content::NotificationService::AllSources()); |
| 66 if (!model->loaded()) { | 66 if (!model->loaded()) { |
| 67 model->Load(); | 67 model->Load(); |
| 68 observer.Wait(); | 68 observer.Wait(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 TemplateURLData data; |
| 72 data.short_name = ASCIIToUTF16("foo"); |
| 73 data.SetKeyword(ASCIIToUTF16("foo")); |
| 74 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().port(), page.c_str())); |
| 77 data.instant_url = data.url(); |
| 71 // TemplateURLService takes ownership of this. | 78 // TemplateURLService takes ownership of this. |
| 72 TemplateURL* template_url = new TemplateURL(); | 79 TemplateURL* template_url = new TemplateURL(data); |
| 73 | |
| 74 std::string url = base::StringPrintf( | |
| 75 "http://%s:%d/files/%s?q={searchTerms}", | |
| 76 test_server()->host_port_pair().host().c_str(), | |
| 77 test_server()->host_port_pair().port(), | |
| 78 page.c_str()); | |
| 79 template_url->SetURL(url); | |
| 80 template_url->SetInstantURL(url); | |
| 81 template_url->set_keyword(ASCIIToUTF16("foo")); | |
| 82 template_url->set_short_name(ASCIIToUTF16("foo")); | |
| 83 | |
| 84 model->Add(template_url); | 80 model->Add(template_url); |
| 85 model->SetDefaultSearchProvider(template_url); | 81 model->SetDefaultSearchProvider(template_url); |
| 86 } | 82 } |
| 87 | 83 |
| 88 // Type a character to get instant to trigger and determine instant support. | 84 // Type a character to get instant to trigger and determine instant support. |
| 89 void DetermineInstantSupport() { | 85 void DetermineInstantSupport() { |
| 90 ui_test_utils::WindowedNotificationObserver observer( | 86 ui_test_utils::WindowedNotificationObserver observer( |
| 91 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED, | 87 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED, |
| 92 content::NotificationService::AllSources()); | 88 content::NotificationService::AllSources()); |
| 93 // "a" triggers the "about:" provider. "b" begins the "bing.com" keyword. | 89 // "a" triggers the "about:" provider. "b" begins the "bing.com" keyword. |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 // Press <Enter> in the omnibox, causing the preview to be committed. | 996 // Press <Enter> in the omnibox, causing the preview to be committed. |
| 1001 WebContents* preview_tab = preview()->web_contents(); | 997 WebContents* preview_tab = preview()->web_contents(); |
| 1002 ASSERT_TRUE(PressEnter()); | 998 ASSERT_TRUE(PressEnter()); |
| 1003 | 999 |
| 1004 // The preview contents should now be the active tab contents. | 1000 // The preview contents should now be the active tab contents. |
| 1005 EXPECT_FALSE(preview()); | 1001 EXPECT_FALSE(preview()); |
| 1006 EXPECT_FALSE(instant()->is_displayable()); | 1002 EXPECT_FALSE(instant()->is_displayable()); |
| 1007 EXPECT_FALSE(instant()->IsCurrent()); | 1003 EXPECT_FALSE(instant()->IsCurrent()); |
| 1008 EXPECT_EQ(preview_tab, browser()->GetSelectedWebContents()); | 1004 EXPECT_EQ(preview_tab, browser()->GetSelectedWebContents()); |
| 1009 } | 1005 } |
| OLD | NEW |