| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_context_menu_model.h" | 5 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_service_unittest.h" | 7 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 8 #include "chrome/browser/extensions/extension_system.h" | 8 #include "chrome/browser/extensions/extension_system.h" |
| 9 #include "chrome/browser/extensions/test_management_policy.h" | 9 #include "chrome/browser/extensions/test_management_policy.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/host_desktop.h" | 11 #include "chrome/browser/ui/host_desktop.h" |
| 12 #include "chrome/common/extensions/extension_builder.h" | 12 #include "chrome/common/extensions/extension_builder.h" |
| 13 #include "chrome/common/extensions/value_builder.h" | 13 #include "chrome/common/extensions/value_builder.h" |
| 14 #include "chrome/test/base/test_browser_window.h" | 14 #include "chrome/test/base/test_browser_window.h" |
| 15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
| 16 #include "content/public/test/test_renderer_host.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 namespace extensions { | 19 namespace extensions { |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 class ExtensionContextMenuModelTest : public ExtensionServiceTestBase { | 22 class ExtensionContextMenuModelTest : public ExtensionServiceTestBase { |
| 23 protected: |
| 24 // The existence of this object enables tests via RenderViewHostTester. |
| 25 content::RenderViewHostTestEnabler rvh_test_enabler_; |
| 22 }; | 26 }; |
| 23 | 27 |
| 24 // Tests that applicable menu items are disabled when a ManagementPolicy | 28 // Tests that applicable menu items are disabled when a ManagementPolicy |
| 25 // prohibits them. | 29 // prohibits them. |
| 26 TEST_F(ExtensionContextMenuModelTest, PolicyDisablesItems) { | 30 TEST_F(ExtensionContextMenuModelTest, PolicyDisablesItems) { |
| 27 InitializeEmptyExtensionService(); | 31 InitializeEmptyExtensionService(); |
| 28 // Build an extension to pass to the menu constructor. It needs an | 32 // Build an extension to pass to the menu constructor. It needs an |
| 29 // ExtensionAction. | 33 // ExtensionAction. |
| 30 scoped_refptr<Extension> extension = ExtensionBuilder() | 34 scoped_refptr<Extension> extension = ExtensionBuilder() |
| 31 .SetManifest(DictionaryBuilder() | 35 .SetManifest(DictionaryBuilder() |
| (...skipping 28 matching lines...) Expand all Loading... |
| 60 | 64 |
| 61 // Now the actions are disabled. | 65 // Now the actions are disabled. |
| 62 ASSERT_FALSE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::UNINSTALL)); | 66 ASSERT_FALSE(menu->IsCommandIdEnabled(ExtensionContextMenuModel::UNINSTALL)); |
| 63 | 67 |
| 64 // Don't leave |policy_provider| dangling. | 68 // Don't leave |policy_provider| dangling. |
| 65 system->management_policy()->UnregisterAllProviders(); | 69 system->management_policy()->UnregisterAllProviders(); |
| 66 } | 70 } |
| 67 | 71 |
| 68 } // namespace | 72 } // namespace |
| 69 } // namespace extensions | 73 } // namespace extensions |
| OLD | NEW |