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

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

Issue 2052013002: Adding ChromeLauncherController interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome_launcher_smaller_api
Patch Set: Rebase Created 4 years, 6 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/common/shelf/shelf_item_types.h" 7 #include "ash/common/shelf/shelf_item_types.h"
8 #include "ash/common/shelf/shelf_model.h" 8 #include "ash/common/shelf/shelf_model.h"
9 #include "ash/common/wm_root_window_controller.h" 9 #include "ash/common/wm_root_window_controller.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
11 #include "ash/common/wm_window.h" 11 #include "ash/common/wm_window.h"
12 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/prefs/incognito_mode_prefs.h" 15 #include "chrome/browser/prefs/incognito_mode_prefs.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" 17 #include "chrome/browser/ui/app_list/arc/arc_app_test.h"
18 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" 18 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h"
19 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" 19 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h"
20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
21 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" 21 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h"
22 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" 22 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h"
23 #include "chrome/test/base/testing_profile.h" 23 #include "chrome/test/base/testing_profile.h"
24 #include "components/arc/test/fake_app_instance.h" 24 #include "components/arc/test/fake_app_instance.h"
25 #include "components/prefs/pref_service.h" 25 #include "components/prefs/pref_service.h"
26 #include "ui/aura/window_event_dispatcher.h" 26 #include "ui/aura/window_event_dispatcher.h"
27 27
28 class LauncherContextMenuTest : public ash::test::AshTestBase { 28 class LauncherContextMenuTest : public ash::test::AshTestBase {
29 protected: 29 protected:
30 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { 30 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) {
31 return menu->GetIndexOfCommandId(command_id) != -1; 31 return menu->GetIndexOfCommandId(command_id) != -1;
32 } 32 }
33 33
34 LauncherContextMenuTest() : profile_(new TestingProfile()) {} 34 LauncherContextMenuTest() : profile_(new TestingProfile()) {}
35 35
36 void SetUp() override { 36 void SetUp() override {
37 arc_test_.SetUp(profile_.get()); 37 arc_test_.SetUp(profile_.get());
38 ash::test::AshTestBase::SetUp(); 38 ash::test::AshTestBase::SetUp();
39 controller_.reset(new ChromeLauncherController(profile(), &shelf_model_)); 39 controller_.reset(
40 new ChromeLauncherControllerImpl(profile(), &shelf_model_));
40 } 41 }
41 42
42 void TearDown() override { 43 void TearDown() override {
43 controller_.reset(nullptr); 44 controller_.reset(nullptr);
44 ash::test::AshTestBase::TearDown(); 45 ash::test::AshTestBase::TearDown();
45 } 46 }
46 47
47 ash::WmShelf* GetWmShelf() { 48 ash::WmShelf* GetWmShelf() {
48 return ash::WmShell::Get() 49 return ash::WmShell::Get()
49 ->GetPrimaryRootWindow() 50 ->GetPrimaryRootWindow()
(...skipping 11 matching lines...) Expand all
61 62
62 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell() { 63 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell() {
63 ash::ShelfItem* item = nullptr; 64 ash::ShelfItem* item = nullptr;
64 return LauncherContextMenu::Create(controller_.get(), item, GetWmShelf()); 65 return LauncherContextMenu::Create(controller_.get(), item, GetWmShelf());
65 } 66 }
66 67
67 ArcAppTest& arc_test() { return arc_test_; } 68 ArcAppTest& arc_test() { return arc_test_; }
68 69
69 Profile* profile() { return profile_.get(); } 70 Profile* profile() { return profile_.get(); }
70 71
71 ChromeLauncherController* controller() { return controller_.get(); } 72 ChromeLauncherControllerImpl* controller() { return controller_.get(); }
72 73
73 private: 74 private:
74 std::unique_ptr<TestingProfile> profile_; 75 std::unique_ptr<TestingProfile> profile_;
75 ash::ShelfModel shelf_model_; 76 ash::ShelfModel shelf_model_;
76 std::unique_ptr<ChromeLauncherController> controller_; 77 std::unique_ptr<ChromeLauncherControllerImpl> controller_;
77 ArcAppTest arc_test_; 78 ArcAppTest arc_test_;
78 79
79 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); 80 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest);
80 }; 81 };
81 82
82 // Verifies that "New Incognito window" menu item in the launcher context 83 // Verifies that "New Incognito window" menu item in the launcher context
83 // menu is disabled when Incognito mode is switched off (by a policy). 84 // menu is disabled when Incognito mode is switched off (by a policy).
84 TEST_F(LauncherContextMenuTest, 85 TEST_F(LauncherContextMenuTest,
85 NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff) { 86 NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff) {
86 // Initially, "New Incognito window" should be enabled. 87 // Initially, "New Incognito window" should be enabled.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 arc_test().app_instance()->SendTaskCreated(1, arc_test().fake_apps()[0]); 197 arc_test().app_instance()->SendTaskCreated(1, arc_test().fake_apps()[0]);
197 menu.reset(new ArcLauncherContextMenu(controller(), &item, wm_shelf)); 198 menu.reset(new ArcLauncherContextMenu(controller(), &item, wm_shelf));
198 199
199 EXPECT_FALSE( 200 EXPECT_FALSE(
200 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); 201 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW));
201 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); 202 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN));
202 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); 203 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN));
203 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); 204 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE));
204 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); 205 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE));
205 } 206 }
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