| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 157 using extensions::Manifest; | 157 using extensions::Manifest; | 
| 158 using extensions::PermissionSet; | 158 using extensions::PermissionSet; | 
| 159 using extensions::TestExtensionSystem; | 159 using extensions::TestExtensionSystem; | 
| 160 using extensions::URLPatternSet; | 160 using extensions::URLPatternSet; | 
| 161 | 161 | 
| 162 namespace keys = extensions::manifest_keys; | 162 namespace keys = extensions::manifest_keys; | 
| 163 | 163 | 
| 164 namespace { | 164 namespace { | 
| 165 | 165 | 
| 166 // Extension ids used during testing. | 166 // Extension ids used during testing. | 
| 167 const char all_zero[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; |  | 
| 168 const char good0[] = "behllobkkfkfnphdnhnkndlbkcpglgmj"; | 167 const char good0[] = "behllobkkfkfnphdnhnkndlbkcpglgmj"; | 
| 169 const char good1[] = "hpiknbiabeeppbpihjehijgoemciehgk"; | 168 const char good1[] = "hpiknbiabeeppbpihjehijgoemciehgk"; | 
| 170 const char good2[] = "bjafgdebaacbbbecmhlhpofkepfkgcpa"; | 169 const char good2[] = "bjafgdebaacbbbecmhlhpofkepfkgcpa"; | 
|  | 170 #if !(defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)) | 
|  | 171 const char all_zero[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | 
| 171 const char good2048[] = "nmgjhmhbleinmjpbdhgajfjkbijcmgbh"; | 172 const char good2048[] = "nmgjhmhbleinmjpbdhgajfjkbijcmgbh"; | 
| 172 const char good_crx[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; | 173 const char good_crx[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; | 
| 173 const char hosted_app[] = "kbmnembihfiondgfjekmnmcbddelicoi"; | 174 const char hosted_app[] = "kbmnembihfiondgfjekmnmcbddelicoi"; | 
| 174 const char page_action[] = "obcimlgaoabeegjmmpldobjndiealpln"; | 175 const char page_action[] = "obcimlgaoabeegjmmpldobjndiealpln"; | 
| 175 const char theme_crx[] = "iamefpfkojoapidjnbafmgkgncegbkad"; | 176 const char theme_crx[] = "iamefpfkojoapidjnbafmgkgncegbkad"; | 
| 176 const char theme2_crx[] = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf"; | 177 const char theme2_crx[] = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf"; | 
| 177 const char permissions_crx[] = "eagpmdpfmaekmmcejjbmjoecnejeiiin"; | 178 const char permissions_crx[] = "eagpmdpfmaekmmcejjbmjoecnejeiiin"; | 
| 178 const char unpacked[] = "cbcdidchbppangcjoddlpdjlenngjldk"; | 179 const char unpacked[] = "cbcdidchbppangcjoddlpdjlenngjldk"; | 
| 179 const char updates_from_webstore[] = "akjooamlhcgeopfifcmlggaebeocgokj"; | 180 const char updates_from_webstore[] = "akjooamlhcgeopfifcmlggaebeocgokj"; | 
|  | 181 #endif | 
| 180 | 182 | 
| 181 struct ExtensionsOrder { | 183 struct ExtensionsOrder { | 
| 182   bool operator()(const scoped_refptr<const Extension>& a, | 184   bool operator()(const scoped_refptr<const Extension>& a, | 
| 183                   const scoped_refptr<const Extension>& b) { | 185                   const scoped_refptr<const Extension>& b) { | 
| 184     return a->name() < b->name(); | 186     return a->name() < b->name(); | 
| 185   } | 187   } | 
| 186 }; | 188 }; | 
| 187 | 189 | 
| 188 static std::vector<string16> GetErrors() { | 190 static std::vector<string16> GetErrors() { | 
| 189   const std::vector<string16>* errors = | 191   const std::vector<string16>* errors = | 
| 190       ExtensionErrorReporter::GetInstance()->GetErrors(); | 192       ExtensionErrorReporter::GetInstance()->GetErrors(); | 
| 191   std::vector<string16> ret_val; | 193   std::vector<string16> ret_val; | 
| 192 | 194 | 
| 193   for (std::vector<string16>::const_iterator iter = errors->begin(); | 195   for (std::vector<string16>::const_iterator iter = errors->begin(); | 
| 194        iter != errors->end(); ++iter) { | 196        iter != errors->end(); ++iter) { | 
| 195     std::string utf8_error = UTF16ToUTF8(*iter); | 197     std::string utf8_error = UTF16ToUTF8(*iter); | 
| 196     if (utf8_error.find(".svn") == std::string::npos) { | 198     if (utf8_error.find(".svn") == std::string::npos) { | 
| 197       ret_val.push_back(*iter); | 199       ret_val.push_back(*iter); | 
| 198     } | 200     } | 
| 199   } | 201   } | 
| 200 | 202 | 
| 201   // The tests rely on the errors being in a certain order, which can vary | 203   // The tests rely on the errors being in a certain order, which can vary | 
| 202   // depending on how filesystem iteration works. | 204   // depending on how filesystem iteration works. | 
| 203   std::stable_sort(ret_val.begin(), ret_val.end()); | 205   std::stable_sort(ret_val.begin(), ret_val.end()); | 
| 204 | 206 | 
| 205   return ret_val; | 207   return ret_val; | 
| 206 } | 208 } | 
| 207 | 209 | 
|  | 210 #if !(defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)) | 
| 208 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { | 211 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { | 
| 209   int schemes = URLPattern::SCHEME_ALL; | 212   int schemes = URLPattern::SCHEME_ALL; | 
| 210   extent->AddPattern(URLPattern(schemes, pattern)); | 213   extent->AddPattern(URLPattern(schemes, pattern)); | 
| 211 } | 214 } | 
|  | 215 #endif | 
| 212 | 216 | 
| 213 base::FilePath GetTemporaryFile() { | 217 base::FilePath GetTemporaryFile() { | 
| 214   base::FilePath temp_file; | 218   base::FilePath temp_file; | 
| 215   CHECK(file_util::CreateTemporaryFile(&temp_file)); | 219   CHECK(file_util::CreateTemporaryFile(&temp_file)); | 
| 216   return temp_file; | 220   return temp_file; | 
| 217 } | 221 } | 
| 218 | 222 | 
| 219 | 223 | 
| 220 bool WaitForCountNotificationsCallback(int *count) { | 224 bool WaitForCountNotificationsCallback(int *count) { | 
| 221   return --(*count) == 0; | 225   return --(*count) == 0; | 
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1278 | 1282 | 
| 1279 // The tests are designed so that we never expect to see a packing error. | 1283 // The tests are designed so that we never expect to see a packing error. | 
| 1280 void PackExtensionTestClient::OnPackFailure(const std::string& error_message, | 1284 void PackExtensionTestClient::OnPackFailure(const std::string& error_message, | 
| 1281                                             ExtensionCreator::ErrorType type) { | 1285                                             ExtensionCreator::ErrorType type) { | 
| 1282   if (type == ExtensionCreator::kCRXExists) | 1286   if (type == ExtensionCreator::kCRXExists) | 
| 1283      FAIL() << "Packing should not fail."; | 1287      FAIL() << "Packing should not fail."; | 
| 1284   else | 1288   else | 
| 1285      FAIL() << "Existing CRX should have been overwritten."; | 1289      FAIL() << "Existing CRX should have been overwritten."; | 
| 1286 } | 1290 } | 
| 1287 | 1291 | 
|  | 1292 // TODO(aura): http://crbug.com/316919 | 
|  | 1293 // | 
|  | 1294 // The ExetnsionServiceTest reliably has some tests fail on each run, except | 
|  | 1295 // that they're different tests each time. The problem appears to be that | 
|  | 1296 // another thread is holding a lock while ShadowingAtExitManager destroys all | 
|  | 1297 // LazyInstances<>. Something very bad is going on with threading here. | 
|  | 1298 // | 
|  | 1299 #if !(defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)) | 
|  | 1300 | 
| 1288 // Test loading good extensions from the profile directory. | 1301 // Test loading good extensions from the profile directory. | 
| 1289 TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectorySuccess) { | 1302 TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectorySuccess) { | 
| 1290   InitPluginService(); | 1303   InitPluginService(); | 
| 1291   InitializeGoodInstalledExtensionService(); | 1304   InitializeGoodInstalledExtensionService(); | 
| 1292   service_->Init(); | 1305   service_->Init(); | 
| 1293 | 1306 | 
| 1294   uint32 expected_num_extensions = 3u; | 1307   uint32 expected_num_extensions = 3u; | 
| 1295   ASSERT_EQ(expected_num_extensions, loaded_.size()); | 1308   ASSERT_EQ(expected_num_extensions, loaded_.size()); | 
| 1296 | 1309 | 
| 1297   EXPECT_EQ(std::string(good0), loaded_[0]->id()); | 1310   EXPECT_EQ(std::string(good0), loaded_[0]->id()); | 
| (...skipping 5368 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6666   // ReconcileKnownDisabled(). | 6679   // ReconcileKnownDisabled(). | 
| 6667   service_->EnableExtension(good2); | 6680   service_->EnableExtension(good2); | 
| 6668   service_->ReconcileKnownDisabled(); | 6681   service_->ReconcileKnownDisabled(); | 
| 6669   expected_extensions.insert(good2); | 6682   expected_extensions.insert(good2); | 
| 6670   expected_disabled_extensions.erase(good2); | 6683   expected_disabled_extensions.erase(good2); | 
| 6671 | 6684 | 
| 6672   EXPECT_EQ(expected_extensions, service_->extensions()->GetIDs()); | 6685   EXPECT_EQ(expected_extensions, service_->extensions()->GetIDs()); | 
| 6673   EXPECT_EQ(expected_disabled_extensions, | 6686   EXPECT_EQ(expected_disabled_extensions, | 
| 6674             service_->disabled_extensions()->GetIDs()); | 6687             service_->disabled_extensions()->GetIDs()); | 
| 6675 } | 6688 } | 
|  | 6689 | 
|  | 6690 #endif // #if !(defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)) | 
| OLD | NEW | 
|---|