| 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/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 return ret_val; | 207 return ret_val; |
| 208 } | 208 } |
| 209 | 209 |
| 210 #if !(defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)) | 210 #if !(defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)) |
| 211 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { | 211 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { |
| 212 int schemes = URLPattern::SCHEME_ALL; | 212 int schemes = URLPattern::SCHEME_ALL; |
| 213 extent->AddPattern(URLPattern(schemes, pattern)); | 213 extent->AddPattern(URLPattern(schemes, pattern)); |
| 214 } | 214 } |
| 215 #endif | 215 #endif |
| 216 | 216 |
| 217 #if !(defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)) |
| 217 base::FilePath GetTemporaryFile() { | 218 base::FilePath GetTemporaryFile() { |
| 218 base::FilePath temp_file; | 219 base::FilePath temp_file; |
| 219 CHECK(file_util::CreateTemporaryFile(&temp_file)); | 220 CHECK(file_util::CreateTemporaryFile(&temp_file)); |
| 220 return temp_file; | 221 return temp_file; |
| 221 } | 222 } |
| 222 | 223 |
| 223 | |
| 224 bool WaitForCountNotificationsCallback(int *count) { | 224 bool WaitForCountNotificationsCallback(int *count) { |
| 225 return --(*count) == 0; | 225 return --(*count) == 0; |
| 226 } | 226 } |
| 227 #endif // !(defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)) |
| 227 | 228 |
| 228 } // namespace | 229 } // namespace |
| 229 | 230 |
| 230 class MockExtensionProvider : public extensions::ExternalProviderInterface { | 231 class MockExtensionProvider : public extensions::ExternalProviderInterface { |
| 231 public: | 232 public: |
| 232 MockExtensionProvider( | 233 MockExtensionProvider( |
| 233 VisitorInterface* visitor, | 234 VisitorInterface* visitor, |
| 234 Manifest::Location location) | 235 Manifest::Location location) |
| 235 : location_(location), visitor_(visitor), visit_count_(0) { | 236 : location_(location), visitor_(visitor), visit_count_(0) { |
| 236 } | 237 } |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 void PackExtensionTestClient::OnPackFailure(const std::string& error_message, | 1297 void PackExtensionTestClient::OnPackFailure(const std::string& error_message, |
| 1297 ExtensionCreator::ErrorType type) { | 1298 ExtensionCreator::ErrorType type) { |
| 1298 if (type == ExtensionCreator::kCRXExists) | 1299 if (type == ExtensionCreator::kCRXExists) |
| 1299 FAIL() << "Packing should not fail."; | 1300 FAIL() << "Packing should not fail."; |
| 1300 else | 1301 else |
| 1301 FAIL() << "Existing CRX should have been overwritten."; | 1302 FAIL() << "Existing CRX should have been overwritten."; |
| 1302 } | 1303 } |
| 1303 | 1304 |
| 1304 // TODO(aura): http://crbug.com/316919 | 1305 // TODO(aura): http://crbug.com/316919 |
| 1305 // | 1306 // |
| 1306 // The ExetnsionServiceTest reliably has some tests fail on each run, except | 1307 // The ExtensionServiceTest reliably has some tests fail on each run, except |
| 1307 // that they're different tests each time. The problem appears to be that | 1308 // that they're different tests each time. The problem appears to be that |
| 1308 // another thread is holding a lock while ShadowingAtExitManager destroys all | 1309 // another thread is holding a lock while ShadowingAtExitManager destroys all |
| 1309 // LazyInstances<>. Something very bad is going on with threading here. | 1310 // LazyInstances<>. Something very bad is going on with threading here. |
| 1310 // | 1311 // |
| 1311 #if !(defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)) | 1312 #if !(defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)) |
| 1312 | 1313 |
| 1313 // Test loading good extensions from the profile directory. | 1314 // Test loading good extensions from the profile directory. |
| 1314 TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectorySuccess) { | 1315 TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectorySuccess) { |
| 1315 InitPluginService(); | 1316 InitPluginService(); |
| 1316 InitializeGoodInstalledExtensionService(); | 1317 InitializeGoodInstalledExtensionService(); |
| (...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3119 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 3120 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 3120 switches::kAppsGalleryInstallAutoConfirmForTests, | 3121 switches::kAppsGalleryInstallAutoConfirmForTests, |
| 3121 "cancel"); | 3122 "cancel"); |
| 3122 | 3123 |
| 3123 service_->ReloadExtension(good1); | 3124 service_->ReloadExtension(good1); |
| 3124 base::RunLoop().RunUntilIdle(); | 3125 base::RunLoop().RunUntilIdle(); |
| 3125 EXPECT_EQ(1u, loaded_.size()); | 3126 EXPECT_EQ(1u, loaded_.size()); |
| 3126 EXPECT_EQ(2u, service_->extensions()->size()); | 3127 EXPECT_EQ(2u, service_->extensions()->size()); |
| 3127 EXPECT_EQ(0u, service_->disabled_extensions()->size()); | 3128 EXPECT_EQ(0u, service_->disabled_extensions()->size()); |
| 3128 } | 3129 } |
| 3129 #endif | 3130 #endif // !defined(OS_CHROMEOS) |
| 3130 | 3131 |
| 3131 namespace { | 3132 namespace { |
| 3132 | 3133 |
| 3133 bool IsExtension(const Extension* extension) { | 3134 bool IsExtension(const Extension* extension) { |
| 3134 return extension->GetType() == Manifest::TYPE_EXTENSION; | 3135 return extension->GetType() == Manifest::TYPE_EXTENSION; |
| 3135 } | 3136 } |
| 3136 | 3137 |
| 3137 } // namespace | 3138 } // namespace |
| 3138 | 3139 |
| 3139 // Test adding a pending extension. | 3140 // Test adding a pending extension. |
| (...skipping 3602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6742 service_->ReconcileKnownDisabled(); | 6743 service_->ReconcileKnownDisabled(); |
| 6743 expected_extensions.insert(good2); | 6744 expected_extensions.insert(good2); |
| 6744 expected_disabled_extensions.erase(good2); | 6745 expected_disabled_extensions.erase(good2); |
| 6745 | 6746 |
| 6746 EXPECT_EQ(expected_extensions, service_->extensions()->GetIDs()); | 6747 EXPECT_EQ(expected_extensions, service_->extensions()->GetIDs()); |
| 6747 EXPECT_EQ(expected_disabled_extensions, | 6748 EXPECT_EQ(expected_disabled_extensions, |
| 6748 service_->disabled_extensions()->GetIDs()); | 6749 service_->disabled_extensions()->GetIDs()); |
| 6749 } | 6750 } |
| 6750 | 6751 |
| 6751 #endif // #if !(defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)) | 6752 #endif // #if !(defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)) |
| OLD | NEW |