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

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

Issue 1812013003: Pass shelf instances, not root windows, for ash context menus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call OnShelfAlignmentChanged after LayoutShelf. Created 4 years, 9 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') | no next file » | 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/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/chrome_launcher_controller.h" 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
17 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
18 #include "components/prefs/pref_service.h" 18 #include "components/prefs/pref_service.h"
19 #include "ui/aura/window_event_dispatcher.h" 19 #include "ui/aura/window_event_dispatcher.h"
20 20
21 class TestChromeLauncherController : public ChromeLauncherController {
22 public:
23 TestChromeLauncherController(Profile* profile, ash::ShelfModel* model)
24 : ChromeLauncherController(profile, model) {}
25 bool IsLoggedInAsGuest() override { return false; }
26 private:
27 DISALLOW_COPY_AND_ASSIGN(TestChromeLauncherController);
28 };
29
30 class LauncherContextMenuTest : public ash::test::AshTestBase { 21 class LauncherContextMenuTest : public ash::test::AshTestBase {
31 protected: 22 protected:
32 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { 23 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) {
33 DCHECK(menu);
34 return menu->GetIndexOfCommandId(command_id) != -1; 24 return menu->GetIndexOfCommandId(command_id) != -1;
35 } 25 }
36 26
37 LauncherContextMenuTest() 27 LauncherContextMenuTest() : profile_(new TestingProfile()) {}
38 : profile_(new TestingProfile()) {}
39 28
40 void SetUp() override { 29 void SetUp() override {
41 ash::test::AshTestBase::SetUp(); 30 ash::test::AshTestBase::SetUp();
42 controller_.reset( 31 controller_.reset(new ChromeLauncherController(profile(), &shelf_model_));
43 new TestChromeLauncherController(profile(), &shelf_model_));
44 } 32 }
45 33
46 void TearDown() override { 34 void TearDown() override {
47 controller_.reset(NULL); 35 controller_.reset(nullptr);
48 ash::test::AshTestBase::TearDown(); 36 ash::test::AshTestBase::TearDown();
49 } 37 }
50 38
51 LauncherContextMenu* CreateLauncherContextMenu( 39 LauncherContextMenu* CreateLauncherContextMenu(
52 ash::ShelfItemType shelf_item_type) { 40 ash::ShelfItemType shelf_item_type) {
53 ash::ShelfItem item; 41 ash::ShelfItem item;
54 item.id = 1; // dummy id 42 item.id = 1; // dummy id
55 item.type = shelf_item_type; 43 item.type = shelf_item_type;
56 return new LauncherContextMenu(controller_.get(), &item, CurrentContext()); 44 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext());
45 return new LauncherContextMenu(controller_.get(), &item, shelf);
57 } 46 }
58 47
59 Profile* profile() { return profile_.get(); } 48 Profile* profile() { return profile_.get(); }
60 49
61 private: 50 private:
62 scoped_ptr<TestingProfile> profile_; 51 scoped_ptr<TestingProfile> profile_;
63 ash::ShelfModel shelf_model_; 52 ash::ShelfModel shelf_model_;
64 scoped_ptr<ChromeLauncherController> controller_; 53 scoped_ptr<ChromeLauncherController> controller_;
65 54
66 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); 55 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW)); 90 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW));
102 91
103 // Disable Incognito mode. 92 // Disable Incognito mode.
104 IncognitoModePrefs::SetAvailability(profile()->GetPrefs(), 93 IncognitoModePrefs::SetAvailability(profile()->GetPrefs(),
105 IncognitoModePrefs::FORCED); 94 IncognitoModePrefs::FORCED);
106 menu.reset(CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT)); 95 menu.reset(CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT));
107 ASSERT_TRUE(IsItemPresentInMenu( 96 ASSERT_TRUE(IsItemPresentInMenu(
108 menu.get(), LauncherContextMenu::MENU_NEW_WINDOW)); 97 menu.get(), LauncherContextMenu::MENU_NEW_WINDOW));
109 EXPECT_FALSE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW)); 98 EXPECT_FALSE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW));
110 } 99 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/launcher_context_menu.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698