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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc

Issue 1160073004: chrome/browser/ui: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Harmonize MessageLoop/TTRH usage. Created 5 years, 6 months 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/location.h"
9 #include "base/message_loop/message_loop.h"
8 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/run_loop.h"
12 #include "base/single_thread_task_runner.h"
msw 2015/06/12 00:31:21 nit: remove sttr and ttrh headers.
Sami 2015/06/12 10:56:22 Done.
9 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/thread_task_runner_handle.h"
11 #include "chrome/app/chrome_command_ids.h" 16 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 17 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
13 #include "chrome/browser/chrome_content_browser_client.h" 18 #include "chrome/browser/chrome_content_browser_client.h"
14 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 21 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
17 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_tabstrip.h" 23 #include "chrome/browser/ui/browser_tabstrip.h"
19 #include "chrome/browser/ui/browser_window.h" 24 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // Tasks and fully shut down. 313 // Tasks and fully shut down.
309 browser_->tab_strip_model()->CloseAllTabs(); 314 browser_->tab_strip_model()->CloseAllTabs();
310 bb_view_.reset(); 315 bb_view_.reset();
311 browser_.reset(); 316 browser_.reset();
312 profile_.reset(); 317 profile_.reset();
313 318
314 // Run the message loop to ensure we delete allTasks and fully shut down. 319 // Run the message loop to ensure we delete allTasks and fully shut down.
315 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); 320 base::MessageLoopForUI* loop = base::MessageLoopForUI::current();
316 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); 321 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop);
317 base::RunLoop run_loop; 322 base::RunLoop run_loop;
318 loop->PostTask(FROM_HERE, run_loop.QuitClosure()); 323 loop->task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure());
319 run_loop.Run(); 324 run_loop.Run();
320 325
321 ViewEventTestBase::TearDown(); 326 ViewEventTestBase::TearDown();
322 BookmarkBarView::DisableAnimationsForTesting(false); 327 BookmarkBarView::DisableAnimationsForTesting(false);
323 constrained_window::SetConstrainedWindowViewsClient(nullptr); 328 constrained_window::SetConstrainedWindowViewsClient(nullptr);
324 329
325 browser_content_client_.reset(); 330 browser_content_client_.reset();
326 content_client_.reset(); 331 content_client_.reset();
327 content::SetContentClient(NULL); 332 content::SetContentClient(NULL);
328 } 333 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 explicit BookmarkContextMenuNotificationObserver(const base::Closure& task) 582 explicit BookmarkContextMenuNotificationObserver(const base::Closure& task)
578 : task_(task) { 583 : task_(task) {
579 registrar_.Add(this, 584 registrar_.Add(this,
580 chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN, 585 chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN,
581 content::NotificationService::AllSources()); 586 content::NotificationService::AllSources());
582 } 587 }
583 588
584 void Observe(int type, 589 void Observe(int type,
585 const content::NotificationSource& source, 590 const content::NotificationSource& source,
586 const content::NotificationDetails& details) override { 591 const content::NotificationDetails& details) override {
587 base::MessageLoop::current()->PostTask(FROM_HERE, task_); 592 base::MessageLoop::current()->task_runner()->PostTask(FROM_HERE, task_);
588 } 593 }
589 594
590 // Sets the task that is posted when the context menu is shown. 595 // Sets the task that is posted when the context menu is shown.
591 void set_task(const base::Closure& task) { task_ = task; } 596 void set_task(const base::Closure& task) { task_ = task; }
592 597
593 private: 598 private:
594 content::NotificationRegistrar registrar_; 599 content::NotificationRegistrar registrar_;
595 base::Closure task_; 600 base::Closure task_;
596 601
597 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenuNotificationObserver); 602 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenuNotificationObserver);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 scroll_down_button->height() / 2); 1013 scroll_down_button->height() / 2);
1009 views::View::ConvertPointToScreen(scroll_down_button, &loc); 1014 views::View::ConvertPointToScreen(scroll_down_button, &loc);
1010 1015
1011 // On linux, the sending one location isn't enough. 1016 // On linux, the sending one location isn't enough.
1012 ui_controls::SendMouseMove(loc.x() - 1 , loc.y() - 1); 1017 ui_controls::SendMouseMove(loc.x() - 1 , loc.y() - 1);
1013 ui_controls::SendMouseMoveNotifyWhenDone( 1018 ui_controls::SendMouseMoveNotifyWhenDone(
1014 loc.x(), loc.y(), CreateEventTask(this, &BookmarkBarViewTest9::Step3)); 1019 loc.x(), loc.y(), CreateEventTask(this, &BookmarkBarViewTest9::Step3));
1015 } 1020 }
1016 1021
1017 void Step3() { 1022 void Step3() {
1018 base::MessageLoop::current()->PostDelayedTask( 1023 base::MessageLoop::current()->task_runner()->PostDelayedTask(
1019 FROM_HERE, 1024 FROM_HERE, base::Bind(&BookmarkBarViewTest9::Step4, this),
1020 base::Bind(&BookmarkBarViewTest9::Step4, this),
1021 base::TimeDelta::FromMilliseconds(200)); 1025 base::TimeDelta::FromMilliseconds(200));
1022 } 1026 }
1023 1027
1024 void Step4() { 1028 void Step4() {
1025 gfx::Point menu_loc; 1029 gfx::Point menu_loc;
1026 views::View::ConvertPointToScreen(first_menu_, &menu_loc); 1030 views::View::ConvertPointToScreen(first_menu_, &menu_loc);
1027 ASSERT_NE(start_y_, menu_loc.y()); 1031 ASSERT_NE(start_y_, menu_loc.y());
1028 1032
1029 // Hide menu. 1033 // Hide menu.
1030 bb_view_->GetMenu()->GetMenuController()->CancelAll(); 1034 bb_view_->GetMenu()->GetMenuController()->CancelAll();
1031 1035
1032 // On linux, Cancelling menu will call Quit on the message loop, 1036 // On linux, Cancelling menu will call Quit on the message loop,
1033 // which can interfere with Done. We need to run Done in the 1037 // which can interfere with Done. We need to run Done in the
1034 // next execution loop. 1038 // next execution loop.
1035 base::MessageLoop::current()->PostTask( 1039 base::MessageLoop::current()->task_runner()->PostTask(
1036 FROM_HERE, base::Bind(&ViewEventTestBase::Done, this)); 1040 FROM_HERE, base::Bind(&ViewEventTestBase::Done, this));
1037 } 1041 }
1038 1042
1039 int start_y_; 1043 int start_y_;
1040 views::MenuItemView* first_menu_; 1044 views::MenuItemView* first_menu_;
1041 }; 1045 };
1042 1046
1043 // Fails on official cros bot. crbug.com/431427. 1047 // Fails on official cros bot. crbug.com/431427.
1044 #if defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD) 1048 #if defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD)
1045 #define MAYBE_ScrollButtonScrolls DISABLED_ScrollButtonScrolls 1049 #define MAYBE_ScrollButtonScrolls DISABLED_ScrollButtonScrolls
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 waiter.reset(); 1312 waiter.reset();
1309 1313
1310 // Press tab to give focus to the cancel button. Wait until the widget 1314 // Press tab to give focus to the cancel button. Wait until the widget
1311 // receives the tab key. 1315 // receives the tab key.
1312 TabKeyWaiter tab_waiter(dialog); 1316 TabKeyWaiter tab_waiter(dialog);
1313 ui_controls::SendKeyPress( 1317 ui_controls::SendKeyPress(
1314 window_->GetNativeWindow(), ui::VKEY_TAB, false, false, false, false); 1318 window_->GetNativeWindow(), ui::VKEY_TAB, false, false, false, false);
1315 tab_waiter.WaitForTab(); 1319 tab_waiter.WaitForTab();
1316 1320
1317 // For some reason return isn't processed correctly unless we delay. 1321 // For some reason return isn't processed correctly unless we delay.
1318 base::MessageLoop::current()->PostDelayedTask( 1322 base::MessageLoop::current()->task_runner()->PostDelayedTask(
1319 FROM_HERE, 1323 FROM_HERE, base::Bind(&BookmarkBarViewTest12::Step5, this,
1320 base::Bind( 1324 base::Unretained(dialog)),
1321 &BookmarkBarViewTest12::Step5, this, base::Unretained(dialog)),
1322 base::TimeDelta::FromSeconds(1)); 1325 base::TimeDelta::FromSeconds(1));
1323 } 1326 }
1324 1327
1325 void Step5(views::Widget* dialog) { 1328 void Step5(views::Widget* dialog) {
1326 DialogCloseWaiter waiter(dialog); 1329 DialogCloseWaiter waiter(dialog);
1327 // And press enter so that the cancel button is selected. 1330 // And press enter so that the cancel button is selected.
1328 ui_controls::SendKeyPressNotifyWhenDone(window_->GetNativeWindow(), 1331 ui_controls::SendKeyPressNotifyWhenDone(window_->GetNativeWindow(),
1329 ui::VKEY_RETURN, 1332 ui::VKEY_RETURN,
1330 false, 1333 false,
1331 false, 1334 false,
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); 1577 ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
1575 1578
1576 // Button should be depressed. 1579 // Button should be depressed.
1577 views::LabelButton* button = GetBookmarkButton(0); 1580 views::LabelButton* button = GetBookmarkButton(0);
1578 ASSERT_TRUE(button->state() == views::CustomButton::STATE_PRESSED); 1581 ASSERT_TRUE(button->state() == views::CustomButton::STATE_PRESSED);
1579 1582
1580 // Close the window. 1583 // Close the window.
1581 window_->Close(); 1584 window_->Close();
1582 window_ = NULL; 1585 window_ = NULL;
1583 1586
1584 base::MessageLoop::current()->PostTask( 1587 base::MessageLoop::current()->task_runner()->PostTask(
1585 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest16::Done)); 1588 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest16::Done));
1586 } 1589 }
1587 }; 1590 };
1588 1591
1589 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 1592 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
1590 // TODO(erg): linux_aura bringup: http://crbug.com/163931 1593 // TODO(erg): linux_aura bringup: http://crbug.com/163931
1591 #define MAYBE_DeleteMenu DISABLED_DeleteMenu 1594 #define MAYBE_DeleteMenu DISABLED_DeleteMenu
1592 #else 1595 #else
1593 #define MAYBE_DeleteMenu DeleteMenu 1596 #define MAYBE_DeleteMenu DeleteMenu
1594 #endif 1597 #endif
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 }; 2056 };
2054 2057
2055 #if defined(OS_WIN) 2058 #if defined(OS_WIN)
2056 // This test times out on Windows. TODO(pkotwicz): Find out why. 2059 // This test times out on Windows. TODO(pkotwicz): Find out why.
2057 #define MAYBE_CloseSourceBrowserDuringDrag DISABLED_CloseSourceBrowserDuringDrag 2060 #define MAYBE_CloseSourceBrowserDuringDrag DISABLED_CloseSourceBrowserDuringDrag
2058 #else 2061 #else
2059 #define MAYBE_CloseSourceBrowserDuringDrag CloseSourceBrowserDuringDrag 2062 #define MAYBE_CloseSourceBrowserDuringDrag CloseSourceBrowserDuringDrag
2060 #endif 2063 #endif
2061 2064
2062 VIEW_TEST(BookmarkBarViewTest22, MAYBE_CloseSourceBrowserDuringDrag) 2065 VIEW_TEST(BookmarkBarViewTest22, MAYBE_CloseSourceBrowserDuringDrag)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698