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

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

Issue 2046843005: mash: Migrate shelf menus to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ash_shell_with_content Created 4 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
« no previous file with comments | « chrome/browser/ui/ash/launcher/launcher_context_menu.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/launcher_context_menu.h" 5 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
6 6
7 #include "ash/common/shelf/shelf_item_types.h" 7 #include "ash/common/shelf/shelf_item_types.h"
8 #include "ash/common/shelf/shelf_model.h" 8 #include "ash/common/shelf/shelf_model.h"
9 #include "ash/shelf/shelf.h" 9 #include "ash/common/wm_root_window_controller.h"
10 #include "ash/shell.h" 10 #include "ash/common/wm_shell.h"
11 #include "ash/common/wm_window.h"
11 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/prefs/incognito_mode_prefs.h" 15 #include "chrome/browser/prefs/incognito_mode_prefs.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" 17 #include "chrome/browser/ui/app_list/arc/arc_app_test.h"
17 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" 18 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h"
18 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" 19 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h"
19 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
20 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" 21 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h"
(...skipping 15 matching lines...) Expand all
36 arc_test_.SetUp(profile_.get()); 37 arc_test_.SetUp(profile_.get());
37 ash::test::AshTestBase::SetUp(); 38 ash::test::AshTestBase::SetUp();
38 controller_.reset(new ChromeLauncherController(profile(), &shelf_model_)); 39 controller_.reset(new ChromeLauncherController(profile(), &shelf_model_));
39 } 40 }
40 41
41 void TearDown() override { 42 void TearDown() override {
42 controller_.reset(nullptr); 43 controller_.reset(nullptr);
43 ash::test::AshTestBase::TearDown(); 44 ash::test::AshTestBase::TearDown();
44 } 45 }
45 46
47 ash::WmShelf* GetWmShelf() {
48 return ash::WmShell::Get()
49 ->GetPrimaryRootWindow()
50 ->GetRootWindowController()
51 ->GetShelf();
52 }
53
46 LauncherContextMenu* CreateLauncherContextMenu( 54 LauncherContextMenu* CreateLauncherContextMenu(
47 ash::ShelfItemType shelf_item_type) { 55 ash::ShelfItemType shelf_item_type) {
48 ash::ShelfItem item; 56 ash::ShelfItem item;
49 item.id = 1; // dummy id 57 item.id = 1; // dummy id
50 item.type = shelf_item_type; 58 item.type = shelf_item_type;
51 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); 59 return LauncherContextMenu::Create(controller_.get(), &item, GetWmShelf());
52 return LauncherContextMenu::Create(controller_.get(), &item, shelf);
53 } 60 }
54 61
55 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell() { 62 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell() {
56 ash::ShelfItem* item = nullptr; 63 ash::ShelfItem* item = nullptr;
57 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); 64 return LauncherContextMenu::Create(controller_.get(), item, GetWmShelf());
58 return LauncherContextMenu::Create(controller_.get(), item, shelf);
59 } 65 }
60 66
61 ArcAppTest& arc_test() { return arc_test_; } 67 ArcAppTest& arc_test() { return arc_test_; }
62 68
63 Profile* profile() { return profile_.get(); } 69 Profile* profile() { return profile_.get(); }
64 70
65 ChromeLauncherController* controller() { return controller_.get(); } 71 ChromeLauncherController* controller() { return controller_.get(); }
66 72
67 private: 73 private:
68 std::unique_ptr<TestingProfile> profile_; 74 std::unique_ptr<TestingProfile> profile_;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // Verifies contextmenu items for Arc app 157 // Verifies contextmenu items for Arc app
152 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) { 158 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) {
153 arc_test().app_instance()->RefreshAppList(); 159 arc_test().app_instance()->RefreshAppList();
154 arc_test().app_instance()->SendRefreshAppList(arc_test().fake_apps()); 160 arc_test().app_instance()->SendRefreshAppList(arc_test().fake_apps());
155 const std::string app_id = ArcAppTest::GetAppId(arc_test().fake_apps()[0]); 161 const std::string app_id = ArcAppTest::GetAppId(arc_test().fake_apps()[0]);
156 162
157 controller()->PinAppWithID(app_id); 163 controller()->PinAppWithID(app_id);
158 164
159 ash::ShelfItem item; 165 ash::ShelfItem item;
160 item.id = controller()->GetShelfIDForAppID(app_id); 166 item.id = controller()->GetShelfIDForAppID(app_id);
161 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); 167 ash::WmShelf* wm_shelf = GetWmShelf();
162 168
163 std::unique_ptr<LauncherContextMenu> menu( 169 std::unique_ptr<LauncherContextMenu> menu(
164 new ArcLauncherContextMenu(controller(), &item, shelf)); 170 new ArcLauncherContextMenu(controller(), &item, wm_shelf));
165 171
166 // Arc app is pinned but not running. 172 // Arc app is pinned but not running.
167 EXPECT_TRUE( 173 EXPECT_TRUE(
168 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); 174 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW));
169 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_OPEN_NEW)); 175 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_OPEN_NEW));
170 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); 176 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN));
171 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); 177 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN));
172 EXPECT_FALSE( 178 EXPECT_FALSE(
173 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); 179 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE));
174 180
175 EXPECT_TRUE( 181 EXPECT_TRUE(
176 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); 182 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE));
177 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); 183 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE));
178 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), 184 EXPECT_TRUE(IsItemPresentInMenu(menu.get(),
179 LauncherContextMenu::MENU_ALIGNMENT_MENU)); 185 LauncherContextMenu::MENU_ALIGNMENT_MENU));
180 EXPECT_TRUE( 186 EXPECT_TRUE(
181 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); 187 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU));
182 // By default, screen is not locked and ChangeWallPaper item is added in 188 // By default, screen is not locked and ChangeWallPaper item is added in
183 // menu. ChangeWallPaper item is not enabled in default mode. 189 // menu. ChangeWallPaper item is not enabled in default mode.
184 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), 190 EXPECT_TRUE(IsItemPresentInMenu(menu.get(),
185 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); 191 LauncherContextMenu::MENU_CHANGE_WALLPAPER));
186 EXPECT_FALSE( 192 EXPECT_FALSE(
187 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); 193 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER));
188 194
189 // Arc app is running. 195 // Arc app is running.
190 arc_test().app_instance()->SendTaskCreated(1, arc_test().fake_apps()[0]); 196 arc_test().app_instance()->SendTaskCreated(1, arc_test().fake_apps()[0]);
191 menu.reset(new ArcLauncherContextMenu(controller(), &item, shelf)); 197 menu.reset(new ArcLauncherContextMenu(controller(), &item, wm_shelf));
192 198
193 EXPECT_FALSE( 199 EXPECT_FALSE(
194 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); 200 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW));
195 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); 201 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN));
196 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); 202 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN));
197 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); 203 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE));
198 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); 204 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE));
199 } 205 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/launcher_context_menu.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698