| 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 <memory> |
| 8 |
| 7 #include "ash/common/shelf/shelf_item_types.h" | 9 #include "ash/common/shelf/shelf_item_types.h" |
| 8 #include "ash/common/wm_lookup.h" | 10 #include "ash/common/wm_lookup.h" |
| 9 #include "ash/common/wm_root_window_controller.h" | 11 #include "ash/common/wm_root_window_controller.h" |
| 10 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
| 11 #include "ash/common/wm_window.h" | 13 #include "ash/common/wm_window.h" |
| 12 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 13 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
| 14 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" |
| 15 #include "chrome/app/chrome_command_ids.h" | 18 #include "chrome/app/chrome_command_ids.h" |
| 16 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 19 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" | 21 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" |
| 19 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" | 22 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" |
| 20 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" | 23 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" |
| 21 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" | 24 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" |
| 22 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 25 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 23 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" | 26 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" |
| 24 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" | 27 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" |
| 25 #include "chrome/test/base/testing_profile.h" | 28 #include "chrome/test/base/testing_profile.h" |
| 26 #include "components/arc/test/fake_app_instance.h" | 29 #include "components/arc/test/fake_app_instance.h" |
| 27 #include "components/exo/shell_surface.h" | 30 #include "components/exo/shell_surface.h" |
| 28 #include "components/prefs/pref_service.h" | 31 #include "components/prefs/pref_service.h" |
| 32 #include "components/session_manager/core/session_manager.h" |
| 29 #include "ui/aura/window_event_dispatcher.h" | 33 #include "ui/aura/window_event_dispatcher.h" |
| 30 #include "ui/display/display.h" | 34 #include "ui/display/display.h" |
| 31 #include "ui/display/screen.h" | 35 #include "ui/display/screen.h" |
| 32 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
| 33 | 37 |
| 34 class LauncherContextMenuTest : public ash::test::AshTestBase { | 38 class LauncherContextMenuTest : public ash::test::AshTestBase { |
| 35 protected: | 39 protected: |
| 36 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { | 40 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { |
| 37 return menu->GetIndexOfCommandId(command_id) != -1; | 41 return menu->GetIndexOfCommandId(command_id) != -1; |
| 38 } | 42 } |
| 39 | 43 |
| 40 LauncherContextMenuTest() : profile_(new TestingProfile()) {} | 44 LauncherContextMenuTest() : profile_(new TestingProfile()) {} |
| 41 | 45 |
| 42 void SetUp() override { | 46 void SetUp() override { |
| 43 arc_test_.SetUp(profile_.get()); | 47 arc_test_.SetUp(profile_.get()); |
| 48 session_manager_ = base::MakeUnique<session_manager::SessionManager>(); |
| 44 ash::test::AshTestBase::SetUp(); | 49 ash::test::AshTestBase::SetUp(); |
| 45 controller_.reset(new ChromeLauncherControllerImpl( | 50 controller_.reset(new ChromeLauncherControllerImpl( |
| 46 profile(), ash::WmShell::Get()->shelf_model())); | 51 profile(), ash::WmShell::Get()->shelf_model())); |
| 47 controller_->Init(); | 52 controller_->Init(); |
| 48 } | 53 } |
| 49 | 54 |
| 50 void TearDown() override { | 55 void TearDown() override { |
| 51 controller_.reset(nullptr); | 56 controller_.reset(nullptr); |
| 52 ash::test::AshTestBase::TearDown(); | 57 ash::test::AshTestBase::TearDown(); |
| 53 } | 58 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 ArcAppTest& arc_test() { return arc_test_; } | 94 ArcAppTest& arc_test() { return arc_test_; } |
| 90 | 95 |
| 91 Profile* profile() { return profile_.get(); } | 96 Profile* profile() { return profile_.get(); } |
| 92 | 97 |
| 93 ChromeLauncherControllerImpl* controller() { return controller_.get(); } | 98 ChromeLauncherControllerImpl* controller() { return controller_.get(); } |
| 94 | 99 |
| 95 private: | 100 private: |
| 96 std::unique_ptr<TestingProfile> profile_; | 101 std::unique_ptr<TestingProfile> profile_; |
| 97 std::unique_ptr<ChromeLauncherControllerImpl> controller_; | 102 std::unique_ptr<ChromeLauncherControllerImpl> controller_; |
| 98 ArcAppTest arc_test_; | 103 ArcAppTest arc_test_; |
| 104 std::unique_ptr<session_manager::SessionManager> session_manager_; |
| 99 | 105 |
| 100 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); | 106 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); |
| 101 }; | 107 }; |
| 102 | 108 |
| 103 // Verifies that "New Incognito window" menu item in the launcher context | 109 // Verifies that "New Incognito window" menu item in the launcher context |
| 104 // menu is disabled when Incognito mode is switched off (by a policy). | 110 // menu is disabled when Incognito mode is switched off (by a policy). |
| 105 TEST_F(LauncherContextMenuTest, | 111 TEST_F(LauncherContextMenuTest, |
| 106 NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff) { | 112 NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff) { |
| 107 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 113 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 108 // Initially, "New Incognito window" should be enabled. | 114 // Initially, "New Incognito window" should be enabled. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 widget->SetFullscreen(true); | 305 widget->SetFullscreen(true); |
| 300 std::unique_ptr<LauncherContextMenu> primary_menu(CreateLauncherContextMenu( | 306 std::unique_ptr<LauncherContextMenu> primary_menu(CreateLauncherContextMenu( |
| 301 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); | 307 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); |
| 302 std::unique_ptr<LauncherContextMenu> secondary_menu(CreateLauncherContextMenu( | 308 std::unique_ptr<LauncherContextMenu> secondary_menu(CreateLauncherContextMenu( |
| 303 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(secondary_id))); | 309 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(secondary_id))); |
| 304 EXPECT_FALSE(IsItemPresentInMenu(primary_menu.get(), | 310 EXPECT_FALSE(IsItemPresentInMenu(primary_menu.get(), |
| 305 LauncherContextMenu::MENU_AUTO_HIDE)); | 311 LauncherContextMenu::MENU_AUTO_HIDE)); |
| 306 EXPECT_TRUE(IsItemPresentInMenu(secondary_menu.get(), | 312 EXPECT_TRUE(IsItemPresentInMenu(secondary_menu.get(), |
| 307 LauncherContextMenu::MENU_AUTO_HIDE)); | 313 LauncherContextMenu::MENU_AUTO_HIDE)); |
| 308 } | 314 } |
| OLD | NEW |