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 "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
8 #include "ash/launcher/launcher_model.h" | 8 #include "ash/launcher/launcher_model.h" |
9 #include "ash/launcher/launcher_types.h" | 9 #include "ash/launcher/launcher_types.h" |
10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
13 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 13 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser.
h" | |
17 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
18 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
19 | 18 |
20 class TestChromeLauncherControllerPerBrowser : | 19 class TestChromeLauncherController : public ChromeLauncherController { |
21 public ChromeLauncherControllerPerBrowser { | |
22 public: | 20 public: |
23 TestChromeLauncherControllerPerBrowser( | 21 TestChromeLauncherController(Profile* profile, ash::LauncherModel* model) |
24 Profile* profile, ash::LauncherModel* model) | 22 : ChromeLauncherController(profile, model) {} |
25 : ChromeLauncherControllerPerBrowser(profile, model) {} | |
26 virtual bool IsLoggedInAsGuest() OVERRIDE { | 23 virtual bool IsLoggedInAsGuest() OVERRIDE { |
27 return false; | 24 return false; |
28 } | 25 } |
29 private: | 26 private: |
30 DISALLOW_COPY_AND_ASSIGN(TestChromeLauncherControllerPerBrowser); | 27 DISALLOW_COPY_AND_ASSIGN(TestChromeLauncherController); |
31 }; | 28 }; |
32 | 29 |
33 class LauncherContextMenuTest : public ash::test::AshTestBase { | 30 class LauncherContextMenuTest : public ash::test::AshTestBase { |
34 protected: | 31 protected: |
35 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { | 32 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { |
36 DCHECK(menu); | 33 DCHECK(menu); |
37 return menu->GetIndexOfCommandId(command_id) != -1; | 34 return menu->GetIndexOfCommandId(command_id) != -1; |
38 } | 35 } |
39 | 36 |
40 LauncherContextMenuTest() | 37 LauncherContextMenuTest() |
41 : profile_(new TestingProfile()) {} | 38 : profile_(new TestingProfile()) {} |
42 | 39 |
43 virtual void SetUp() OVERRIDE { | 40 virtual void SetUp() OVERRIDE { |
44 ash::test::AshTestBase::SetUp(); | 41 ash::test::AshTestBase::SetUp(); |
45 controller_.reset( | 42 controller_.reset( |
46 new TestChromeLauncherControllerPerBrowser(profile(), | 43 new TestChromeLauncherController(profile(), &launcher_model_)); |
47 &launcher_model_)); | |
48 } | 44 } |
49 | 45 |
50 virtual void TearDown() OVERRIDE { | 46 virtual void TearDown() OVERRIDE { |
51 controller_.reset(NULL); | 47 controller_.reset(NULL); |
52 ash::test::AshTestBase::TearDown(); | 48 ash::test::AshTestBase::TearDown(); |
53 } | 49 } |
54 | 50 |
55 LauncherContextMenu* CreateLauncherContextMenu( | 51 LauncherContextMenu* CreateLauncherContextMenu( |
56 ash::LauncherItemType launcher_item_type) { | 52 ash::LauncherItemType launcher_item_type) { |
57 ash::LauncherItem item; | 53 ash::LauncherItem item; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW)); | 101 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW)); |
106 | 102 |
107 // Disable Incognito mode. | 103 // Disable Incognito mode. |
108 IncognitoModePrefs::SetAvailability(profile()->GetPrefs(), | 104 IncognitoModePrefs::SetAvailability(profile()->GetPrefs(), |
109 IncognitoModePrefs::FORCED); | 105 IncognitoModePrefs::FORCED); |
110 menu.reset(CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT)); | 106 menu.reset(CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT)); |
111 ASSERT_TRUE(IsItemPresentInMenu( | 107 ASSERT_TRUE(IsItemPresentInMenu( |
112 menu.get(), LauncherContextMenu::MENU_NEW_WINDOW)); | 108 menu.get(), LauncherContextMenu::MENU_NEW_WINDOW)); |
113 EXPECT_FALSE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW)); | 109 EXPECT_FALSE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW)); |
114 } | 110 } |
OLD | NEW |