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

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 2647783003: Reenable disabled component extensions with profile resetter. (Closed)
Patch Set: Rebase. Created 3 years, 10 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 | « no previous file | chrome/browser/profile_resetter/profile_resetter.cc » ('j') | 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/extensions/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 252
253 size_t GetExternalInstallBubbleCount(ExtensionService* service) { 253 size_t GetExternalInstallBubbleCount(ExtensionService* service) {
254 size_t bubble_count = 0u; 254 size_t bubble_count = 0u;
255 std::vector<ExternalInstallError*> errors = 255 std::vector<ExternalInstallError*> errors =
256 service->external_install_manager()->GetErrorsForTesting(); 256 service->external_install_manager()->GetErrorsForTesting();
257 for (auto* error : errors) 257 for (auto* error : errors)
258 bubble_count += error->alert_type() == ExternalInstallError::BUBBLE_ALERT; 258 bubble_count += error->alert_type() == ExternalInstallError::BUBBLE_ALERT;
259 return bubble_count; 259 return bubble_count;
260 } 260 }
261 261
262 scoped_refptr<Extension> CreateExtension(const base::string16& name,
263 const base::FilePath& path,
264 Manifest::Location location) {
265 base::DictionaryValue manifest;
266 manifest.SetString(extensions::manifest_keys::kVersion, "1.0.0.0");
267 manifest.SetString(extensions::manifest_keys::kName, name);
268 std::string error;
269 scoped_refptr<Extension> extension =
270 Extension::Create(path, location, manifest, Extension::NO_FLAGS, &error);
271 EXPECT_TRUE(extension.get() != nullptr) << error;
272 return extension;
273 }
274
262 } // namespace 275 } // namespace
263 276
264 class MockExtensionProvider : public extensions::ExternalProviderInterface { 277 class MockExtensionProvider : public extensions::ExternalProviderInterface {
265 public: 278 public:
266 MockExtensionProvider( 279 MockExtensionProvider(
267 VisitorInterface* visitor, 280 VisitorInterface* visitor,
268 Manifest::Location location) 281 Manifest::Location location)
269 : location_(location), visitor_(visitor), visit_count_(0) { 282 : location_(location), visitor_(visitor), visit_count_(0) {
270 } 283 }
271 284
(...skipping 6130 matching lines...) Expand 10 before | Expand all | Expand 10 after
6402 const Extension* extension = 6415 const Extension* extension =
6403 registry()->disabled_extensions().GetByID(page_action); 6416 registry()->disabled_extensions().GetByID(page_action);
6404 EXPECT_TRUE(extension); 6417 EXPECT_TRUE(extension);
6405 EXPECT_EQ(page_action, extension->id()); 6418 EXPECT_EQ(page_action, extension->id());
6406 6419
6407 service()->EnableExtension(page_action); 6420 service()->EnableExtension(page_action);
6408 EXPECT_FALSE(HasExternalInstallErrors(service())); 6421 EXPECT_FALSE(HasExternalInstallErrors(service()));
6409 EXPECT_TRUE(service()->IsExtensionEnabled(page_action)); 6422 EXPECT_TRUE(service()->IsExtensionEnabled(page_action));
6410 } 6423 }
6411 6424
6425 // As for components, only external component extensions can be disabled.
6426 TEST_F(ExtensionServiceTest, DisablingComponentExtensions) {
6427 InitializeEmptyExtensionService();
6428 service_->Init();
6429
6430 scoped_refptr<Extension> external_component_extension = CreateExtension(
6431 base::ASCIIToUTF16("external_component_extension"),
6432 base::FilePath(FILE_PATH_LITERAL("//external_component_extension")),
6433 Manifest::EXTERNAL_COMPONENT);
6434 service_->AddExtension(external_component_extension.get());
6435 EXPECT_TRUE(registry()->enabled_extensions().Contains(
6436 external_component_extension->id()));
6437 service_->DisableExtension(external_component_extension->id(),
6438 extensions::Extension::DISABLE_USER_ACTION);
6439 EXPECT_TRUE(registry()->disabled_extensions().Contains(
6440 external_component_extension->id()));
6441
6442 scoped_refptr<Extension> component_extension = CreateExtension(
6443 base::ASCIIToUTF16("component_extension"),
6444 base::FilePath(FILE_PATH_LITERAL("//component_extension")),
6445 Manifest::COMPONENT);
6446 service_->AddExtension(component_extension.get());
6447 EXPECT_TRUE(
6448 registry()->enabled_extensions().Contains(component_extension->id()));
6449 service_->DisableExtension(component_extension->id(),
6450 extensions::Extension::DISABLE_USER_ACTION);
6451 EXPECT_FALSE(
6452 registry()->disabled_extensions().Contains(component_extension->id()));
6453 }
6454
6412 // Test that installing multiple external extensions works. 6455 // Test that installing multiple external extensions works.
6413 // Flaky on windows; http://crbug.com/295757 . 6456 // Flaky on windows; http://crbug.com/295757 .
6414 // Causes race conditions with an in-process utility thread, so disable under 6457 // Causes race conditions with an in-process utility thread, so disable under
6415 // TSan: https://crbug.com/518957 6458 // TSan: https://crbug.com/518957
6416 #if defined(OS_WIN) || defined(THREAD_SANITIZER) 6459 #if defined(OS_WIN) || defined(THREAD_SANITIZER)
6417 #define MAYBE_ExternalInstallMultiple DISABLED_ExternalInstallMultiple 6460 #define MAYBE_ExternalInstallMultiple DISABLED_ExternalInstallMultiple
6418 #else 6461 #else
6419 #define MAYBE_ExternalInstallMultiple ExternalInstallMultiple 6462 #define MAYBE_ExternalInstallMultiple ExternalInstallMultiple
6420 #endif 6463 #endif
6421 TEST_F(ExtensionServiceTest, MAYBE_ExternalInstallMultiple) { 6464 TEST_F(ExtensionServiceTest, MAYBE_ExternalInstallMultiple) {
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
7125 7168
7126 // Wait for the reload to complete. This previously crashed (see 7169 // Wait for the reload to complete. This previously crashed (see
7127 // crbug.com/676815). 7170 // crbug.com/676815).
7128 base::RunLoop().RunUntilIdle(); 7171 base::RunLoop().RunUntilIdle();
7129 // The extension should be enabled again... 7172 // The extension should be enabled again...
7130 EXPECT_TRUE(registry()->enabled_extensions().Contains(kExtensionId)); 7173 EXPECT_TRUE(registry()->enabled_extensions().Contains(kExtensionId));
7131 // ...and should have reloaded (for ease, we just compare the extension 7174 // ...and should have reloaded (for ease, we just compare the extension
7132 // objects). 7175 // objects).
7133 EXPECT_NE(extension, registry()->enabled_extensions().GetByID(kExtensionId)); 7176 EXPECT_NE(extension, registry()->enabled_extensions().GetByID(kExtensionId));
7134 } 7177 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profile_resetter/profile_resetter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698