Chromium Code Reviews| 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 // history::HisoryServiceObserver: | |
|
sdefresne
2014/11/05 14:51:52
nit: history::HistoryServiceObserver
nshaik
2014/11/06 02:05:12
Done.
| |
| 146 virtual void OnHistoryServiceLoaded( | |
|
sdefresne
2014/11/05 14:51:52
style: remove "virtual" and add "override" instead
nshaik
2014/11/06 02:05:12
Not sure how i missed it. Fixed it..
| |
| 147 HistoryService* history_service) override { | |
| 148 base::MessageLoop::current()->Quit(); | |
| 149 } | |
| 150 | |
| 141 protected: | 151 protected: |
| 142 void SetUpOnMainThread() override { | 152 void SetUpOnMainThread() override { |
| 143 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 153 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 144 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | 154 ASSERT_NO_FATAL_FAILURE(SetupComponents()); |
| 145 chrome::FocusLocationBar(browser()); | 155 chrome::FocusLocationBar(browser()); |
| 146 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 156 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
| 147 } | 157 } |
| 148 | 158 |
| 149 static void GetOmniboxViewForBrowser( | 159 static void GetOmniboxViewForBrowser( |
| 150 const Browser* browser, | 160 const Browser* browser, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 } | 285 } |
| 276 } | 286 } |
| 277 | 287 |
| 278 void AddHistoryEntry(const TestHistoryEntry& entry, const Time& time) { | 288 void AddHistoryEntry(const TestHistoryEntry& entry, const Time& time) { |
| 279 Profile* profile = browser()->profile(); | 289 Profile* profile = browser()->profile(); |
| 280 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 290 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 281 profile, Profile::EXPLICIT_ACCESS); | 291 profile, Profile::EXPLICIT_ACCESS); |
| 282 ASSERT_TRUE(history_service); | 292 ASSERT_TRUE(history_service); |
| 283 | 293 |
| 284 if (!history_service->BackendLoaded()) { | 294 if (!history_service->BackendLoaded()) { |
| 285 content::NotificationRegistrar registrar; | 295 observer_.Add(history_service); |
| 286 registrar.Add(this, chrome::NOTIFICATION_HISTORY_LOADED, | |
| 287 content::Source<Profile>(profile)); | |
| 288 content::RunMessageLoop(); | 296 content::RunMessageLoop(); |
| 289 } | 297 } |
| 290 | 298 |
| 291 BookmarkModel* bookmark_model = | 299 BookmarkModel* bookmark_model = |
| 292 BookmarkModelFactory::GetForProfile(profile); | 300 BookmarkModelFactory::GetForProfile(profile); |
| 293 ASSERT_TRUE(bookmark_model); | 301 ASSERT_TRUE(bookmark_model); |
| 294 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); | 302 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); |
| 295 | 303 |
| 296 GURL url(entry.url); | 304 GURL url(entry.url); |
| 297 // Add everything in order of time. We don't want to have a time that | 305 // 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()); | 347 ASSERT_NO_FATAL_FAILURE(SetupHistory()); |
| 340 } | 348 } |
| 341 | 349 |
| 342 void Observe(int type, | 350 void Observe(int type, |
| 343 const content::NotificationSource& source, | 351 const content::NotificationSource& source, |
| 344 const content::NotificationDetails& details) override { | 352 const content::NotificationDetails& details) override { |
| 345 switch (type) { | 353 switch (type) { |
| 346 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: | 354 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: |
| 347 case chrome::NOTIFICATION_TAB_PARENTED: | 355 case chrome::NOTIFICATION_TAB_PARENTED: |
| 348 case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY: | 356 case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY: |
| 349 case chrome::NOTIFICATION_HISTORY_LOADED: | |
| 350 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED: | 357 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED: |
| 351 break; | 358 break; |
| 352 default: | 359 default: |
| 353 FAIL() << "Unexpected notification type"; | 360 FAIL() << "Unexpected notification type"; |
| 354 } | 361 } |
| 355 base::MessageLoop::current()->Quit(); | 362 base::MessageLoop::current()->Quit(); |
| 356 } | 363 } |
| 364 | |
| 365 private: | |
| 366 ScopedObserver<HistoryService, OmniboxViewTest> observer_; | |
| 357 }; | 367 }; |
| 358 | 368 |
| 359 // Test if ctrl-* accelerators are workable in omnibox. | 369 // Test if ctrl-* accelerators are workable in omnibox. |
| 360 // See http://crbug.com/19193: omnibox blocks ctrl-* commands | 370 // See http://crbug.com/19193: omnibox blocks ctrl-* commands |
| 361 // | 371 // |
| 362 // Flaky on interactive tests (dbg), http://crbug.com/69433 | 372 // Flaky on interactive tests (dbg), http://crbug.com/69433 |
| 363 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_BrowserAccelerators) { | 373 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_BrowserAccelerators) { |
| 364 OmniboxView* omnibox_view = NULL; | 374 OmniboxView* omnibox_view = NULL; |
| 365 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 375 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 366 | 376 |
| (...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1799 omnibox_view->Update(); | 1809 omnibox_view->Update(); |
| 1800 EXPECT_EQ(url_c, omnibox_view->GetText()); | 1810 EXPECT_EQ(url_c, omnibox_view->GetText()); |
| 1801 } | 1811 } |
| 1802 | 1812 |
| 1803 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) { | 1813 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) { |
| 1804 browser()->toolbar_model()->set_url_replacement_enabled(true); | 1814 browser()->toolbar_model()->set_url_replacement_enabled(true); |
| 1805 chrome::FocusLocationBar(browser()); | 1815 chrome::FocusLocationBar(browser()); |
| 1806 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); | 1816 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); |
| 1807 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled()); | 1817 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled()); |
| 1808 } | 1818 } |
| OLD | NEW |