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