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

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

Issue 2700783002: s/\bArc\b/ARC/g for ARC related code. (Closed)
Patch Set: Address ARC++ Created 3 years, 10 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) 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 <memory> 7 #include <memory>
8 8
9 #include "ash/common/shelf/shelf_item_types.h" 9 #include "ash/common/shelf/shelf_item_types.h"
10 #include "ash/common/wm_lookup.h" 10 #include "ash/common/wm_lookup.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 item.type = shelf_item_type; 72 item.type = shelf_item_type;
73 return LauncherContextMenu::Create(controller_.get(), &item, wm_shelf); 73 return LauncherContextMenu::Create(controller_.get(), &item, wm_shelf);
74 } 74 }
75 75
76 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell( 76 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell(
77 ash::WmShelf* wm_shelf) { 77 ash::WmShelf* wm_shelf) {
78 ash::ShelfItem* item = nullptr; 78 ash::ShelfItem* item = nullptr;
79 return LauncherContextMenu::Create(controller_.get(), item, wm_shelf); 79 return LauncherContextMenu::Create(controller_.get(), item, wm_shelf);
80 } 80 }
81 81
82 // Creates app window and set optional Arc application id. 82 // Creates app window and set optional ARC application id.
83 views::Widget* CreateArcWindow(std::string& window_app_id) { 83 views::Widget* CreateArcWindow(std::string& window_app_id) {
84 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 84 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
85 views::Widget* widget = new views::Widget(); 85 views::Widget* widget = new views::Widget();
86 widget->Init(params); 86 widget->Init(params);
87 widget->Show(); 87 widget->Show();
88 widget->Activate(); 88 widget->Activate();
89 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(), 89 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(),
90 window_app_id); 90 window_app_id);
91 return widget; 91 return widget;
92 } 92 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // opened. 180 // opened.
181 TEST_F(LauncherContextMenuTest, 181 TEST_F(LauncherContextMenuTest,
182 DesktopShellLauncherContextMenuVerifyCloseItem) { 182 DesktopShellLauncherContextMenuVerifyCloseItem) {
183 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 183 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
184 std::unique_ptr<LauncherContextMenu> menu(CreateLauncherContextMenu( 184 std::unique_ptr<LauncherContextMenu> menu(CreateLauncherContextMenu(
185 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); 185 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id)));
186 ASSERT_FALSE( 186 ASSERT_FALSE(
187 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); 187 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE));
188 } 188 }
189 189
190 // Verifies contextmenu items for Arc app 190 // Verifies contextmenu items for ARC app
191 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) { 191 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) {
192 arc_test().app_instance()->RefreshAppList(); 192 arc_test().app_instance()->RefreshAppList();
193 arc_test().app_instance()->SendRefreshAppList( 193 arc_test().app_instance()->SendRefreshAppList(
194 std::vector<arc::mojom::AppInfo>(arc_test().fake_apps().begin(), 194 std::vector<arc::mojom::AppInfo>(arc_test().fake_apps().begin(),
195 arc_test().fake_apps().begin() + 1)); 195 arc_test().fake_apps().begin() + 1));
196 const std::string app_id = ArcAppTest::GetAppId(arc_test().fake_apps()[0]); 196 const std::string app_id = ArcAppTest::GetAppId(arc_test().fake_apps()[0]);
197 197
198 controller()->PinAppWithID(app_id); 198 controller()->PinAppWithID(app_id);
199 199
200 const ash::ShelfID item_id = controller()->GetShelfIDForAppID(app_id); 200 const ash::ShelfID item_id = controller()->GetShelfIDForAppID(app_id);
201 const ash::ShelfItem* item = controller()->GetItem(item_id); 201 const ash::ShelfItem* item = controller()->GetItem(item_id);
202 ASSERT_TRUE(item); 202 ASSERT_TRUE(item);
203 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 203 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
204 ash::WmShelf* wm_shelf = GetWmShelf(primary_id); 204 ash::WmShelf* wm_shelf = GetWmShelf(primary_id);
205 205
206 std::unique_ptr<LauncherContextMenu> menu( 206 std::unique_ptr<LauncherContextMenu> menu(
207 new ArcLauncherContextMenu(controller(), item, wm_shelf)); 207 new ArcLauncherContextMenu(controller(), item, wm_shelf));
208 208
209 // Arc app is pinned but not running. 209 // ARC app is pinned but not running.
210 EXPECT_TRUE( 210 EXPECT_TRUE(
211 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); 211 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW));
212 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_OPEN_NEW)); 212 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_OPEN_NEW));
213 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); 213 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN));
214 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); 214 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN));
215 EXPECT_FALSE( 215 EXPECT_FALSE(
216 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); 216 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE));
217 217
218 EXPECT_TRUE( 218 EXPECT_TRUE(
219 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); 219 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE));
220 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); 220 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE));
221 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), 221 EXPECT_TRUE(IsItemPresentInMenu(menu.get(),
222 LauncherContextMenu::MENU_ALIGNMENT_MENU)); 222 LauncherContextMenu::MENU_ALIGNMENT_MENU));
223 EXPECT_TRUE( 223 EXPECT_TRUE(
224 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); 224 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU));
225 // By default, screen is not locked and ChangeWallPaper item is added in 225 // By default, screen is not locked and ChangeWallPaper item is added in
226 // menu. ChangeWallPaper item is not enabled in default mode. 226 // menu. ChangeWallPaper item is not enabled in default mode.
227 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), 227 EXPECT_TRUE(IsItemPresentInMenu(menu.get(),
228 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); 228 LauncherContextMenu::MENU_CHANGE_WALLPAPER));
229 EXPECT_FALSE( 229 EXPECT_FALSE(
230 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); 230 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER));
231 231
232 // Arc app is running. 232 // ARC app is running.
233 std::string window_app_id1("org.chromium.arc.1"); 233 std::string window_app_id1("org.chromium.arc.1");
234 CreateArcWindow(window_app_id1); 234 CreateArcWindow(window_app_id1);
235 arc_test().app_instance()->SendTaskCreated(1, arc_test().fake_apps()[0], 235 arc_test().app_instance()->SendTaskCreated(1, arc_test().fake_apps()[0],
236 std::string()); 236 std::string());
237 menu.reset(new ArcLauncherContextMenu(controller(), item, wm_shelf)); 237 menu.reset(new ArcLauncherContextMenu(controller(), item, wm_shelf));
238 238
239 EXPECT_FALSE( 239 EXPECT_FALSE(
240 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); 240 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW));
241 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); 241 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN));
242 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); 242 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN));
243 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); 243 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE));
244 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); 244 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE));
245 245
246 // Arc non-launchable app is running. 246 // ARC non-launchable app is running.
247 const std::string app_id2 = ArcAppTest::GetAppId(arc_test().fake_apps()[1]); 247 const std::string app_id2 = ArcAppTest::GetAppId(arc_test().fake_apps()[1]);
248 std::string window_app_id2("org.chromium.arc.2"); 248 std::string window_app_id2("org.chromium.arc.2");
249 CreateArcWindow(window_app_id2); 249 CreateArcWindow(window_app_id2);
250 arc_test().app_instance()->SendTaskCreated(2, arc_test().fake_apps()[1], 250 arc_test().app_instance()->SendTaskCreated(2, arc_test().fake_apps()[1],
251 std::string()); 251 std::string());
252 const ash::ShelfID item_id2 = controller()->GetShelfIDForAppID(app_id2); 252 const ash::ShelfID item_id2 = controller()->GetShelfIDForAppID(app_id2);
253 const ash::ShelfItem* item2 = controller()->GetItem(item_id2); 253 const ash::ShelfItem* item2 = controller()->GetItem(item_id2);
254 ASSERT_TRUE(item2); 254 ASSERT_TRUE(item2);
255 menu.reset(new ArcLauncherContextMenu(controller(), item2, wm_shelf)); 255 menu.reset(new ArcLauncherContextMenu(controller(), item2, wm_shelf));
256 256
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 widget->SetFullscreen(true); 302 widget->SetFullscreen(true);
303 std::unique_ptr<LauncherContextMenu> primary_menu(CreateLauncherContextMenu( 303 std::unique_ptr<LauncherContextMenu> primary_menu(CreateLauncherContextMenu(
304 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); 304 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id)));
305 std::unique_ptr<LauncherContextMenu> secondary_menu(CreateLauncherContextMenu( 305 std::unique_ptr<LauncherContextMenu> secondary_menu(CreateLauncherContextMenu(
306 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(secondary_id))); 306 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(secondary_id)));
307 EXPECT_FALSE(IsItemPresentInMenu(primary_menu.get(), 307 EXPECT_FALSE(IsItemPresentInMenu(primary_menu.get(),
308 LauncherContextMenu::MENU_AUTO_HIDE)); 308 LauncherContextMenu::MENU_AUTO_HIDE));
309 EXPECT_TRUE(IsItemPresentInMenu(secondary_menu.get(), 309 EXPECT_TRUE(IsItemPresentInMenu(secondary_menu.get(),
310 LauncherContextMenu::MENU_AUTO_HIDE)); 310 LauncherContextMenu::MENU_AUTO_HIDE));
311 } 311 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/launcher_context_menu.cc ('k') | chrome/browser/ui/ash/launcher/launcher_controller_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698