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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_browsertest.cc

Issue 2718563008: mash: Use mojo for ShelfItemDelegate and [app] MenuItem. (Closed)
Patch Set: Cleanup; fix ash_shell compile and a couple tests. Created 3 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/common/shelf/app_list_button.h" 9 #include "ash/common/shelf/app_list_button.h"
10 #include "ash/common/shelf/shelf_button.h" 10 #include "ash/common/shelf/shelf_button.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #include "testing/gtest/include/gtest/gtest.h" 71 #include "testing/gtest/include/gtest/gtest.h"
72 #include "ui/app_list/app_list_switches.h" 72 #include "ui/app_list/app_list_switches.h"
73 #include "ui/app_list/views/app_list_item_view.h" 73 #include "ui/app_list/views/app_list_item_view.h"
74 #include "ui/app_list/views/apps_grid_view.h" 74 #include "ui/app_list/views/apps_grid_view.h"
75 #include "ui/app_list/views/start_page_view.h" 75 #include "ui/app_list/views/start_page_view.h"
76 #include "ui/app_list/views/tile_item_view.h" 76 #include "ui/app_list/views/tile_item_view.h"
77 #include "ui/aura/client/aura_constants.h" 77 #include "ui/aura/client/aura_constants.h"
78 #include "ui/aura/window.h" 78 #include "ui/aura/window.h"
79 #include "ui/base/window_open_disposition.h" 79 #include "ui/base/window_open_disposition.h"
80 #include "ui/display/test/display_manager_test_api.h" 80 #include "ui/display/test/display_manager_test_api.h"
81 #include "ui/events/base_event_utils.h"
81 #include "ui/events/event.h" 82 #include "ui/events/event.h"
82 #include "ui/events/event_constants.h" 83 #include "ui/events/event_constants.h"
83 #include "ui/events/test/event_generator.h" 84 #include "ui/events/test/event_generator.h"
84 85
85 using ash::WmShelf; 86 using ash::WmShelf;
86 using extensions::AppWindow; 87 using extensions::AppWindow;
87 using extensions::Extension; 88 using extensions::Extension;
88 using content::WebContents; 89 using content::WebContents;
89 90
90 namespace { 91 namespace {
91 92
92 ChromeLauncherControllerImpl* GetChromeLauncherControllerImpl() { 93 ChromeLauncherControllerImpl* GetChromeLauncherControllerImpl() {
93 return static_cast<ChromeLauncherControllerImpl*>( 94 return static_cast<ChromeLauncherControllerImpl*>(
94 ChromeLauncherController::instance()); 95 ChromeLauncherController::instance());
95 } 96 }
96 97
98 // A callback that records the action taken when a shelf item is selected.
99 void SelectItemCallback(ash::ShelfAction* action_taken,
100 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.
101 ash::ShelfAction action,
102 ash::ShelfItemDelegate::MenuItemList) {
103 *action_taken = action;
104 run_loop_quit_closure.Run();
105 }
106
97 // Calls ShelfItemDelegate::SelectItem with an event type and default arguments. 107 // Calls ShelfItemDelegate::SelectItem with an event type and default arguments.
98 ash::ShelfAction SelectItem(ash::ShelfItemDelegate* delegate, 108 ash::ShelfAction SelectItem(ash::ShelfItemDelegate* delegate,
99 ui::EventType event_type) { 109 ui::EventType event_type) {
100 return delegate->ItemSelected(event_type, ui::EF_NONE, 110 std::unique_ptr<ui::Event> event;
101 display::kInvalidDisplayId, 111 if (event_type == ui::ET_MOUSE_PRESSED) {
102 ash::LAUNCH_FROM_UNKNOWN); 112 event =
113 base::MakeUnique<ui::MouseEvent>(event_type, gfx::Point(), gfx::Point(),
114 ui::EventTimeForNow(), ui::EF_NONE, 0);
115 } else if (event_type == ui::ET_KEY_RELEASED) {
116 event = base::MakeUnique<ui::KeyEvent>(event_type, ui::VKEY_UNKNOWN,
117 ui::EF_NONE);
118 }
119
120 base::RunLoop run_loop;
121 ash::ShelfAction action = ash::SHELF_ACTION_NONE;
122 delegate->ItemSelected(
123 std::move(event), display::kInvalidDisplayId, ash::LAUNCH_FROM_UNKNOWN,
124 base::Bind(&SelectItemCallback, &action, run_loop.QuitClosure()));
125 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.
126 return action;
103 } 127 }
104 128
105 class TestEvent : public ui::Event { 129 class TestEvent : public ui::Event {
106 public: 130 public:
107 explicit TestEvent(ui::EventType type) 131 explicit TestEvent(ui::EventType type)
108 : ui::Event(type, base::TimeTicks(), 0) {} 132 : ui::Event(type, base::TimeTicks(), 0) {}
109 ~TestEvent() override {} 133 ~TestEvent() override {}
110 134
111 private: 135 private:
112 DISALLOW_COPY_AND_ASSIGN(TestEvent); 136 DISALLOW_COPY_AND_ASSIGN(TestEvent);
(...skipping 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 2416
2393 // Close all windows via the menu item. 2417 // Close all windows via the menu item.
2394 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); 2418 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE);
2395 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); 2419 EXPECT_EQ(0u, BrowserList::GetInstance()->size());
2396 2420
2397 // Check if "Close" is removed from the context menu. 2421 // Check if "Close" is removed from the context menu.
2398 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); 2422 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu();
2399 ASSERT_FALSE( 2423 ASSERT_FALSE(
2400 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); 2424 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE));
2401 } 2425 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698