Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_browsertest.cc |
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_browsertest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_browsertest.cc |
index 7a473e041830316b61cb431dbca1fc6668cae753..249f759331ebf483ae32715904607b7772ab111c 100644 |
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_browsertest.cc |
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_browsertest.cc |
@@ -78,6 +78,7 @@ |
#include "ui/aura/window.h" |
#include "ui/base/window_open_disposition.h" |
#include "ui/display/test/display_manager_test_api.h" |
+#include "ui/events/base_event_utils.h" |
#include "ui/events/event.h" |
#include "ui/events/event_constants.h" |
#include "ui/events/test/event_generator.h" |
@@ -94,12 +95,35 @@ ChromeLauncherControllerImpl* GetChromeLauncherControllerImpl() { |
ChromeLauncherController::instance()); |
} |
+// A callback that records the action taken when a shelf item is selected. |
+void SelectItemCallback(ash::ShelfAction* action_taken, |
+ base::Closure run_loop_quit_closure, |
James Cook
2017/03/09 01:09:47
optional: you could also take a RunLoop* run_loop
msw
2017/03/10 06:17:57
Done.
|
+ ash::ShelfAction action, |
+ ash::ShelfItemDelegate::MenuItemList) { |
+ *action_taken = action; |
+ run_loop_quit_closure.Run(); |
+} |
+ |
// Calls ShelfItemDelegate::SelectItem with an event type and default arguments. |
ash::ShelfAction SelectItem(ash::ShelfItemDelegate* delegate, |
ui::EventType event_type) { |
- return delegate->ItemSelected(event_type, ui::EF_NONE, |
- display::kInvalidDisplayId, |
- ash::LAUNCH_FROM_UNKNOWN); |
+ std::unique_ptr<ui::Event> event; |
+ if (event_type == ui::ET_MOUSE_PRESSED) { |
+ event = |
+ base::MakeUnique<ui::MouseEvent>(event_type, gfx::Point(), gfx::Point(), |
+ ui::EventTimeForNow(), ui::EF_NONE, 0); |
+ } else if (event_type == ui::ET_KEY_RELEASED) { |
+ event = base::MakeUnique<ui::KeyEvent>(event_type, ui::VKEY_UNKNOWN, |
+ ui::EF_NONE); |
+ } |
+ |
+ base::RunLoop run_loop; |
+ ash::ShelfAction action = ash::SHELF_ACTION_NONE; |
+ delegate->ItemSelected( |
+ std::move(event), display::kInvalidDisplayId, ash::LAUNCH_FROM_UNKNOWN, |
+ base::Bind(&SelectItemCallback, &action, run_loop.QuitClosure())); |
+ run_loop.RunUntilIdle(); |
James Cook
2017/03/09 01:09:47
Shouldn't this be run_loop.Run()?
msw
2017/03/10 06:17:57
Done.
|
+ return action; |
} |
class TestEvent : public ui::Event { |