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

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

Issue 1869063002: Arc integration in shelf launcher context menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Include file only when necessary Created 4 years, 8 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') | chrome/chrome_browser_ui.gypi » ('j') | 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/shelf/shelf.h" 7 #include "ash/shelf/shelf.h"
8 #include "ash/shelf/shelf_item_types.h" 8 #include "ash/shelf/shelf_item_types.h"
9 #include "ash/shelf/shelf_model.h" 9 #include "ash/shelf/shelf_model.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "chrome/app/chrome_command_ids.h" 13 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/prefs/incognito_mode_prefs.h" 14 #include "chrome/browser/prefs/incognito_mode_prefs.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
17 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" 17 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h"
18 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" 18 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h"
19 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
20 #include "components/prefs/pref_service.h" 20 #include "components/prefs/pref_service.h"
21 #include "ui/aura/window_event_dispatcher.h" 21 #include "ui/aura/window_event_dispatcher.h"
22 22
23 #if defined(OS_CHROMEOS)
24 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h"
25 #endif // defined(OS_CHROMEOS)
26
23 class LauncherContextMenuTest : public ash::test::AshTestBase { 27 class LauncherContextMenuTest : public ash::test::AshTestBase {
24 protected: 28 protected:
25 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { 29 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) {
26 return menu->GetIndexOfCommandId(command_id) != -1; 30 return menu->GetIndexOfCommandId(command_id) != -1;
27 } 31 }
28 32
29 LauncherContextMenuTest() : profile_(new TestingProfile()) {} 33 LauncherContextMenuTest() : profile_(new TestingProfile()) {}
30 34
31 void SetUp() override { 35 void SetUp() override {
32 ash::test::AshTestBase::SetUp(); 36 ash::test::AshTestBase::SetUp();
(...skipping 13 matching lines...) Expand all
46 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); 50 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext());
47 return LauncherContextMenu::Create(controller_.get(), &item, shelf); 51 return LauncherContextMenu::Create(controller_.get(), &item, shelf);
48 } 52 }
49 53
50 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell() { 54 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell() {
51 ash::ShelfItem* item = nullptr; 55 ash::ShelfItem* item = nullptr;
52 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); 56 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext());
53 return LauncherContextMenu::Create(controller_.get(), item, shelf); 57 return LauncherContextMenu::Create(controller_.get(), item, shelf);
54 } 58 }
55 59
60 #if defined(OS_CHROMEOS)
61 LauncherContextMenu* CreateLauncherContextMenuForArcApp() {
62 ash::ShelfItem item;
63 item.id = 1; // dummy id
64 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext());
65 return new ArcLauncherContextMenu(controller_.get(), &item, shelf);
66 }
67 #endif
68
56 Profile* profile() { return profile_.get(); } 69 Profile* profile() { return profile_.get(); }
57 70
58 private: 71 private:
59 scoped_ptr<TestingProfile> profile_; 72 scoped_ptr<TestingProfile> profile_;
60 ash::ShelfModel shelf_model_; 73 ash::ShelfModel shelf_model_;
61 scoped_ptr<ChromeLauncherController> controller_; 74 scoped_ptr<ChromeLauncherController> controller_;
62 75
63 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); 76 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest);
64 }; 77 };
65 78
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); 135 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU));
123 #if defined(OS_CHROMEOS) 136 #if defined(OS_CHROMEOS)
124 // By default, screen is not locked and ChangeWallPaper item is added in 137 // By default, screen is not locked and ChangeWallPaper item is added in
125 // menu. ChangeWallPaper item is not enabled in default mode. 138 // menu. ChangeWallPaper item is not enabled in default mode.
126 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), 139 EXPECT_TRUE(IsItemPresentInMenu(menu.get(),
127 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); 140 LauncherContextMenu::MENU_CHANGE_WALLPAPER));
128 EXPECT_FALSE( 141 EXPECT_FALSE(
129 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); 142 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER));
130 #endif 143 #endif
131 } 144 }
145
146 // Verifies contextmenu items for Arc app
147 #if defined(OS_CHROMEOS)
148 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) {
149 scoped_ptr<LauncherContextMenu> menu(CreateLauncherContextMenuForArcApp());
150 EXPECT_TRUE(
151 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW));
152 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_OPEN_NEW));
153 EXPECT_TRUE(
154 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE));
155 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE));
156 EXPECT_TRUE(IsItemPresentInMenu(menu.get(),
157 LauncherContextMenu::MENU_ALIGNMENT_MENU));
158 EXPECT_TRUE(
159 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU));
160 // By default, screen is not locked and ChangeWallPaper item is added in
161 // menu. ChangeWallPaper item is not enabled in default mode.
162 EXPECT_TRUE(IsItemPresentInMenu(menu.get(),
163 LauncherContextMenu::MENU_CHANGE_WALLPAPER));
164 EXPECT_FALSE(
165 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER));
166 }
167 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/launcher_context_menu.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698