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 <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 #if defined(OS_MACOSX) | 131 #if defined(OS_MACOSX) |
132 const int kCtrlOrCmdMask = ui::EF_COMMAND_DOWN; | 132 const int kCtrlOrCmdMask = ui::EF_COMMAND_DOWN; |
133 #else | 133 #else |
134 const int kCtrlOrCmdMask = ui::EF_CONTROL_DOWN; | 134 const int kCtrlOrCmdMask = ui::EF_CONTROL_DOWN; |
135 #endif | 135 #endif |
136 | 136 |
137 } // namespace | 137 } // namespace |
138 | 138 |
139 class OmniboxViewTest : public InProcessBrowserTest, | 139 class OmniboxViewTest : public InProcessBrowserTest, |
140 public content::NotificationObserver { | 140 public content::NotificationObserver, |
| 141 public history::HistoryServiceObserver { |
| 142 public: |
| 143 OmniboxViewTest() : observer_(this) { |
| 144 } |
| 145 |
| 146 // history::HisoryServiceObserver: |
| 147 virtual void OnHistoryServiceLoaded( |
| 148 HistoryService* history_service) override { |
| 149 base::MessageLoop::current()->Quit(); |
| 150 } |
| 151 |
141 protected: | 152 protected: |
142 void SetUpOnMainThread() override { | 153 void SetUpOnMainThread() override { |
143 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 154 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
144 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | 155 ASSERT_NO_FATAL_FAILURE(SetupComponents()); |
145 chrome::FocusLocationBar(browser()); | 156 chrome::FocusLocationBar(browser()); |
146 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 157 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
147 } | 158 } |
148 | 159 |
149 static void GetOmniboxViewForBrowser( | 160 static void GetOmniboxViewForBrowser( |
150 const Browser* browser, | 161 const Browser* browser, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 286 } |
276 } | 287 } |
277 | 288 |
278 void AddHistoryEntry(const TestHistoryEntry& entry, const Time& time) { | 289 void AddHistoryEntry(const TestHistoryEntry& entry, const Time& time) { |
279 Profile* profile = browser()->profile(); | 290 Profile* profile = browser()->profile(); |
280 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 291 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
281 profile, Profile::EXPLICIT_ACCESS); | 292 profile, Profile::EXPLICIT_ACCESS); |
282 ASSERT_TRUE(history_service); | 293 ASSERT_TRUE(history_service); |
283 | 294 |
284 if (!history_service->BackendLoaded()) { | 295 if (!history_service->BackendLoaded()) { |
285 content::NotificationRegistrar registrar; | 296 observer_.Add(history_service); |
286 registrar.Add(this, chrome::NOTIFICATION_HISTORY_LOADED, | |
287 content::Source<Profile>(profile)); | |
288 content::RunMessageLoop(); | 297 content::RunMessageLoop(); |
289 } | 298 } |
290 | 299 |
291 BookmarkModel* bookmark_model = | 300 BookmarkModel* bookmark_model = |
292 BookmarkModelFactory::GetForProfile(profile); | 301 BookmarkModelFactory::GetForProfile(profile); |
293 ASSERT_TRUE(bookmark_model); | 302 ASSERT_TRUE(bookmark_model); |
294 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); | 303 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); |
295 | 304 |
296 GURL url(entry.url); | 305 GURL url(entry.url); |
297 // Add everything in order of time. We don't want to have a time that | 306 // Add everything in order of time. We don't want to have a time that |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 ASSERT_NO_FATAL_FAILURE(SetupHistory()); | 348 ASSERT_NO_FATAL_FAILURE(SetupHistory()); |
340 } | 349 } |
341 | 350 |
342 void Observe(int type, | 351 void Observe(int type, |
343 const content::NotificationSource& source, | 352 const content::NotificationSource& source, |
344 const content::NotificationDetails& details) override { | 353 const content::NotificationDetails& details) override { |
345 switch (type) { | 354 switch (type) { |
346 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: | 355 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: |
347 case chrome::NOTIFICATION_TAB_PARENTED: | 356 case chrome::NOTIFICATION_TAB_PARENTED: |
348 case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY: | 357 case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY: |
349 case chrome::NOTIFICATION_HISTORY_LOADED: | |
350 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED: | 358 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED: |
351 break; | 359 break; |
352 default: | 360 default: |
353 FAIL() << "Unexpected notification type"; | 361 FAIL() << "Unexpected notification type"; |
354 } | 362 } |
355 base::MessageLoop::current()->Quit(); | 363 base::MessageLoop::current()->Quit(); |
356 } | 364 } |
| 365 |
| 366 private: |
| 367 ScopedObserver<HistoryService, OmniboxViewTest> observer_; |
357 }; | 368 }; |
358 | 369 |
359 // Test if ctrl-* accelerators are workable in omnibox. | 370 // Test if ctrl-* accelerators are workable in omnibox. |
360 // See http://crbug.com/19193: omnibox blocks ctrl-* commands | 371 // See http://crbug.com/19193: omnibox blocks ctrl-* commands |
361 // | 372 // |
362 // Flaky on interactive tests (dbg), http://crbug.com/69433 | 373 // Flaky on interactive tests (dbg), http://crbug.com/69433 |
363 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_BrowserAccelerators) { | 374 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_BrowserAccelerators) { |
364 OmniboxView* omnibox_view = NULL; | 375 OmniboxView* omnibox_view = NULL; |
365 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 376 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
366 | 377 |
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1799 omnibox_view->Update(); | 1810 omnibox_view->Update(); |
1800 EXPECT_EQ(url_c, omnibox_view->GetText()); | 1811 EXPECT_EQ(url_c, omnibox_view->GetText()); |
1801 } | 1812 } |
1802 | 1813 |
1803 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) { | 1814 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) { |
1804 browser()->toolbar_model()->set_url_replacement_enabled(true); | 1815 browser()->toolbar_model()->set_url_replacement_enabled(true); |
1805 chrome::FocusLocationBar(browser()); | 1816 chrome::FocusLocationBar(browser()); |
1806 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); | 1817 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); |
1807 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled()); | 1818 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled()); |
1808 } | 1819 } |
OLD | NEW |