| OLD | NEW |
| 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/arc_launcher_context_menu.h" |
| 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 17 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" | 18 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" |
| 18 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" | 19 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 20 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
| 21 #include "ui/aura/window_event_dispatcher.h" | 22 #include "ui/aura/window_event_dispatcher.h" |
| 22 | 23 |
| 23 #if defined(OS_CHROMEOS) | |
| 24 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" | |
| 25 #endif // defined(OS_CHROMEOS) | |
| 26 | |
| 27 class LauncherContextMenuTest : public ash::test::AshTestBase { | 24 class LauncherContextMenuTest : public ash::test::AshTestBase { |
| 28 protected: | 25 protected: |
| 29 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { | 26 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { |
| 30 return menu->GetIndexOfCommandId(command_id) != -1; | 27 return menu->GetIndexOfCommandId(command_id) != -1; |
| 31 } | 28 } |
| 32 | 29 |
| 33 LauncherContextMenuTest() : profile_(new TestingProfile()) {} | 30 LauncherContextMenuTest() : profile_(new TestingProfile()) {} |
| 34 | 31 |
| 35 void SetUp() override { | 32 void SetUp() override { |
| 36 ash::test::AshTestBase::SetUp(); | 33 ash::test::AshTestBase::SetUp(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 50 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); | 47 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); |
| 51 return LauncherContextMenu::Create(controller_.get(), &item, shelf); | 48 return LauncherContextMenu::Create(controller_.get(), &item, shelf); |
| 52 } | 49 } |
| 53 | 50 |
| 54 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell() { | 51 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell() { |
| 55 ash::ShelfItem* item = nullptr; | 52 ash::ShelfItem* item = nullptr; |
| 56 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); | 53 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); |
| 57 return LauncherContextMenu::Create(controller_.get(), item, shelf); | 54 return LauncherContextMenu::Create(controller_.get(), item, shelf); |
| 58 } | 55 } |
| 59 | 56 |
| 60 #if defined(OS_CHROMEOS) | |
| 61 LauncherContextMenu* CreateLauncherContextMenuForArcApp() { | 57 LauncherContextMenu* CreateLauncherContextMenuForArcApp() { |
| 62 ash::ShelfItem item; | 58 ash::ShelfItem item; |
| 63 item.id = 1; // dummy id | 59 item.id = 1; // dummy id |
| 64 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); | 60 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); |
| 65 return new ArcLauncherContextMenu(controller_.get(), &item, shelf); | 61 return new ArcLauncherContextMenu(controller_.get(), &item, shelf); |
| 66 } | 62 } |
| 67 #endif | |
| 68 | 63 |
| 69 Profile* profile() { return profile_.get(); } | 64 Profile* profile() { return profile_.get(); } |
| 70 | 65 |
| 71 private: | 66 private: |
| 72 std::unique_ptr<TestingProfile> profile_; | 67 std::unique_ptr<TestingProfile> profile_; |
| 73 ash::ShelfModel shelf_model_; | 68 ash::ShelfModel shelf_model_; |
| 74 std::unique_ptr<ChromeLauncherController> controller_; | 69 std::unique_ptr<ChromeLauncherController> controller_; |
| 75 | 70 |
| 76 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); | 71 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); |
| 77 }; | 72 }; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 EXPECT_FALSE( | 121 EXPECT_FALSE( |
| 127 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 122 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
| 128 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 123 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
| 129 EXPECT_TRUE( | 124 EXPECT_TRUE( |
| 130 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); | 125 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); |
| 131 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); | 126 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); |
| 132 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | 127 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), |
| 133 LauncherContextMenu::MENU_ALIGNMENT_MENU)); | 128 LauncherContextMenu::MENU_ALIGNMENT_MENU)); |
| 134 EXPECT_TRUE( | 129 EXPECT_TRUE( |
| 135 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); | 130 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); |
| 136 #if defined(OS_CHROMEOS) | |
| 137 // By default, screen is not locked and ChangeWallPaper item is added in | 131 // By default, screen is not locked and ChangeWallPaper item is added in |
| 138 // menu. ChangeWallPaper item is not enabled in default mode. | 132 // menu. ChangeWallPaper item is not enabled in default mode. |
| 139 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | 133 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), |
| 140 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | 134 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); |
| 141 EXPECT_FALSE( | 135 EXPECT_FALSE( |
| 142 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | 136 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); |
| 143 #endif | |
| 144 } | 137 } |
| 145 | 138 |
| 146 // Verifies contextmenu items for Arc app | 139 // Verifies contextmenu items for Arc app |
| 147 #if defined(OS_CHROMEOS) | |
| 148 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) { | 140 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) { |
| 149 std::unique_ptr<LauncherContextMenu> menu( | 141 std::unique_ptr<LauncherContextMenu> menu( |
| 150 CreateLauncherContextMenuForArcApp()); | 142 CreateLauncherContextMenuForArcApp()); |
| 151 EXPECT_TRUE( | 143 EXPECT_TRUE( |
| 152 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 144 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
| 153 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_OPEN_NEW)); | 145 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_OPEN_NEW)); |
| 154 EXPECT_TRUE( | 146 EXPECT_TRUE( |
| 155 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); | 147 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); |
| 156 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); | 148 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); |
| 157 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | 149 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), |
| 158 LauncherContextMenu::MENU_ALIGNMENT_MENU)); | 150 LauncherContextMenu::MENU_ALIGNMENT_MENU)); |
| 159 EXPECT_TRUE( | 151 EXPECT_TRUE( |
| 160 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); | 152 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); |
| 161 // By default, screen is not locked and ChangeWallPaper item is added in | 153 // By default, screen is not locked and ChangeWallPaper item is added in |
| 162 // menu. ChangeWallPaper item is not enabled in default mode. | 154 // menu. ChangeWallPaper item is not enabled in default mode. |
| 163 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | 155 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), |
| 164 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | 156 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); |
| 165 EXPECT_FALSE( | 157 EXPECT_FALSE( |
| 166 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | 158 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); |
| 167 } | 159 } |
| 168 #endif | |
| OLD | NEW |