| OLD | NEW | 
|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extensions_service_unittest.h" | 5 #include "chrome/browser/extensions/extensions_service_unittest.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <vector> | 8 #include <vector> | 
| 9 | 9 | 
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" | 
| (...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1430   for (std::vector<std::string>::iterator err = errors.begin(); | 1430   for (std::vector<std::string>::iterator err = errors.begin(); | 
| 1431     err != errors.end(); ++err) { | 1431     err != errors.end(); ++err) { | 
| 1432     LOG(ERROR) << *err; | 1432     LOG(ERROR) << *err; | 
| 1433   } | 1433   } | 
| 1434   ASSERT_EQ(2u, loaded_.size()); | 1434   ASSERT_EQ(2u, loaded_.size()); | 
| 1435 | 1435 | 
| 1436   EXPECT_NE(std::string(good0), loaded_[0]->id()); | 1436   EXPECT_NE(std::string(good0), loaded_[0]->id()); | 
| 1437   EXPECT_NE(std::string(good0), loaded_[1]->id()); | 1437   EXPECT_NE(std::string(good0), loaded_[1]->id()); | 
| 1438 } | 1438 } | 
| 1439 | 1439 | 
|  | 1440 // Tests disabling extensions | 
|  | 1441 TEST_F(ExtensionsServiceTest, DisableExtension) { | 
|  | 1442   InitializeEmptyExtensionsService(); | 
|  | 1443   FilePath extensions_path; | 
|  | 1444   ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); | 
|  | 1445   extensions_path = extensions_path.AppendASCII("extensions"); | 
|  | 1446 | 
|  | 1447   // A simple extension that should install without error. | 
|  | 1448   FilePath path = extensions_path.AppendASCII("good.crx"); | 
|  | 1449   InstallExtension(path, true); | 
|  | 1450 | 
|  | 1451   const char* extension_id = good_crx; | 
|  | 1452   EXPECT_FALSE(service_->extensions()->empty()); | 
|  | 1453   EXPECT_TRUE(service_->GetExtensionById(extension_id, true) != NULL); | 
|  | 1454   EXPECT_TRUE(service_->GetExtensionById(extension_id, false) != NULL); | 
|  | 1455   EXPECT_TRUE(service_->disabled_extensions()->empty()); | 
|  | 1456 | 
|  | 1457   // Disable it. | 
|  | 1458   service_->DisableExtension(extension_id); | 
|  | 1459 | 
|  | 1460   EXPECT_TRUE(service_->extensions()->empty()); | 
|  | 1461   EXPECT_TRUE(service_->GetExtensionById(extension_id, true) != NULL); | 
|  | 1462   EXPECT_FALSE(service_->GetExtensionById(extension_id, false) != NULL); | 
|  | 1463   EXPECT_FALSE(service_->disabled_extensions()->empty()); | 
|  | 1464 } | 
|  | 1465 | 
|  | 1466 // Tests reloading extensions | 
|  | 1467 TEST_F(ExtensionsServiceTest, ReloadExtensions) { | 
|  | 1468   InitializeEmptyExtensionsService(); | 
|  | 1469   FilePath extensions_path; | 
|  | 1470   ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); | 
|  | 1471   extensions_path = extensions_path.AppendASCII("extensions"); | 
|  | 1472 | 
|  | 1473   // Simple extension that should install without error. | 
|  | 1474   FilePath path = extensions_path.AppendASCII("good.crx"); | 
|  | 1475   InstallExtension(path, true); | 
|  | 1476   const char* extension_id = good_crx; | 
|  | 1477   service_->DisableExtension(extension_id); | 
|  | 1478 | 
|  | 1479   EXPECT_EQ(0u, service_->extensions()->size()); | 
|  | 1480   EXPECT_EQ(1u, service_->disabled_extensions()->size()); | 
|  | 1481 | 
|  | 1482   service_->ReloadExtensions(); | 
|  | 1483 | 
|  | 1484   // Extension counts shouldn't change. | 
|  | 1485   EXPECT_EQ(0u, service_->extensions()->size()); | 
|  | 1486   EXPECT_EQ(1u, service_->disabled_extensions()->size()); | 
|  | 1487 | 
|  | 1488   service_->EnableExtension(extension_id); | 
|  | 1489 | 
|  | 1490   EXPECT_EQ(1u, service_->extensions()->size()); | 
|  | 1491   EXPECT_EQ(0u, service_->disabled_extensions()->size()); | 
|  | 1492 | 
|  | 1493   service_->ReloadExtensions(); | 
|  | 1494 | 
|  | 1495   // Extension counts shouldn't change. | 
|  | 1496   EXPECT_EQ(1u, service_->extensions()->size()); | 
|  | 1497   EXPECT_EQ(0u, service_->disabled_extensions()->size()); | 
|  | 1498 } | 
|  | 1499 | 
| 1440 // Tests uninstalling normal extensions | 1500 // Tests uninstalling normal extensions | 
| 1441 TEST_F(ExtensionsServiceTest, UninstallExtension) { | 1501 TEST_F(ExtensionsServiceTest, UninstallExtension) { | 
| 1442   InitializeEmptyExtensionsService(); | 1502   InitializeEmptyExtensionsService(); | 
| 1443   FilePath extensions_path; | 1503   FilePath extensions_path; | 
| 1444   ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); | 1504   ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); | 
| 1445   extensions_path = extensions_path.AppendASCII("extensions"); | 1505   extensions_path = extensions_path.AppendASCII("extensions"); | 
| 1446 | 1506 | 
| 1447   // A simple extension that should install without error. | 1507   // A simple extension that should install without error. | 
| 1448   FilePath path = extensions_path.AppendASCII("good.crx"); | 1508   FilePath path = extensions_path.AppendASCII("good.crx"); | 
| 1449   InstallExtension(path, true); | 1509   InstallExtension(path, true); | 
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1998   // Component extensions shouldn't get recourded in the prefs. | 2058   // Component extensions shouldn't get recourded in the prefs. | 
| 1999   ValidatePrefKeyCount(0); | 2059   ValidatePrefKeyCount(0); | 
| 2000 | 2060 | 
| 2001   // Reload all extensions, and make sure it comes back. | 2061   // Reload all extensions, and make sure it comes back. | 
| 2002   std::string extension_id = service_->extensions()->at(0)->id(); | 2062   std::string extension_id = service_->extensions()->at(0)->id(); | 
| 2003   loaded_.clear(); | 2063   loaded_.clear(); | 
| 2004   service_->ReloadExtensions(); | 2064   service_->ReloadExtensions(); | 
| 2005   ASSERT_EQ(1u, service_->extensions()->size()); | 2065   ASSERT_EQ(1u, service_->extensions()->size()); | 
| 2006   EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 2066   EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 
| 2007 } | 2067 } | 
| OLD | NEW | 
|---|