| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "chrome/browser/extensions/extension_install_prompt.h" | 7 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 8 #include "chrome/browser/extensions/extension_reenabler.h" | 8 #include "chrome/browser/extensions/extension_reenabler.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_service_test_base.h" | 10 #include "chrome/browser/extensions/extension_service_test_base.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 ExtensionsBrowserClient::Set(nullptr); | 129 ExtensionsBrowserClient::Set(nullptr); |
| 130 test_browser_client_.reset(); | 130 test_browser_client_.reset(); |
| 131 ExtensionServiceTestBase::TearDown(); | 131 ExtensionServiceTestBase::TearDown(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 // Test that the ExtensionReenabler reenables disabled extensions. | 134 // Test that the ExtensionReenabler reenables disabled extensions. |
| 135 TEST_F(ExtensionReenablerUnitTest, TestReenablingDisabledExtension) { | 135 TEST_F(ExtensionReenablerUnitTest, TestReenablingDisabledExtension) { |
| 136 // Create a simple extension and add it to the service. | 136 // Create a simple extension and add it to the service. |
| 137 scoped_refptr<const Extension> extension = | 137 scoped_refptr<const Extension> extension = |
| 138 ExtensionBuilder() | 138 ExtensionBuilder() |
| 139 .SetManifest(std::move(DictionaryBuilder() | 139 .SetManifest(DictionaryBuilder() |
| 140 .Set("name", "test ext") | 140 .Set("name", "test ext") |
| 141 .Set("version", "1.0") | 141 .Set("version", "1.0") |
| 142 .Set("manifest_version", 2) | 142 .Set("manifest_version", 2) |
| 143 .Set("description", "a test ext"))) | 143 .Set("description", "a test ext") |
| 144 .Build()) |
| 144 .SetID(crx_file::id_util::GenerateId("test ext")) | 145 .SetID(crx_file::id_util::GenerateId("test ext")) |
| 145 .Build(); | 146 .Build(); |
| 146 service()->AddExtension(extension.get()); | 147 service()->AddExtension(extension.get()); |
| 147 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension->id())); | 148 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension->id())); |
| 148 | 149 |
| 149 CallbackHelper callback_helper; | 150 CallbackHelper callback_helper; |
| 150 | 151 |
| 151 // Check that the ExtensionReenabler can re-enable disabled extensions. | 152 // Check that the ExtensionReenabler can re-enable disabled extensions. |
| 152 { | 153 { |
| 153 // Disable the extension due to a permissions increase (the only type of | 154 // Disable the extension due to a permissions increase (the only type of |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 EXPECT_FALSE(callback_helper.has_result()); | 262 EXPECT_FALSE(callback_helper.has_result()); |
| 262 // Destroy the reenabler to simulate the owning context being shut down | 263 // Destroy the reenabler to simulate the owning context being shut down |
| 263 // (e.g., the tab closing). | 264 // (e.g., the tab closing). |
| 264 extension_reenabler.reset(); | 265 extension_reenabler.reset(); |
| 265 EXPECT_TRUE( | 266 EXPECT_TRUE( |
| 266 callback_helper.result_matches(ExtensionReenabler::ABORTED)); | 267 callback_helper.result_matches(ExtensionReenabler::ABORTED)); |
| 267 } | 268 } |
| 268 } | 269 } |
| 269 | 270 |
| 270 } // namespace extensions | 271 } // namespace extensions |
| OLD | NEW |