| 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> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/public/cpp/shelf_item.h" | 9 #include "ash/public/cpp/shelf_item.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/test/ash_test_helper.h" | 13 #include "ash/test/ash_test_helper.h" |
| 14 #include "ash/test/shell_test_api.h" | 14 #include "ash/test/shell_test_api.h" |
| 15 #include "ash/test/test_shell_delegate.h" | 15 #include "ash/test/test_shell_delegate.h" |
| 16 #include "ash/wm_window.h" | 16 #include "ash/wm_window.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 19 #include "chrome/app/chrome_command_ids.h" | 19 #include "chrome/app/chrome_command_ids.h" |
| 20 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 20 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" | 22 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" |
| 23 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" | 23 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" |
| 24 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" | 24 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" |
| 25 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" | 25 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" |
| 26 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 26 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 27 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" | 27 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" |
| 28 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" | 28 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" |
| 29 #include "chrome/test/base/testing_profile.h" | 29 #include "chrome/test/base/testing_profile.h" |
| 30 #include "components/arc/test/fake_app_instance.h" | 30 #include "components/arc/test/fake_app_instance.h" |
| 31 #include "components/exo/shell_surface.h" | 31 #include "components/exo/shell_surface.h" |
| 32 #include "components/prefs/pref_service.h" | 32 #include "components/prefs/pref_service.h" |
| 33 #include "components/session_manager/core/session_manager.h" | 33 #include "components/session_manager/core/session_manager.h" |
| 34 #include "ui/aura/window_event_dispatcher.h" | 34 #include "ui/aura/window_event_dispatcher.h" |
| 35 #include "ui/display/display.h" | 35 #include "ui/display/display.h" |
| 36 #include "ui/display/screen.h" | 36 #include "ui/display/screen.h" |
| 37 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
| 38 | 38 |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| 41 // A shell delegate that owns a ChromeLauncherController, like production. | 41 // A shell delegate that owns a ChromeLauncherController, like production. |
| 42 class ChromeLauncherTestShellDelegate : public ash::test::TestShellDelegate { | 42 class ChromeLauncherTestShellDelegate : public ash::test::TestShellDelegate { |
| 43 public: | 43 public: |
| 44 explicit ChromeLauncherTestShellDelegate(Profile* profile) | 44 explicit ChromeLauncherTestShellDelegate(Profile* profile) |
| 45 : profile_(profile) {} | 45 : profile_(profile) {} |
| 46 | 46 |
| 47 ChromeLauncherControllerImpl* controller() { return controller_.get(); } | 47 ChromeLauncherController* controller() { return controller_.get(); } |
| 48 | 48 |
| 49 // ash::test::TestShellDelegate: | 49 // ash::test::TestShellDelegate: |
| 50 void ShelfInit() override { | 50 void ShelfInit() override { |
| 51 if (!controller_) { | 51 if (!controller_) { |
| 52 controller_ = base::MakeUnique<ChromeLauncherControllerImpl>( | 52 controller_ = base::MakeUnique<ChromeLauncherController>( |
| 53 profile_, ash::Shell::Get()->shelf_model()); | 53 profile_, ash::Shell::Get()->shelf_model()); |
| 54 controller_->Init(); | 54 controller_->Init(); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 void ShelfShutdown() override { controller_.reset(); } | 57 void ShelfShutdown() override { controller_.reset(); } |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 Profile* profile_; | 60 Profile* profile_; |
| 61 std::unique_ptr<ChromeLauncherControllerImpl> controller_; | 61 std::unique_ptr<ChromeLauncherController> controller_; |
| 62 | 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherTestShellDelegate); | 63 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherTestShellDelegate); |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 class LauncherContextMenuTest : public ash::test::AshTestBase { | 66 class LauncherContextMenuTest : public ash::test::AshTestBase { |
| 67 protected: | 67 protected: |
| 68 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { | 68 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { |
| 69 return menu->GetIndexOfCommandId(command_id) != -1; | 69 return menu->GetIndexOfCommandId(command_id) != -1; |
| 70 } | 70 } |
| 71 | 71 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 widget->Activate(); | 109 widget->Activate(); |
| 110 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(), | 110 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(), |
| 111 window_app_id); | 111 window_app_id); |
| 112 return widget; | 112 return widget; |
| 113 } | 113 } |
| 114 | 114 |
| 115 ArcAppTest& arc_test() { return arc_test_; } | 115 ArcAppTest& arc_test() { return arc_test_; } |
| 116 | 116 |
| 117 Profile* profile() { return &profile_; } | 117 Profile* profile() { return &profile_; } |
| 118 | 118 |
| 119 ChromeLauncherControllerImpl* controller() { | 119 ChromeLauncherController* controller() { |
| 120 return shell_delegate_->controller(); | 120 return shell_delegate_->controller(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 TestingProfile profile_; | 124 TestingProfile profile_; |
| 125 ChromeLauncherTestShellDelegate* shell_delegate_ = nullptr; | 125 ChromeLauncherTestShellDelegate* shell_delegate_ = nullptr; |
| 126 ArcAppTest arc_test_; | 126 ArcAppTest arc_test_; |
| 127 std::unique_ptr<session_manager::SessionManager> session_manager_; | 127 std::unique_ptr<session_manager::SessionManager> session_manager_; |
| 128 | 128 |
| 129 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); | 129 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); | 327 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); |
| 328 std::unique_ptr<LauncherContextMenu> secondary_menu(CreateLauncherContextMenu( | 328 std::unique_ptr<LauncherContextMenu> secondary_menu(CreateLauncherContextMenu( |
| 329 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(secondary_id))); | 329 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(secondary_id))); |
| 330 EXPECT_FALSE(IsItemPresentInMenu(primary_menu.get(), | 330 EXPECT_FALSE(IsItemPresentInMenu(primary_menu.get(), |
| 331 LauncherContextMenu::MENU_AUTO_HIDE)); | 331 LauncherContextMenu::MENU_AUTO_HIDE)); |
| 332 EXPECT_TRUE(IsItemPresentInMenu(secondary_menu.get(), | 332 EXPECT_TRUE(IsItemPresentInMenu(secondary_menu.get(), |
| 333 LauncherContextMenu::MENU_AUTO_HIDE)); | 333 LauncherContextMenu::MENU_AUTO_HIDE)); |
| 334 } | 334 } |
| 335 | 335 |
| 336 } // namespace | 336 } // namespace |
| OLD | NEW |