Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc

Issue 694843002: Remove NOTIFICATION_HISTORY_URLS_MODIFIED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/scoped_observer.h"
8 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
9 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "chrome/app/chrome_command_ids.h" 13 #include "chrome/app/chrome_command_ids.h"
13 #include "chrome/browser/autocomplete/history_quick_provider.h" 14 #include "chrome/browser/autocomplete/history_quick_provider.h"
14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
15 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/history/history_service.h" 17 #include "chrome/browser/history/history_service.h"
17 #include "chrome/browser/history/history_service_factory.h" 18 #include "chrome/browser/history/history_service_factory.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/search_engines/template_url_service_factory.h" 20 #include "chrome/browser/search_engines/template_url_service_factory.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_commands.h" 22 #include "chrome/browser/ui/browser_commands.h"
22 #include "chrome/browser/ui/browser_window.h" 23 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/browser/ui/location_bar/location_bar.h" 24 #include "chrome/browser/ui/location_bar/location_bar.h"
24 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 25 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
25 #include "chrome/browser/ui/omnibox/omnibox_view.h" 26 #include "chrome/browser/ui/omnibox/omnibox_view.h"
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" 27 #include "chrome/browser/ui/tabs/tab_strip_model.h"
27 #include "chrome/browser/ui/toolbar/test_toolbar_model.h" 28 #include "chrome/browser/ui/toolbar/test_toolbar_model.h"
28 #include "chrome/common/chrome_paths.h" 29 #include "chrome/common/chrome_paths.h"
29 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
31 #include "chrome/test/base/in_process_browser_test.h" 32 #include "chrome/test/base/in_process_browser_test.h"
32 #include "chrome/test/base/interactive_test_utils.h" 33 #include "chrome/test/base/interactive_test_utils.h"
33 #include "chrome/test/base/ui_test_utils.h" 34 #include "chrome/test/base/ui_test_utils.h"
34 #include "components/bookmarks/browser/bookmark_model.h" 35 #include "components/bookmarks/browser/bookmark_model.h"
35 #include "components/bookmarks/browser/bookmark_utils.h" 36 #include "components/bookmarks/browser/bookmark_utils.h"
36 #include "components/bookmarks/test/bookmark_test_helpers.h" 37 #include "components/bookmarks/test/bookmark_test_helpers.h"
38 #include "components/history/core/browser/history_service_observer.h"
37 #include "components/omnibox/autocomplete_input.h" 39 #include "components/omnibox/autocomplete_input.h"
38 #include "components/omnibox/autocomplete_match.h" 40 #include "components/omnibox/autocomplete_match.h"
39 #include "components/search_engines/template_url.h" 41 #include "components/search_engines/template_url.h"
40 #include "components/search_engines/template_url_service.h" 42 #include "components/search_engines/template_url_service.h"
41 #include "content/public/browser/notification_service.h" 43 #include "content/public/browser/notification_service.h"
42 #include "content/public/browser/web_contents.h" 44 #include "content/public/browser/web_contents.h"
43 #include "net/dns/mock_host_resolver.h" 45 #include "net/dns/mock_host_resolver.h"
44 #include "ui/base/clipboard/clipboard.h" 46 #include "ui/base/clipboard/clipboard.h"
45 #include "ui/base/clipboard/scoped_clipboard_writer.h" 47 #include "ui/base/clipboard/scoped_clipboard_writer.h"
46 #include "ui/events/event_constants.h" 48 #include "ui/events/event_constants.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 132
131 #if defined(OS_MACOSX) 133 #if defined(OS_MACOSX)
132 const int kCtrlOrCmdMask = ui::EF_COMMAND_DOWN; 134 const int kCtrlOrCmdMask = ui::EF_COMMAND_DOWN;
133 #else 135 #else
134 const int kCtrlOrCmdMask = ui::EF_CONTROL_DOWN; 136 const int kCtrlOrCmdMask = ui::EF_CONTROL_DOWN;
135 #endif 137 #endif
136 138
137 } // namespace 139 } // namespace
138 140
139 class OmniboxViewTest : public InProcessBrowserTest, 141 class OmniboxViewTest : public InProcessBrowserTest,
140 public content::NotificationObserver { 142 public content::NotificationObserver,
143 public history::HistoryServiceObserver {
141 protected: 144 protected:
142 void SetUpOnMainThread() override { 145 void SetUpOnMainThread() override {
143 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 146 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
144 ASSERT_NO_FATAL_FAILURE(SetupComponents()); 147 ASSERT_NO_FATAL_FAILURE(SetupComponents());
145 chrome::FocusLocationBar(browser()); 148 chrome::FocusLocationBar(browser());
146 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); 149 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
147 } 150 }
148 151
149 static void GetOmniboxViewForBrowser( 152 static void GetOmniboxViewForBrowser(
150 const Browser* browser, 153 const Browser* browser,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // Add everything in order of time. We don't want to have a time that 300 // Add everything in order of time. We don't want to have a time that
298 // is "right now" or it will nondeterministically appear in the results. 301 // is "right now" or it will nondeterministically appear in the results.
299 history_service->AddPageWithDetails(url, base::UTF8ToUTF16(entry.title), 302 history_service->AddPageWithDetails(url, base::UTF8ToUTF16(entry.title),
300 entry.visit_count, 303 entry.visit_count,
301 entry.typed_count, time, false, 304 entry.typed_count, time, false,
302 history::SOURCE_BROWSED); 305 history::SOURCE_BROWSED);
303 if (entry.starred) 306 if (entry.starred)
304 bookmarks::AddIfNotBookmarked(bookmark_model, url, base::string16()); 307 bookmarks::AddIfNotBookmarked(bookmark_model, url, base::string16());
305 // Wait at least for the AddPageWithDetails() call to finish. 308 // Wait at least for the AddPageWithDetails() call to finish.
306 { 309 {
307 content::NotificationRegistrar registrar; 310 ScopedObserver<HistoryService, history::HistoryServiceObserver> observer(
308 registrar.Add(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, 311 this);
309 content::Source<Profile>(profile)); 312 observer.Add(history_service);
310 content::RunMessageLoop(); 313 content::RunMessageLoop();
311 // We don't want to return until all observers have processed this 314 // We don't want to return until all observers have processed this
312 // notification, because some (e.g. the in-memory history database) may do 315 // notification, because some (e.g. the in-memory history database) may do
313 // something important. Since we don't know where in the observer list we 316 // something important. Since we don't know where in the observer list we
314 // stand, just spin the message loop once more to allow the current 317 // stand, just spin the message loop once more to allow the current
315 // callstack to complete. 318 // callstack to complete.
316 content::RunAllPendingInMessageLoop(); 319 content::RunAllPendingInMessageLoop();
317 } 320 }
318 } 321 }
319 322
(...skipping 20 matching lines...) Expand all
340 } 343 }
341 344
342 void Observe(int type, 345 void Observe(int type,
343 const content::NotificationSource& source, 346 const content::NotificationSource& source,
344 const content::NotificationDetails& details) override { 347 const content::NotificationDetails& details) override {
345 switch (type) { 348 switch (type) {
346 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: 349 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED:
347 case chrome::NOTIFICATION_TAB_PARENTED: 350 case chrome::NOTIFICATION_TAB_PARENTED:
348 case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY: 351 case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY:
349 case chrome::NOTIFICATION_HISTORY_LOADED: 352 case chrome::NOTIFICATION_HISTORY_LOADED:
350 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED:
351 break; 353 break;
352 default: 354 default:
353 FAIL() << "Unexpected notification type"; 355 FAIL() << "Unexpected notification type";
354 } 356 }
355 base::MessageLoop::current()->Quit(); 357 base::MessageLoop::current()->Quit();
356 } 358 }
359
360 void OnURLsModified(HistoryService* history_service,
361 const history::URLRows& changed_urls) override {
362 base::MessageLoop::current()->Quit();
363 }
357 }; 364 };
358 365
359 // Test if ctrl-* accelerators are workable in omnibox. 366 // Test if ctrl-* accelerators are workable in omnibox.
360 // See http://crbug.com/19193: omnibox blocks ctrl-* commands 367 // See http://crbug.com/19193: omnibox blocks ctrl-* commands
361 // 368 //
362 // Flaky on interactive tests (dbg), http://crbug.com/69433 369 // Flaky on interactive tests (dbg), http://crbug.com/69433
363 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_BrowserAccelerators) { 370 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_BrowserAccelerators) {
364 OmniboxView* omnibox_view = NULL; 371 OmniboxView* omnibox_view = NULL;
365 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 372 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
366 373
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 omnibox_view->Update(); 1806 omnibox_view->Update();
1800 EXPECT_EQ(url_c, omnibox_view->GetText()); 1807 EXPECT_EQ(url_c, omnibox_view->GetText());
1801 } 1808 }
1802 1809
1803 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) { 1810 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) {
1804 browser()->toolbar_model()->set_url_replacement_enabled(true); 1811 browser()->toolbar_model()->set_url_replacement_enabled(true);
1805 chrome::FocusLocationBar(browser()); 1812 chrome::FocusLocationBar(browser());
1806 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); 1813 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0));
1807 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled()); 1814 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled());
1808 } 1815 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/history_menu_bridge.mm ('k') | components/history/core/browser/history_backend_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698