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

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

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
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"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 ash::ShelfItem item; 62 ash::ShelfItem item;
63 item.id = 1; // dummy id 63 item.id = 1; // dummy id
64 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); 64 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext());
65 return new ArcLauncherContextMenu(controller_.get(), &item, shelf); 65 return new ArcLauncherContextMenu(controller_.get(), &item, shelf);
66 } 66 }
67 #endif 67 #endif
68 68
69 Profile* profile() { return profile_.get(); } 69 Profile* profile() { return profile_.get(); }
70 70
71 private: 71 private:
72 scoped_ptr<TestingProfile> profile_; 72 std::unique_ptr<TestingProfile> profile_;
73 ash::ShelfModel shelf_model_; 73 ash::ShelfModel shelf_model_;
74 scoped_ptr<ChromeLauncherController> controller_; 74 std::unique_ptr<ChromeLauncherController> controller_;
75 75
76 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); 76 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest);
77 }; 77 };
78 78
79 // Verifies that "New Incognito window" menu item in the launcher context 79 // Verifies that "New Incognito window" menu item in the launcher context
80 // menu is disabled when Incognito mode is switched off (by a policy). 80 // menu is disabled when Incognito mode is switched off (by a policy).
81 TEST_F(LauncherContextMenuTest, 81 TEST_F(LauncherContextMenuTest,
82 NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff) { 82 NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff) {
83 // Initially, "New Incognito window" should be enabled. 83 // Initially, "New Incognito window" should be enabled.
84 scoped_ptr<LauncherContextMenu> menu( 84 std::unique_ptr<LauncherContextMenu> menu(
85 CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT)); 85 CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT));
86 ASSERT_TRUE(IsItemPresentInMenu( 86 ASSERT_TRUE(IsItemPresentInMenu(
87 menu.get(), LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW)); 87 menu.get(), LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW));
88 EXPECT_TRUE(menu->IsCommandIdEnabled( 88 EXPECT_TRUE(menu->IsCommandIdEnabled(
89 LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW)); 89 LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW));
90 90
91 // Disable Incognito mode. 91 // Disable Incognito mode.
92 IncognitoModePrefs::SetAvailability(profile()->GetPrefs(), 92 IncognitoModePrefs::SetAvailability(profile()->GetPrefs(),
93 IncognitoModePrefs::DISABLED); 93 IncognitoModePrefs::DISABLED);
94 menu.reset(CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT)); 94 menu.reset(CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT));
95 // The item should be disabled. 95 // The item should be disabled.
96 ASSERT_TRUE(IsItemPresentInMenu( 96 ASSERT_TRUE(IsItemPresentInMenu(
97 menu.get(), LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW)); 97 menu.get(), LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW));
98 EXPECT_FALSE(menu->IsCommandIdEnabled( 98 EXPECT_FALSE(menu->IsCommandIdEnabled(
99 LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW)); 99 LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW));
100 } 100 }
101 101
102 // Verifies that "New window" menu item in the launcher context 102 // Verifies that "New window" menu item in the launcher context
103 // menu is disabled when Incognito mode is forced (by a policy). 103 // menu is disabled when Incognito mode is forced (by a policy).
104 TEST_F(LauncherContextMenuTest, 104 TEST_F(LauncherContextMenuTest,
105 NewWindowMenuIsDisabledWhenIncognitoModeForced) { 105 NewWindowMenuIsDisabledWhenIncognitoModeForced) {
106 // Initially, "New window" should be enabled. 106 // Initially, "New window" should be enabled.
107 scoped_ptr<LauncherContextMenu> menu( 107 std::unique_ptr<LauncherContextMenu> menu(
108 CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT)); 108 CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT));
109 ASSERT_TRUE(IsItemPresentInMenu( 109 ASSERT_TRUE(IsItemPresentInMenu(
110 menu.get(), LauncherContextMenu::MENU_NEW_WINDOW)); 110 menu.get(), LauncherContextMenu::MENU_NEW_WINDOW));
111 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW)); 111 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW));
112 112
113 // Disable Incognito mode. 113 // Disable Incognito mode.
114 IncognitoModePrefs::SetAvailability(profile()->GetPrefs(), 114 IncognitoModePrefs::SetAvailability(profile()->GetPrefs(),
115 IncognitoModePrefs::FORCED); 115 IncognitoModePrefs::FORCED);
116 menu.reset(CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT)); 116 menu.reset(CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT));
117 ASSERT_TRUE(IsItemPresentInMenu( 117 ASSERT_TRUE(IsItemPresentInMenu(
118 menu.get(), LauncherContextMenu::MENU_NEW_WINDOW)); 118 menu.get(), LauncherContextMenu::MENU_NEW_WINDOW));
119 EXPECT_FALSE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW)); 119 EXPECT_FALSE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW));
120 } 120 }
121 121
122 // Verifies status of contextmenu items for desktop shell. 122 // Verifies status of contextmenu items for desktop shell.
123 TEST_F(LauncherContextMenuTest, DesktopShellLauncherContextMenuItemCheck) { 123 TEST_F(LauncherContextMenuTest, DesktopShellLauncherContextMenuItemCheck) {
124 scoped_ptr<LauncherContextMenu> menu( 124 std::unique_ptr<LauncherContextMenu> menu(
125 CreateLauncherContextMenuForDesktopShell()); 125 CreateLauncherContextMenuForDesktopShell());
126 EXPECT_FALSE( 126 EXPECT_FALSE(
127 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); 127 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW));
128 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); 128 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN));
129 EXPECT_TRUE( 129 EXPECT_TRUE(
130 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); 130 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE));
131 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); 131 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE));
132 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), 132 EXPECT_TRUE(IsItemPresentInMenu(menu.get(),
133 LauncherContextMenu::MENU_ALIGNMENT_MENU)); 133 LauncherContextMenu::MENU_ALIGNMENT_MENU));
134 EXPECT_TRUE( 134 EXPECT_TRUE(
(...skipping 23 matching lines...) Expand all
158 EXPECT_TRUE( 158 EXPECT_TRUE(
159 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); 159 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU));
160 // By default, screen is not locked and ChangeWallPaper item is added in 160 // By default, screen is not locked and ChangeWallPaper item is added in
161 // menu. ChangeWallPaper item is not enabled in default mode. 161 // menu. ChangeWallPaper item is not enabled in default mode.
162 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), 162 EXPECT_TRUE(IsItemPresentInMenu(menu.get(),
163 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); 163 LauncherContextMenu::MENU_CHANGE_WALLPAPER));
164 EXPECT_FALSE( 164 EXPECT_FALSE(
165 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); 165 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER));
166 } 166 }
167 #endif 167 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698