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

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

Issue 17038002: Separate the NTP app ordering from the app list app ordering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years, 2 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
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_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 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 1232
1233 EXPECT_EQ(std::string(good0), loaded_[0]->id()); 1233 EXPECT_EQ(std::string(good0), loaded_[0]->id());
1234 EXPECT_EQ(std::string("My extension 1"), 1234 EXPECT_EQ(std::string("My extension 1"),
1235 loaded_[0]->name()); 1235 loaded_[0]->name());
1236 EXPECT_EQ(std::string("The first extension that I made."), 1236 EXPECT_EQ(std::string("The first extension that I made."),
1237 loaded_[0]->description()); 1237 loaded_[0]->description());
1238 EXPECT_EQ(Manifest::INTERNAL, loaded_[0]->location()); 1238 EXPECT_EQ(Manifest::INTERNAL, loaded_[0]->location());
1239 EXPECT_TRUE(service_->GetExtensionById(loaded_[0]->id(), false)); 1239 EXPECT_TRUE(service_->GetExtensionById(loaded_[0]->id(), false));
1240 EXPECT_EQ(expected_num_extensions, service_->extensions()->size()); 1240 EXPECT_EQ(expected_num_extensions, service_->extensions()->size());
1241 1241
1242 ValidatePrefKeyCount(3);
1243 ValidateIntegerPref(good0, "state", Extension::ENABLED); 1242 ValidateIntegerPref(good0, "state", Extension::ENABLED);
1244 ValidateIntegerPref(good0, "location", Manifest::INTERNAL); 1243 ValidateIntegerPref(good0, "location", Manifest::INTERNAL);
1245 ValidateIntegerPref(good1, "state", Extension::ENABLED); 1244 ValidateIntegerPref(good1, "state", Extension::ENABLED);
1246 ValidateIntegerPref(good1, "location", Manifest::INTERNAL); 1245 ValidateIntegerPref(good1, "location", Manifest::INTERNAL);
1247 ValidateIntegerPref(good2, "state", Extension::ENABLED); 1246 ValidateIntegerPref(good2, "state", Extension::ENABLED);
1248 ValidateIntegerPref(good2, "location", Manifest::INTERNAL); 1247 ValidateIntegerPref(good2, "location", Manifest::INTERNAL);
1249 1248
1250 URLPatternSet expected_patterns; 1249 URLPatternSet expected_patterns;
1251 AddPattern(&expected_patterns, "file:///*"); 1250 AddPattern(&expected_patterns, "file:///*");
1252 AddPattern(&expected_patterns, "http://*.google.com/*"); 1251 AddPattern(&expected_patterns, "http://*.google.com/*");
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 // Remove it because we are not testing the pending extension manager's 1542 // Remove it because we are not testing the pending extension manager's
1544 // ability to download and install extensions. 1543 // ability to download and install extensions.
1545 EXPECT_TRUE(service_->pending_extension_manager()->Remove(pending_id)); 1544 EXPECT_TRUE(service_->pending_extension_manager()->Remove(pending_id));
1546 } 1545 }
1547 1546
1548 // Test installing extensions. This test tries to install few extensions using 1547 // Test installing extensions. This test tries to install few extensions using
1549 // crx files. If you need to change those crx files, feel free to repackage 1548 // crx files. If you need to change those crx files, feel free to repackage
1550 // them, throw away the key used and change the id's above. 1549 // them, throw away the key used and change the id's above.
1551 TEST_F(ExtensionServiceTest, InstallExtension) { 1550 TEST_F(ExtensionServiceTest, InstallExtension) {
1552 InitializeEmptyExtensionService(); 1551 InitializeEmptyExtensionService();
1552 int expected_pref_count = GetPrefKeyCount();
1553 1553
1554 // Extensions not enabled. 1554 // Extensions not enabled.
1555 set_extensions_enabled(false); 1555 set_extensions_enabled(false);
1556 base::FilePath path = data_dir_.AppendASCII("good.crx"); 1556 base::FilePath path = data_dir_.AppendASCII("good.crx");
1557 InstallCRX(path, INSTALL_FAILED); 1557 InstallCRX(path, INSTALL_FAILED);
1558 set_extensions_enabled(true); 1558 set_extensions_enabled(true);
1559 1559
1560 ValidatePrefKeyCount(0); 1560 ValidatePrefKeyCount(expected_pref_count);
1561 1561
1562 // A simple extension that should install without error. 1562 // A simple extension that should install without error.
1563 path = data_dir_.AppendASCII("good.crx"); 1563 path = data_dir_.AppendASCII("good.crx");
1564 InstallCRX(path, INSTALL_NEW); 1564 InstallCRX(path, INSTALL_NEW);
1565 // TODO(erikkay): verify the contents of the installed extension. 1565 // TODO(erikkay): verify the contents of the installed extension.
1566 1566
1567 int pref_count = 0; 1567 ValidatePrefKeyCount(++expected_pref_count);
1568 ValidatePrefKeyCount(++pref_count);
1569 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 1568 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
1570 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); 1569 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
1571 1570
1572 // An extension with page actions. 1571 // An extension with page actions.
1573 path = data_dir_.AppendASCII("page_action.crx"); 1572 path = data_dir_.AppendASCII("page_action.crx");
1574 InstallCRX(path, INSTALL_NEW); 1573 InstallCRX(path, INSTALL_NEW);
1575 ValidatePrefKeyCount(++pref_count); 1574 ValidatePrefKeyCount(++expected_pref_count);
1576 ValidateIntegerPref(page_action, "state", Extension::ENABLED); 1575 ValidateIntegerPref(page_action, "state", Extension::ENABLED);
1577 ValidateIntegerPref(page_action, "location", Manifest::INTERNAL); 1576 ValidateIntegerPref(page_action, "location", Manifest::INTERNAL);
1578 1577
1579 // Bad signature. 1578 // Bad signature.
1580 path = data_dir_.AppendASCII("bad_signature.crx"); 1579 path = data_dir_.AppendASCII("bad_signature.crx");
1581 InstallCRX(path, INSTALL_FAILED); 1580 InstallCRX(path, INSTALL_FAILED);
1582 ValidatePrefKeyCount(pref_count); 1581 ValidatePrefKeyCount(expected_pref_count);
1583 1582
1584 // 0-length extension file. 1583 // 0-length extension file.
1585 path = data_dir_.AppendASCII("not_an_extension.crx"); 1584 path = data_dir_.AppendASCII("not_an_extension.crx");
1586 InstallCRX(path, INSTALL_FAILED); 1585 InstallCRX(path, INSTALL_FAILED);
1587 ValidatePrefKeyCount(pref_count); 1586 ValidatePrefKeyCount(expected_pref_count);
1588 1587
1589 // Bad magic number. 1588 // Bad magic number.
1590 path = data_dir_.AppendASCII("bad_magic.crx"); 1589 path = data_dir_.AppendASCII("bad_magic.crx");
1591 InstallCRX(path, INSTALL_FAILED); 1590 InstallCRX(path, INSTALL_FAILED);
1592 ValidatePrefKeyCount(pref_count); 1591 ValidatePrefKeyCount(expected_pref_count);
1593 1592
1594 // Packed extensions may have folders or files that have underscores. 1593 // Packed extensions may have folders or files that have underscores.
1595 // This will only cause a warning, rather than a fatal error. 1594 // This will only cause a warning, rather than a fatal error.
1596 path = data_dir_.AppendASCII("bad_underscore.crx"); 1595 path = data_dir_.AppendASCII("bad_underscore.crx");
1597 InstallCRX(path, INSTALL_NEW); 1596 InstallCRX(path, INSTALL_NEW);
1598 ValidatePrefKeyCount(++pref_count); 1597 ValidatePrefKeyCount(++expected_pref_count);
1599 1598
1600 // TODO(erikkay): add more tests for many of the failure cases. 1599 // TODO(erikkay): add more tests for many of the failure cases.
1601 // TODO(erikkay): add tests for upgrade cases. 1600 // TODO(erikkay): add tests for upgrade cases.
1602 } 1601 }
1603 1602
1604 struct MockInstallObserver : public extensions::InstallObserver { 1603 struct MockInstallObserver : public extensions::InstallObserver {
1605 MockInstallObserver() { 1604 MockInstallObserver() {
1606 } 1605 }
1607 1606
1608 virtual ~MockInstallObserver() { 1607 virtual ~MockInstallObserver() {
(...skipping 21 matching lines...) Expand all
1630 virtual void OnExtensionLoaded(const Extension* extension) OVERRIDE { 1629 virtual void OnExtensionLoaded(const Extension* extension) OVERRIDE {
1631 } 1630 }
1632 1631
1633 virtual void OnExtensionUnloaded(const Extension* extension) OVERRIDE { 1632 virtual void OnExtensionUnloaded(const Extension* extension) OVERRIDE {
1634 } 1633 }
1635 1634
1636 virtual void OnExtensionUninstalled(const Extension* extension) OVERRIDE { 1635 virtual void OnExtensionUninstalled(const Extension* extension) OVERRIDE {
1637 last_extension_uninstalled = extension->id(); 1636 last_extension_uninstalled = extension->id();
1638 } 1637 }
1639 1638
1640 virtual void OnAppsReordered() OVERRIDE { 1639 virtual void OnAppListReordered() OVERRIDE {
1641 } 1640 }
1642 1641
1643 virtual void OnAppInstalledToAppList( 1642 virtual void OnAppInstalledToAppList(
1644 const std::string& extension_id) OVERRIDE { 1643 const std::string& extension_id) OVERRIDE {
1645 } 1644 }
1646 1645
1647 virtual void OnShutdown() OVERRIDE { 1646 virtual void OnShutdown() OVERRIDE {
1648 } 1647 }
1649 1648
1650 std::string last_extension_installed; 1649 std::string last_extension_installed;
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); 2340 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator());
2342 ASSERT_TRUE(creator->Run(input_directory, crx_path, privkey_path, 2341 ASSERT_TRUE(creator->Run(input_directory, crx_path, privkey_path,
2343 base::FilePath(), ExtensionCreator::kOverwriteCRX)); 2342 base::FilePath(), ExtensionCreator::kOverwriteCRX));
2344 2343
2345 InstallCRX(crx_path, INSTALL_NEW); 2344 InstallCRX(crx_path, INSTALL_NEW);
2346 } 2345 }
2347 2346
2348 TEST_F(ExtensionServiceTest, InstallTheme) { 2347 TEST_F(ExtensionServiceTest, InstallTheme) {
2349 InitializeEmptyExtensionService(); 2348 InitializeEmptyExtensionService();
2350 service_->Init(); 2349 service_->Init();
2350 int expected_pref_count = GetPrefKeyCount();
2351 2351
2352 // A theme. 2352 // A theme.
2353 base::FilePath path = data_dir_.AppendASCII("theme.crx"); 2353 base::FilePath path = data_dir_.AppendASCII("theme.crx");
2354 InstallCRX(path, INSTALL_NEW); 2354 InstallCRX(path, INSTALL_NEW);
2355 int pref_count = 0; 2355 ValidatePrefKeyCount(++expected_pref_count);
2356 ValidatePrefKeyCount(++pref_count);
2357 ValidateIntegerPref(theme_crx, "state", Extension::ENABLED); 2356 ValidateIntegerPref(theme_crx, "state", Extension::ENABLED);
2358 ValidateIntegerPref(theme_crx, "location", Manifest::INTERNAL); 2357 ValidateIntegerPref(theme_crx, "location", Manifest::INTERNAL);
2359 2358
2360 // A theme when extensions are disabled. Themes can be installed, even when 2359 // A theme when extensions are disabled. Themes can be installed, even when
2361 // extensions are disabled. 2360 // extensions are disabled.
2362 set_extensions_enabled(false); 2361 set_extensions_enabled(false);
2363 path = data_dir_.AppendASCII("theme2.crx"); 2362 path = data_dir_.AppendASCII("theme2.crx");
2364 InstallCRX(path, INSTALL_NEW); 2363 InstallCRX(path, INSTALL_NEW);
2365 ValidatePrefKeyCount(++pref_count); 2364 ValidatePrefKeyCount(++expected_pref_count);
2366 ValidateIntegerPref(theme2_crx, "state", Extension::ENABLED); 2365 ValidateIntegerPref(theme2_crx, "state", Extension::ENABLED);
2367 ValidateIntegerPref(theme2_crx, "location", Manifest::INTERNAL); 2366 ValidateIntegerPref(theme2_crx, "location", Manifest::INTERNAL);
2368 2367
2369 // A theme with extension elements. Themes cannot have extension elements, 2368 // A theme with extension elements. Themes cannot have extension elements,
2370 // so any such elements (like content scripts) should be ignored. 2369 // so any such elements (like content scripts) should be ignored.
2371 set_extensions_enabled(true); 2370 set_extensions_enabled(true);
2372 { 2371 {
2373 path = data_dir_.AppendASCII("theme_with_extension.crx"); 2372 path = data_dir_.AppendASCII("theme_with_extension.crx");
2374 const Extension* extension = InstallCRX(path, INSTALL_NEW); 2373 const Extension* extension = InstallCRX(path, INSTALL_NEW);
2375 ValidatePrefKeyCount(++pref_count); 2374 ValidatePrefKeyCount(++expected_pref_count);
2376 ASSERT_TRUE(extension); 2375 ASSERT_TRUE(extension);
2377 EXPECT_TRUE(extension->is_theme()); 2376 EXPECT_TRUE(extension->is_theme());
2378 EXPECT_EQ( 2377 EXPECT_EQ(
2379 0u, 2378 0u,
2380 extensions::ContentScriptsInfo::GetContentScripts(extension).size()); 2379 extensions::ContentScriptsInfo::GetContentScripts(extension).size());
2381 } 2380 }
2382 2381
2383 // A theme with image resources missing (misspelt path). 2382 // A theme with image resources missing (misspelt path).
2384 path = data_dir_.AppendASCII("theme_missing_image.crx"); 2383 path = data_dir_.AppendASCII("theme_missing_image.crx");
2385 InstallCRX(path, INSTALL_FAILED); 2384 InstallCRX(path, INSTALL_FAILED);
2386 ValidatePrefKeyCount(pref_count); 2385 ValidatePrefKeyCount(expected_pref_count);
2387 } 2386 }
2388 2387
2389 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) { 2388 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) {
2390 // Load. 2389 // Load.
2391 InitializeEmptyExtensionService(); 2390 InitializeEmptyExtensionService();
2392 service_->Init(); 2391 service_->Init();
2393 2392
2394 base::FilePath extension_path = data_dir_ 2393 base::FilePath extension_path = data_dir_
2395 .AppendASCII("theme_i18n"); 2394 .AppendASCII("theme_i18n");
2396 2395
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 const Extension* theme = PackAndInstallCRX(theme_path, INSTALL_NEW); 2508 const Extension* theme = PackAndInstallCRX(theme_path, INSTALL_NEW);
2510 2509
2511 EXPECT_EQ(0u, GetErrors().size()); 2510 EXPECT_EQ(0u, GetErrors().size());
2512 EXPECT_EQ(1u, service_->extensions()->size()); 2511 EXPECT_EQ(1u, service_->extensions()->size());
2513 EXPECT_EQ("name", theme->name()); 2512 EXPECT_EQ("name", theme->name());
2514 EXPECT_EQ("description", theme->description()); 2513 EXPECT_EQ("description", theme->description());
2515 } 2514 }
2516 2515
2517 TEST_F(ExtensionServiceTest, InstallApps) { 2516 TEST_F(ExtensionServiceTest, InstallApps) {
2518 InitializeEmptyExtensionService(); 2517 InitializeEmptyExtensionService();
2518 int expected_pref_count = GetPrefKeyCount();
2519 2519
2520 // An empty app. 2520 // An empty app.
2521 const Extension* app = PackAndInstallCRX(data_dir_.AppendASCII("app1"), 2521 const Extension* app = PackAndInstallCRX(data_dir_.AppendASCII("app1"),
2522 INSTALL_NEW); 2522 INSTALL_NEW);
2523 int pref_count = 0; 2523 ValidatePrefKeyCount(++expected_pref_count);
2524 ValidatePrefKeyCount(++pref_count);
2525 ASSERT_EQ(1u, service_->extensions()->size()); 2524 ASSERT_EQ(1u, service_->extensions()->size());
2526 ValidateIntegerPref(app->id(), "state", Extension::ENABLED); 2525 ValidateIntegerPref(app->id(), "state", Extension::ENABLED);
2527 ValidateIntegerPref(app->id(), "location", Manifest::INTERNAL); 2526 ValidateIntegerPref(app->id(), "location", Manifest::INTERNAL);
2528 2527
2529 // Another app with non-overlapping extent. Should succeed. 2528 // Another app with non-overlapping extent. Should succeed.
2530 PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); 2529 PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW);
2531 ValidatePrefKeyCount(++pref_count); 2530 ValidatePrefKeyCount(++expected_pref_count);
2532 2531
2533 // A third app whose extent overlaps the first. Should fail. 2532 // A third app whose extent overlaps the first. Should fail.
2534 PackAndInstallCRX(data_dir_.AppendASCII("app3"), INSTALL_FAILED); 2533 PackAndInstallCRX(data_dir_.AppendASCII("app3"), INSTALL_FAILED);
2535 ValidatePrefKeyCount(pref_count); 2534 ValidatePrefKeyCount(expected_pref_count);
2536 } 2535 }
2537 2536
2538 // Tests that file access is OFF by default. 2537 // Tests that file access is OFF by default.
2539 TEST_F(ExtensionServiceTest, DefaultFileAccess) { 2538 TEST_F(ExtensionServiceTest, DefaultFileAccess) {
2540 InitializeEmptyExtensionService(); 2539 InitializeEmptyExtensionService();
2541 const Extension* extension = 2540 const Extension* extension =
2542 PackAndInstallCRX(data_dir_ 2541 PackAndInstallCRX(data_dir_
2543 .AppendASCII("permissions") 2542 .AppendASCII("permissions")
2544 .AppendASCII("files"), 2543 .AppendASCII("files"),
2545 INSTALL_NEW); 2544 INSTALL_NEW);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 EXPECT_TRUE( 2609 EXPECT_TRUE(
2611 sorting->GetPageOrdinal(extension_misc::kWebStoreAppId).IsValid()); 2610 sorting->GetPageOrdinal(extension_misc::kWebStoreAppId).IsValid());
2612 EXPECT_TRUE( 2611 EXPECT_TRUE(
2613 sorting->GetAppLaunchOrdinal(extension_misc::kWebStoreAppId).IsValid()); 2612 sorting->GetAppLaunchOrdinal(extension_misc::kWebStoreAppId).IsValid());
2614 } 2613 }
2615 2614
2616 TEST_F(ExtensionServiceTest, InstallAppsWithUnlimitedStorage) { 2615 TEST_F(ExtensionServiceTest, InstallAppsWithUnlimitedStorage) {
2617 InitializeEmptyExtensionService(); 2616 InitializeEmptyExtensionService();
2618 EXPECT_TRUE(service_->extensions()->is_empty()); 2617 EXPECT_TRUE(service_->extensions()->is_empty());
2619 2618
2620 int pref_count = 0; 2619 int expected_pref_count = GetPrefKeyCount();
2621 2620
2622 // Install app1 with unlimited storage. 2621 // Install app1 with unlimited storage.
2623 const Extension* extension = 2622 const Extension* extension =
2624 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); 2623 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW);
2625 ValidatePrefKeyCount(++pref_count); 2624 ValidatePrefKeyCount(++expected_pref_count);
2626 ASSERT_EQ(1u, service_->extensions()->size()); 2625 ASSERT_EQ(1u, service_->extensions()->size());
2627 const std::string id1 = extension->id(); 2626 const std::string id1 = extension->id();
2628 EXPECT_TRUE(extension->HasAPIPermission( 2627 EXPECT_TRUE(extension->HasAPIPermission(
2629 APIPermission::kUnlimitedStorage)); 2628 APIPermission::kUnlimitedStorage));
2630 EXPECT_TRUE(extension->web_extent().MatchesURL( 2629 EXPECT_TRUE(extension->web_extent().MatchesURL(
2631 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); 2630 extensions::AppLaunchInfo::GetFullLaunchURL(extension)));
2632 const GURL origin1( 2631 const GURL origin1(
2633 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); 2632 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin());
2634 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 2633 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
2635 IsStorageUnlimited(origin1)); 2634 IsStorageUnlimited(origin1));
2636 2635
2637 // Install app2 from the same origin with unlimited storage. 2636 // Install app2 from the same origin with unlimited storage.
2638 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); 2637 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW);
2639 ValidatePrefKeyCount(++pref_count); 2638 ValidatePrefKeyCount(++expected_pref_count);
2640 ASSERT_EQ(2u, service_->extensions()->size()); 2639 ASSERT_EQ(2u, service_->extensions()->size());
2641 const std::string id2 = extension->id(); 2640 const std::string id2 = extension->id();
2642 EXPECT_TRUE(extension->HasAPIPermission( 2641 EXPECT_TRUE(extension->HasAPIPermission(
2643 APIPermission::kUnlimitedStorage)); 2642 APIPermission::kUnlimitedStorage));
2644 EXPECT_TRUE(extension->web_extent().MatchesURL( 2643 EXPECT_TRUE(extension->web_extent().MatchesURL(
2645 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); 2644 extensions::AppLaunchInfo::GetFullLaunchURL(extension)));
2646 const GURL origin2( 2645 const GURL origin2(
2647 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); 2646 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin());
2648 EXPECT_EQ(origin1, origin2); 2647 EXPECT_EQ(origin1, origin2);
2649 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 2648 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
(...skipping 11 matching lines...) Expand all
2661 UninstallExtension(id2, false); 2660 UninstallExtension(id2, false);
2662 EXPECT_EQ(0u, service_->extensions()->size()); 2661 EXPECT_EQ(0u, service_->extensions()->size());
2663 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()-> 2662 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->
2664 IsStorageUnlimited(origin2)); 2663 IsStorageUnlimited(origin2));
2665 } 2664 }
2666 2665
2667 TEST_F(ExtensionServiceTest, InstallAppsAndCheckStorageProtection) { 2666 TEST_F(ExtensionServiceTest, InstallAppsAndCheckStorageProtection) {
2668 InitializeEmptyExtensionService(); 2667 InitializeEmptyExtensionService();
2669 EXPECT_TRUE(service_->extensions()->is_empty()); 2668 EXPECT_TRUE(service_->extensions()->is_empty());
2670 2669
2671 int pref_count = 0; 2670 int expected_pref_count = GetPrefKeyCount();
2672 2671
2673 const Extension* extension = 2672 const Extension* extension =
2674 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); 2673 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW);
2675 ValidatePrefKeyCount(++pref_count); 2674 ValidatePrefKeyCount(++expected_pref_count);
2676 ASSERT_EQ(1u, service_->extensions()->size()); 2675 ASSERT_EQ(1u, service_->extensions()->size());
2677 EXPECT_TRUE(extension->is_app()); 2676 EXPECT_TRUE(extension->is_app());
2678 const std::string id1 = extension->id(); 2677 const std::string id1 = extension->id();
2679 const GURL origin1( 2678 const GURL origin1(
2680 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); 2679 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin());
2681 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 2680 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
2682 IsStorageProtected(origin1)); 2681 IsStorageProtected(origin1));
2683 2682
2684 // App 4 has a different origin (maps.google.com). 2683 // App 4 has a different origin (maps.google.com).
2685 extension = PackAndInstallCRX(data_dir_.AppendASCII("app4"), INSTALL_NEW); 2684 extension = PackAndInstallCRX(data_dir_.AppendASCII("app4"), INSTALL_NEW);
2686 ValidatePrefKeyCount(++pref_count); 2685 ValidatePrefKeyCount(++expected_pref_count);
2687 ASSERT_EQ(2u, service_->extensions()->size()); 2686 ASSERT_EQ(2u, service_->extensions()->size());
2688 const std::string id2 = extension->id(); 2687 const std::string id2 = extension->id();
2689 const GURL origin2( 2688 const GURL origin2(
2690 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); 2689 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin());
2691 ASSERT_NE(origin1, origin2); 2690 ASSERT_NE(origin1, origin2);
2692 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 2691 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
2693 IsStorageProtected(origin2)); 2692 IsStorageProtected(origin2));
2694 2693
2695 UninstallExtension(id1, false); 2694 UninstallExtension(id1, false);
2696 EXPECT_EQ(1u, service_->extensions()->size()); 2695 EXPECT_EQ(1u, service_->extensions()->size());
2697 2696
2698 UninstallExtension(id2, false); 2697 UninstallExtension(id2, false);
2699 2698
2700 EXPECT_TRUE(service_->extensions()->is_empty()); 2699 EXPECT_TRUE(service_->extensions()->is_empty());
2701 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()-> 2700 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->
2702 IsStorageProtected(origin1)); 2701 IsStorageProtected(origin1));
2703 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()-> 2702 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->
2704 IsStorageProtected(origin2)); 2703 IsStorageProtected(origin2));
2705 } 2704 }
2706 2705
2707 // Test that when an extension version is reinstalled, nothing happens. 2706 // Test that when an extension version is reinstalled, nothing happens.
2708 TEST_F(ExtensionServiceTest, Reinstall) { 2707 TEST_F(ExtensionServiceTest, Reinstall) {
2709 InitializeEmptyExtensionService(); 2708 InitializeEmptyExtensionService();
2709 int expected_pref_count = GetPrefKeyCount();
2710 2710
2711 // A simple extension that should install without error. 2711 // A simple extension that should install without error.
2712 base::FilePath path = data_dir_.AppendASCII("good.crx"); 2712 base::FilePath path = data_dir_.AppendASCII("good.crx");
2713 InstallCRX(path, INSTALL_NEW); 2713 InstallCRX(path, INSTALL_NEW);
2714 2714
2715 ValidatePrefKeyCount(1); 2715 ValidatePrefKeyCount(++expected_pref_count);
2716 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 2716 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
2717 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); 2717 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
2718 2718
2719 // Reinstall the same version, it should overwrite the previous one. 2719 // Reinstall the same version, it should overwrite the previous one.
2720 InstallCRX(path, INSTALL_UPDATED); 2720 InstallCRX(path, INSTALL_UPDATED);
2721 2721
2722 ValidatePrefKeyCount(1); 2722 ValidatePrefKeyCount(expected_pref_count);
2723 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 2723 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
2724 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); 2724 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
2725 } 2725 }
2726 2726
2727 // Test that we can determine if extensions came from the 2727 // Test that we can determine if extensions came from the
2728 // Chrome web store. 2728 // Chrome web store.
2729 TEST_F(ExtensionServiceTest, FromWebStore) { 2729 TEST_F(ExtensionServiceTest, FromWebStore) {
2730 InitializeEmptyExtensionService(); 2730 InitializeEmptyExtensionService();
2731 int expected_pref_count = GetPrefKeyCount();
2731 2732
2732 // A simple extension that should install without error. 2733 // A simple extension that should install without error.
2733 base::FilePath path = data_dir_.AppendASCII("good.crx"); 2734 base::FilePath path = data_dir_.AppendASCII("good.crx");
2734 // Not from web store. 2735 // Not from web store.
2735 const Extension* extension = InstallCRX(path, INSTALL_NEW); 2736 const Extension* extension = InstallCRX(path, INSTALL_NEW);
2736 std::string id = extension->id(); 2737 std::string id = extension->id();
2737 2738
2738 ValidatePrefKeyCount(1); 2739 ValidatePrefKeyCount(++expected_pref_count);
2739 ValidateBooleanPref(good_crx, "from_webstore", false); 2740 ValidateBooleanPref(good_crx, "from_webstore", false);
2740 ASSERT_FALSE(extension->from_webstore()); 2741 ASSERT_FALSE(extension->from_webstore());
2741 2742
2742 // Test install from web store. 2743 // Test install from web store.
2743 InstallCRXFromWebStore(path, INSTALL_UPDATED); // From web store. 2744 InstallCRXFromWebStore(path, INSTALL_UPDATED); // From web store.
2744 2745
2745 ValidatePrefKeyCount(1); 2746 ValidatePrefKeyCount(expected_pref_count);
2746 ValidateBooleanPref(good_crx, "from_webstore", true); 2747 ValidateBooleanPref(good_crx, "from_webstore", true);
2747 2748
2748 // Reload so extension gets reinitialized with new value. 2749 // Reload so extension gets reinitialized with new value.
2749 service_->ReloadExtensions(); 2750 service_->ReloadExtensions();
2750 extension = service_->GetExtensionById(id, false); 2751 extension = service_->GetExtensionById(id, false);
2751 ASSERT_TRUE(extension->from_webstore()); 2752 ASSERT_TRUE(extension->from_webstore());
2752 2753
2753 // Upgrade to version 2.0 2754 // Upgrade to version 2.0
2754 path = data_dir_.AppendASCII("good2.crx"); 2755 path = data_dir_.AppendASCII("good2.crx");
2755 UpdateExtension(good_crx, path, ENABLED); 2756 UpdateExtension(good_crx, path, ENABLED);
2756 ValidatePrefKeyCount(1); 2757 ValidatePrefKeyCount(expected_pref_count);
2757 ValidateBooleanPref(good_crx, "from_webstore", true); 2758 ValidateBooleanPref(good_crx, "from_webstore", true);
2758 } 2759 }
2759 2760
2760 // Test upgrading a signed extension. 2761 // Test upgrading a signed extension.
2761 TEST_F(ExtensionServiceTest, UpgradeSignedGood) { 2762 TEST_F(ExtensionServiceTest, UpgradeSignedGood) {
2762 InitializeEmptyExtensionService(); 2763 InitializeEmptyExtensionService();
2763 2764
2764 base::FilePath path = data_dir_.AppendASCII("good.crx"); 2765 base::FilePath path = data_dir_.AppendASCII("good.crx");
2765 const Extension* extension = InstallCRX(path, INSTALL_NEW); 2766 const Extension* extension = InstallCRX(path, INSTALL_NEW);
2766 std::string id = extension->id(); 2767 std::string id = extension->id();
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
4183 // Check that the LSO file has been removed. 4184 // Check that the LSO file has been removed.
4184 EXPECT_FALSE(base::PathExists(lso_file_path)); 4185 EXPECT_FALSE(base::PathExists(lso_file_path));
4185 4186
4186 // Check if the indexed db has disappeared too. 4187 // Check if the indexed db has disappeared too.
4187 EXPECT_FALSE(base::DirectoryExists(idb_path)); 4188 EXPECT_FALSE(base::DirectoryExists(idb_path));
4188 } 4189 }
4189 4190
4190 // Verifies app state is removed upon uninstall. 4191 // Verifies app state is removed upon uninstall.
4191 TEST_F(ExtensionServiceTest, ClearAppData) { 4192 TEST_F(ExtensionServiceTest, ClearAppData) {
4192 InitializeEmptyExtensionService(); 4193 InitializeEmptyExtensionService();
4194 int expected_pref_count = GetPrefKeyCount();
4195
4193 ExtensionCookieCallback callback; 4196 ExtensionCookieCallback callback;
4194 4197
4195 int pref_count = 0;
4196
4197 // Install app1 with unlimited storage. 4198 // Install app1 with unlimited storage.
4198 const Extension* extension = 4199 const Extension* extension =
4199 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); 4200 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW);
4200 ValidatePrefKeyCount(++pref_count); 4201 ValidatePrefKeyCount(++expected_pref_count);
4201 ASSERT_EQ(1u, service_->extensions()->size()); 4202 ASSERT_EQ(1u, service_->extensions()->size());
4202 const std::string id1 = extension->id(); 4203 const std::string id1 = extension->id();
4203 EXPECT_TRUE(extension->HasAPIPermission( 4204 EXPECT_TRUE(extension->HasAPIPermission(
4204 APIPermission::kUnlimitedStorage)); 4205 APIPermission::kUnlimitedStorage));
4205 const GURL origin1( 4206 const GURL origin1(
4206 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); 4207 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin());
4207 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 4208 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
4208 IsStorageUnlimited(origin1)); 4209 IsStorageUnlimited(origin1));
4209 std::string origin_id = webkit_database::GetIdentifierFromOrigin(origin1); 4210 std::string origin_id = webkit_database::GetIdentifierFromOrigin(origin1);
4210 4211
4211 // Install app2 from the same origin with unlimited storage. 4212 // Install app2 from the same origin with unlimited storage.
4212 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); 4213 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW);
4213 ValidatePrefKeyCount(++pref_count); 4214 ValidatePrefKeyCount(++expected_pref_count);
4214 ASSERT_EQ(2u, service_->extensions()->size()); 4215 ASSERT_EQ(2u, service_->extensions()->size());
4215 const std::string id2 = extension->id(); 4216 const std::string id2 = extension->id();
4216 EXPECT_TRUE(extension->HasAPIPermission( 4217 EXPECT_TRUE(extension->HasAPIPermission(
4217 APIPermission::kUnlimitedStorage)); 4218 APIPermission::kUnlimitedStorage));
4218 EXPECT_TRUE(extension->web_extent().MatchesURL( 4219 EXPECT_TRUE(extension->web_extent().MatchesURL(
4219 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); 4220 extensions::AppLaunchInfo::GetFullLaunchURL(extension)));
4220 const GURL origin2( 4221 const GURL origin2(
4221 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); 4222 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin());
4222 EXPECT_EQ(origin1, origin2); 4223 EXPECT_EQ(origin1, origin2);
4223 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 4224 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
4317 EXPECT_FALSE(base::PathExists(lso_file_path)); 4318 EXPECT_FALSE(base::PathExists(lso_file_path));
4318 4319
4319 // Check if the indexed db has disappeared too. 4320 // Check if the indexed db has disappeared too.
4320 EXPECT_FALSE(base::DirectoryExists(idb_path)); 4321 EXPECT_FALSE(base::DirectoryExists(idb_path));
4321 } 4322 }
4322 4323
4323 // Tests loading single extensions (like --load-extension) 4324 // Tests loading single extensions (like --load-extension)
4324 // Flaky crashes. http://crbug.com/231806 4325 // Flaky crashes. http://crbug.com/231806
4325 TEST_F(ExtensionServiceTest, DISABLED_LoadExtension) { 4326 TEST_F(ExtensionServiceTest, DISABLED_LoadExtension) {
4326 InitializeEmptyExtensionService(); 4327 InitializeEmptyExtensionService();
4328 int expected_pref_count = GetPrefKeyCount();
4327 4329
4328 base::FilePath ext1 = data_dir_ 4330 base::FilePath ext1 = data_dir_
4329 .AppendASCII("good") 4331 .AppendASCII("good")
4330 .AppendASCII("Extensions") 4332 .AppendASCII("Extensions")
4331 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 4333 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
4332 .AppendASCII("1.0.0.0"); 4334 .AppendASCII("1.0.0.0");
4333 extensions::UnpackedInstaller::Create(service_)->Load(ext1); 4335 extensions::UnpackedInstaller::Create(service_)->Load(ext1);
4334 base::RunLoop().RunUntilIdle(); 4336 base::RunLoop().RunUntilIdle();
4335 EXPECT_EQ(0u, GetErrors().size()); 4337 EXPECT_EQ(0u, GetErrors().size());
4336 ASSERT_EQ(1u, loaded_.size()); 4338 ASSERT_EQ(1u, loaded_.size());
4337 EXPECT_EQ(Manifest::UNPACKED, loaded_[0]->location()); 4339 EXPECT_EQ(Manifest::UNPACKED, loaded_[0]->location());
4338 EXPECT_EQ(1u, service_->extensions()->size()); 4340 EXPECT_EQ(1u, service_->extensions()->size());
4339 4341
4340 ValidatePrefKeyCount(1); 4342 ValidatePrefKeyCount(++expected_pref_count);
4341 4343
4342 base::FilePath no_manifest = data_dir_ 4344 base::FilePath no_manifest = data_dir_
4343 .AppendASCII("bad") 4345 .AppendASCII("bad")
4344 // .AppendASCII("Extensions") 4346 // .AppendASCII("Extensions")
4345 .AppendASCII("cccccccccccccccccccccccccccccccc") 4347 .AppendASCII("cccccccccccccccccccccccccccccccc")
4346 .AppendASCII("1"); 4348 .AppendASCII("1");
4347 extensions::UnpackedInstaller::Create(service_)->Load(no_manifest); 4349 extensions::UnpackedInstaller::Create(service_)->Load(no_manifest);
4348 base::RunLoop().RunUntilIdle(); 4350 base::RunLoop().RunUntilIdle();
4349 EXPECT_EQ(1u, GetErrors().size()); 4351 EXPECT_EQ(1u, GetErrors().size());
4350 ASSERT_EQ(1u, loaded_.size()); 4352 ASSERT_EQ(1u, loaded_.size());
4351 EXPECT_EQ(1u, service_->extensions()->size()); 4353 EXPECT_EQ(1u, service_->extensions()->size());
4352 4354
4353 // Test uninstall. 4355 // Test uninstall.
4354 std::string id = loaded_[0]->id(); 4356 std::string id = loaded_[0]->id();
4355 EXPECT_FALSE(unloaded_id_.length()); 4357 EXPECT_FALSE(unloaded_id_.length());
4356 service_->UninstallExtension(id, false, NULL); 4358 service_->UninstallExtension(id, false, NULL);
4357 base::RunLoop().RunUntilIdle(); 4359 base::RunLoop().RunUntilIdle();
4358 EXPECT_EQ(id, unloaded_id_); 4360 EXPECT_EQ(id, unloaded_id_);
4359 ASSERT_EQ(0u, loaded_.size()); 4361 ASSERT_EQ(0u, loaded_.size());
4360 EXPECT_EQ(0u, service_->extensions()->size()); 4362 EXPECT_EQ(0u, service_->extensions()->size());
4361 } 4363 }
4362 4364
4363 // Tests that we generate IDs when they are not specified in the manifest for 4365 // Tests that we generate IDs when they are not specified in the manifest for
4364 // --load-extension. 4366 // --load-extension.
4365 TEST_F(ExtensionServiceTest, GenerateID) { 4367 TEST_F(ExtensionServiceTest, GenerateID) {
4366 InitializeEmptyExtensionService(); 4368 InitializeEmptyExtensionService();
4369 int expected_pref_count = GetPrefKeyCount();
4367 4370
4368 base::FilePath no_id_ext = data_dir_.AppendASCII("no_id"); 4371 base::FilePath no_id_ext = data_dir_.AppendASCII("no_id");
4369 extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext); 4372 extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext);
4370 base::RunLoop().RunUntilIdle(); 4373 base::RunLoop().RunUntilIdle();
4371 EXPECT_EQ(0u, GetErrors().size()); 4374 EXPECT_EQ(0u, GetErrors().size());
4372 ASSERT_EQ(1u, loaded_.size()); 4375 ASSERT_EQ(1u, loaded_.size());
4373 ASSERT_TRUE(Extension::IdIsValid(loaded_[0]->id())); 4376 ASSERT_TRUE(Extension::IdIsValid(loaded_[0]->id()));
4374 EXPECT_EQ(loaded_[0]->location(), Manifest::UNPACKED); 4377 EXPECT_EQ(loaded_[0]->location(), Manifest::UNPACKED);
4375 4378
4376 ValidatePrefKeyCount(1); 4379 ValidatePrefKeyCount(++expected_pref_count);
4377 4380
4378 std::string previous_id = loaded_[0]->id(); 4381 std::string previous_id = loaded_[0]->id();
4379 4382
4380 // If we reload the same path, we should get the same extension ID. 4383 // If we reload the same path, we should get the same extension ID.
4381 extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext); 4384 extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext);
4382 base::RunLoop().RunUntilIdle(); 4385 base::RunLoop().RunUntilIdle();
4383 ASSERT_EQ(1u, loaded_.size()); 4386 ASSERT_EQ(1u, loaded_.size());
4384 ASSERT_EQ(previous_id, loaded_[0]->id()); 4387 ASSERT_EQ(previous_id, loaded_[0]->id());
4385 } 4388 }
4386 4389
(...skipping 13 matching lines...) Expand all
4400 testing::HasSubstr("Dictionary keys must be quoted."))); 4403 testing::HasSubstr("Dictionary keys must be quoted.")));
4401 ASSERT_EQ(0u, loaded_.size()); 4404 ASSERT_EQ(0u, loaded_.size());
4402 } 4405 }
4403 4406
4404 void ExtensionServiceTest::TestExternalProvider( 4407 void ExtensionServiceTest::TestExternalProvider(
4405 MockExtensionProvider* provider, Manifest::Location location) { 4408 MockExtensionProvider* provider, Manifest::Location location) {
4406 // Verify that starting with no providers loads no extensions. 4409 // Verify that starting with no providers loads no extensions.
4407 service_->Init(); 4410 service_->Init();
4408 ASSERT_EQ(0u, loaded_.size()); 4411 ASSERT_EQ(0u, loaded_.size());
4409 4412
4413 int expected_pref_count = GetPrefKeyCount();
4414
4410 provider->set_visit_count(0); 4415 provider->set_visit_count(0);
4411 4416
4412 // Register a test extension externally using the mock registry provider. 4417 // Register a test extension externally using the mock registry provider.
4413 base::FilePath source_path = data_dir_.AppendASCII("good.crx"); 4418 base::FilePath source_path = data_dir_.AppendASCII("good.crx");
4414 4419
4415 // Add the extension. 4420 // Add the extension.
4416 provider->UpdateOrAddExtension(good_crx, "1.0.0.0", source_path); 4421 provider->UpdateOrAddExtension(good_crx, "1.0.0.0", source_path);
4417 4422
4418 // Reloading extensions should find our externally registered extension 4423 // Reloading extensions should find our externally registered extension
4419 // and install it. 4424 // and install it.
4420 service_->CheckForExternalUpdates(); 4425 service_->CheckForExternalUpdates();
4421 content::WindowedNotificationObserver( 4426 content::WindowedNotificationObserver(
4422 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 4427 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
4423 content::NotificationService::AllSources()).Wait(); 4428 content::NotificationService::AllSources()).Wait();
4424 4429
4425 ASSERT_EQ(0u, GetErrors().size()); 4430 ASSERT_EQ(0u, GetErrors().size());
4426 ASSERT_EQ(1u, loaded_.size()); 4431 ASSERT_EQ(1u, loaded_.size());
4427 ASSERT_EQ(location, loaded_[0]->location()); 4432 ASSERT_EQ(location, loaded_[0]->location());
4428 ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString()); 4433 ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString());
4429 ValidatePrefKeyCount(1); 4434 ValidatePrefKeyCount(++expected_pref_count);
4430 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 4435 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
4431 ValidateIntegerPref(good_crx, "location", location); 4436 ValidateIntegerPref(good_crx, "location", location);
4432 4437
4433 // Reload extensions without changing anything. The extension should be 4438 // Reload extensions without changing anything. The extension should be
4434 // loaded again. 4439 // loaded again.
4435 loaded_.clear(); 4440 loaded_.clear();
4436 service_->ReloadExtensions(); 4441 service_->ReloadExtensions();
4437 base::RunLoop().RunUntilIdle(); 4442 base::RunLoop().RunUntilIdle();
4438 ASSERT_EQ(0u, GetErrors().size()); 4443 ASSERT_EQ(0u, GetErrors().size());
4439 ASSERT_EQ(1u, loaded_.size()); 4444 ASSERT_EQ(1u, loaded_.size());
4440 ValidatePrefKeyCount(1); 4445 ValidatePrefKeyCount(expected_pref_count);
4441 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 4446 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
4442 ValidateIntegerPref(good_crx, "location", location); 4447 ValidateIntegerPref(good_crx, "location", location);
4443 4448
4444 // Now update the extension with a new version. We should get upgraded. 4449 // Now update the extension with a new version. We should get upgraded.
4445 source_path = source_path.DirName().AppendASCII("good2.crx"); 4450 source_path = source_path.DirName().AppendASCII("good2.crx");
4446 provider->UpdateOrAddExtension(good_crx, "1.0.0.1", source_path); 4451 provider->UpdateOrAddExtension(good_crx, "1.0.0.1", source_path);
4447 4452
4448 loaded_.clear(); 4453 loaded_.clear();
4449 service_->CheckForExternalUpdates(); 4454 service_->CheckForExternalUpdates();
4450 content::WindowedNotificationObserver( 4455 content::WindowedNotificationObserver(
4451 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 4456 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
4452 content::NotificationService::AllSources()).Wait(); 4457 content::NotificationService::AllSources()).Wait();
4453 ASSERT_EQ(0u, GetErrors().size()); 4458 ASSERT_EQ(0u, GetErrors().size());
4454 ASSERT_EQ(1u, loaded_.size()); 4459 ASSERT_EQ(1u, loaded_.size());
4455 ASSERT_EQ("1.0.0.1", loaded_[0]->version()->GetString()); 4460 ASSERT_EQ("1.0.0.1", loaded_[0]->version()->GetString());
4456 ValidatePrefKeyCount(1); 4461 ValidatePrefKeyCount(expected_pref_count);
4457 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 4462 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
4458 ValidateIntegerPref(good_crx, "location", location); 4463 ValidateIntegerPref(good_crx, "location", location);
4459 4464
4460 // Uninstall the extension and reload. Nothing should happen because the 4465 // Uninstall the extension and reload. Nothing should happen because the
4461 // preference should prevent us from reinstalling. 4466 // preference should prevent us from reinstalling.
4462 std::string id = loaded_[0]->id(); 4467 std::string id = loaded_[0]->id();
4463 bool no_uninstall = 4468 bool no_uninstall =
4464 management_policy_->MustRemainEnabled(loaded_[0].get(), NULL); 4469 management_policy_->MustRemainEnabled(loaded_[0].get(), NULL);
4465 service_->UninstallExtension(id, false, NULL); 4470 service_->UninstallExtension(id, false, NULL);
4466 base::RunLoop().RunUntilIdle(); 4471 base::RunLoop().RunUntilIdle();
4467 4472
4468 base::FilePath install_path = extensions_install_dir_.AppendASCII(id); 4473 base::FilePath install_path = extensions_install_dir_.AppendASCII(id);
4469 if (no_uninstall) { 4474 if (no_uninstall) {
4470 // Policy controlled extensions should not have been touched by uninstall. 4475 // Policy controlled extensions should not have been touched by uninstall.
4471 ASSERT_TRUE(base::PathExists(install_path)); 4476 ASSERT_TRUE(base::PathExists(install_path));
4472 } else { 4477 } else {
4473 // The extension should also be gone from the install directory. 4478 // The extension should also be gone from the install directory.
4474 ASSERT_FALSE(base::PathExists(install_path)); 4479 ASSERT_FALSE(base::PathExists(install_path));
4475 loaded_.clear(); 4480 loaded_.clear();
4476 service_->CheckForExternalUpdates(); 4481 service_->CheckForExternalUpdates();
4477 base::RunLoop().RunUntilIdle(); 4482 base::RunLoop().RunUntilIdle();
4478 ASSERT_EQ(0u, loaded_.size()); 4483 ASSERT_EQ(0u, loaded_.size());
4479 ValidatePrefKeyCount(1); 4484 ValidatePrefKeyCount(expected_pref_count);
4480 ValidateIntegerPref(good_crx, "state", 4485 ValidateIntegerPref(good_crx, "state",
4481 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 4486 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
4482 ValidateIntegerPref(good_crx, "location", location); 4487 ValidateIntegerPref(good_crx, "location", location);
4483 4488
4484 // Now clear the preference and reinstall. 4489 // Now clear the preference and reinstall.
4485 SetPrefInteg(good_crx, "state", Extension::ENABLED); 4490 SetPrefInteg(good_crx, "state", Extension::ENABLED);
4486 4491
4487 loaded_.clear(); 4492 loaded_.clear();
4488 service_->CheckForExternalUpdates(); 4493 service_->CheckForExternalUpdates();
4489 content::WindowedNotificationObserver( 4494 content::WindowedNotificationObserver(
4490 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 4495 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
4491 content::NotificationService::AllSources()).Wait(); 4496 content::NotificationService::AllSources()).Wait();
4492 ASSERT_EQ(1u, loaded_.size()); 4497 ASSERT_EQ(1u, loaded_.size());
4493 } 4498 }
4494 ValidatePrefKeyCount(1); 4499 ValidatePrefKeyCount(expected_pref_count);
4495 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 4500 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
4496 ValidateIntegerPref(good_crx, "location", location); 4501 ValidateIntegerPref(good_crx, "location", location);
4497 4502
4498 if (management_policy_->MustRemainEnabled(loaded_[0].get(), NULL)) { 4503 if (management_policy_->MustRemainEnabled(loaded_[0].get(), NULL)) {
4499 EXPECT_EQ(2, provider->visit_count()); 4504 EXPECT_EQ(2, provider->visit_count());
4500 } else { 4505 } else {
4501 // Now test an externally triggered uninstall (deleting the registry key or 4506 // Now test an externally triggered uninstall (deleting the registry key or
4502 // the pref entry). 4507 // the pref entry).
4503 provider->RemoveExtension(good_crx); 4508 provider->RemoveExtension(good_crx);
4504 4509
4505 loaded_.clear(); 4510 loaded_.clear();
4506 service_->OnExternalProviderReady(provider); 4511 service_->OnExternalProviderReady(provider);
4507 base::RunLoop().RunUntilIdle(); 4512 base::RunLoop().RunUntilIdle();
4508 ASSERT_EQ(0u, loaded_.size()); 4513 ASSERT_EQ(0u, loaded_.size());
4509 ValidatePrefKeyCount(0); 4514 ValidatePrefKeyCount(--expected_pref_count);
4510 4515
4511 // The extension should also be gone from the install directory. 4516 // The extension should also be gone from the install directory.
4512 ASSERT_FALSE(base::PathExists(install_path)); 4517 ASSERT_FALSE(base::PathExists(install_path));
4513 4518
4514 // Now test the case where user uninstalls and then the extension is removed 4519 // Now test the case where user uninstalls and then the extension is removed
4515 // from the external provider. 4520 // from the external provider.
4516 provider->UpdateOrAddExtension(good_crx, "1.0.0.1", source_path); 4521 provider->UpdateOrAddExtension(good_crx, "1.0.0.1", source_path);
4517 service_->CheckForExternalUpdates(); 4522 service_->CheckForExternalUpdates();
4518 content::WindowedNotificationObserver( 4523 content::WindowedNotificationObserver(
4519 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 4524 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
4520 content::NotificationService::AllSources()).Wait(); 4525 content::NotificationService::AllSources()).Wait();
4521 4526
4522 ASSERT_EQ(1u, loaded_.size()); 4527 ASSERT_EQ(1u, loaded_.size());
4523 ASSERT_EQ(0u, GetErrors().size()); 4528 ASSERT_EQ(0u, GetErrors().size());
4524 4529
4525 // User uninstalls. 4530 // User uninstalls.
4526 loaded_.clear(); 4531 loaded_.clear();
4527 service_->UninstallExtension(id, false, NULL); 4532 service_->UninstallExtension(id, false, NULL);
4528 base::RunLoop().RunUntilIdle(); 4533 base::RunLoop().RunUntilIdle();
4529 ASSERT_EQ(0u, loaded_.size()); 4534 ASSERT_EQ(0u, loaded_.size());
4530 4535
4531 // Then remove the extension from the extension provider. 4536 // Then remove the extension from the extension provider.
4532 provider->RemoveExtension(good_crx); 4537 provider->RemoveExtension(good_crx);
4533 4538
4534 // Should still be at 0. 4539 // Should still be at 0.
4535 loaded_.clear(); 4540 loaded_.clear();
4536 extensions::InstalledLoader(service_).LoadAllExtensions(); 4541 extensions::InstalledLoader(service_).LoadAllExtensions();
4537 base::RunLoop().RunUntilIdle(); 4542 base::RunLoop().RunUntilIdle();
4538 ASSERT_EQ(0u, loaded_.size()); 4543 ASSERT_EQ(0u, loaded_.size());
4539 ValidatePrefKeyCount(1); 4544 ValidatePrefKeyCount(++expected_pref_count);
4540 4545
4541 EXPECT_EQ(5, provider->visit_count()); 4546 EXPECT_EQ(5, provider->visit_count());
4542 } 4547 }
4543 } 4548 }
4544 4549
4545 // Tests the external installation feature 4550 // Tests the external installation feature
4546 #if defined(OS_WIN) 4551 #if defined(OS_WIN)
4547 TEST_F(ExtensionServiceTest, ExternalInstallRegistry) { 4552 TEST_F(ExtensionServiceTest, ExternalInstallRegistry) {
4548 // This should all work, even when normal extension installation is disabled. 4553 // This should all work, even when normal extension installation is disabled.
4549 InitializeEmptyExtensionService(); 4554 InitializeEmptyExtensionService();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
4632 base::RunLoop().RunUntilIdle(); 4637 base::RunLoop().RunUntilIdle();
4633 4638
4634 ASSERT_EQ(0u, GetErrors().size()); 4639 ASSERT_EQ(0u, GetErrors().size());
4635 ASSERT_EQ(0u, loaded_.size()); 4640 ASSERT_EQ(0u, loaded_.size());
4636 } 4641 }
4637 4642
4638 // Test that running multiple update checks simultaneously does not 4643 // Test that running multiple update checks simultaneously does not
4639 // keep the update from succeeding. 4644 // keep the update from succeeding.
4640 TEST_F(ExtensionServiceTest, MultipleExternalUpdateCheck) { 4645 TEST_F(ExtensionServiceTest, MultipleExternalUpdateCheck) {
4641 InitializeEmptyExtensionService(); 4646 InitializeEmptyExtensionService();
4647 int expected_pref_count = GetPrefKeyCount();
4642 4648
4643 MockExtensionProvider* provider = 4649 MockExtensionProvider* provider =
4644 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF); 4650 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF);
4645 AddMockExternalProvider(provider); 4651 AddMockExternalProvider(provider);
4646 4652
4647 // Verify that starting with no providers loads no extensions. 4653 // Verify that starting with no providers loads no extensions.
4648 service_->Init(); 4654 service_->Init();
4649 ASSERT_EQ(0u, loaded_.size()); 4655 ASSERT_EQ(0u, loaded_.size());
4650 4656
4651 // Start two checks for updates. 4657 // Start two checks for updates.
(...skipping 17 matching lines...) Expand all
4669 service_->CheckForExternalUpdates(); 4675 service_->CheckForExternalUpdates();
4670 service_->CheckForExternalUpdates(); 4676 service_->CheckForExternalUpdates();
4671 content::WindowedNotificationObserver( 4677 content::WindowedNotificationObserver(
4672 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 4678 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
4673 content::NotificationService::AllSources()).Wait(); 4679 content::NotificationService::AllSources()).Wait();
4674 EXPECT_EQ(2, provider->visit_count()); 4680 EXPECT_EQ(2, provider->visit_count());
4675 ASSERT_EQ(0u, GetErrors().size()); 4681 ASSERT_EQ(0u, GetErrors().size());
4676 ASSERT_EQ(1u, loaded_.size()); 4682 ASSERT_EQ(1u, loaded_.size());
4677 ASSERT_EQ(Manifest::EXTERNAL_PREF, loaded_[0]->location()); 4683 ASSERT_EQ(Manifest::EXTERNAL_PREF, loaded_[0]->location());
4678 ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString()); 4684 ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString());
4679 ValidatePrefKeyCount(1); 4685 ValidatePrefKeyCount(++expected_pref_count);
4680 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 4686 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
4681 ValidateIntegerPref(good_crx, "location", Manifest::EXTERNAL_PREF); 4687 ValidateIntegerPref(good_crx, "location", Manifest::EXTERNAL_PREF);
4682 4688
4683 provider->RemoveExtension(good_crx); 4689 provider->RemoveExtension(good_crx);
4684 provider->set_visit_count(0); 4690 provider->set_visit_count(0);
4685 service_->CheckForExternalUpdates(); 4691 service_->CheckForExternalUpdates();
4686 service_->CheckForExternalUpdates(); 4692 service_->CheckForExternalUpdates();
4687 base::RunLoop().RunUntilIdle(); 4693 base::RunLoop().RunUntilIdle();
4688 4694
4689 // Two calls should cause two checks for external extensions. 4695 // Two calls should cause two checks for external extensions.
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
5049 loaded_[0]->url())); 5055 loaded_[0]->url()));
5050 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( 5056 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited(
5051 loaded_[1]->url())); 5057 loaded_[1]->url()));
5052 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( 5058 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited(
5053 loaded_[2]->url())); 5059 loaded_[2]->url()));
5054 } 5060 }
5055 5061
5056 // Tests ComponentLoader::Add(). 5062 // Tests ComponentLoader::Add().
5057 TEST_F(ExtensionServiceTest, ComponentExtensions) { 5063 TEST_F(ExtensionServiceTest, ComponentExtensions) {
5058 InitializeEmptyExtensionService(); 5064 InitializeEmptyExtensionService();
5065 int expected_pref_count = GetPrefKeyCount();
5059 5066
5060 // Component extensions should work even when extensions are disabled. 5067 // Component extensions should work even when extensions are disabled.
5061 set_extensions_enabled(false); 5068 set_extensions_enabled(false);
5062 5069
5063 base::FilePath path = data_dir_ 5070 base::FilePath path = data_dir_
5064 .AppendASCII("good") 5071 .AppendASCII("good")
5065 .AppendASCII("Extensions") 5072 .AppendASCII("Extensions")
5066 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 5073 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
5067 .AppendASCII("1.0.0.0"); 5074 .AppendASCII("1.0.0.0");
5068 5075
5069 std::string manifest; 5076 std::string manifest;
5070 ASSERT_TRUE(base::ReadFileToString( 5077 ASSERT_TRUE(base::ReadFileToString(
5071 path.Append(extensions::kManifestFilename), &manifest)); 5078 path.Append(extensions::kManifestFilename), &manifest));
5072 5079
5073 service_->component_loader()->Add(manifest, path); 5080 service_->component_loader()->Add(manifest, path);
5074 service_->Init(); 5081 service_->Init();
5075 5082
5076 // Note that we do not pump messages -- the extension should be loaded 5083 // Note that we do not pump messages -- the extension should be loaded
5077 // immediately. 5084 // immediately.
5078 5085
5079 EXPECT_EQ(0u, GetErrors().size()); 5086 EXPECT_EQ(0u, GetErrors().size());
5080 ASSERT_EQ(1u, loaded_.size()); 5087 ASSERT_EQ(1u, loaded_.size());
5081 EXPECT_EQ(Manifest::COMPONENT, loaded_[0]->location()); 5088 EXPECT_EQ(Manifest::COMPONENT, loaded_[0]->location());
5082 EXPECT_EQ(1u, service_->extensions()->size()); 5089 EXPECT_EQ(1u, service_->extensions()->size());
5083 5090
5084 // Component extensions get a prefs entry on first install. 5091 // Component extensions get a prefs entry on first install.
5085 ValidatePrefKeyCount(1); 5092 ValidatePrefKeyCount(++expected_pref_count);
5086 5093
5087 // Reload all extensions, and make sure it comes back. 5094 // Reload all extensions, and make sure it comes back.
5088 std::string extension_id = (*service_->extensions()->begin())->id(); 5095 std::string extension_id = (*service_->extensions()->begin())->id();
5089 loaded_.clear(); 5096 loaded_.clear();
5090 service_->ReloadExtensions(); 5097 service_->ReloadExtensions();
5091 ASSERT_EQ(1u, service_->extensions()->size()); 5098 ASSERT_EQ(1u, service_->extensions()->size());
5092 EXPECT_EQ(extension_id, (*service_->extensions()->begin())->id()); 5099 EXPECT_EQ(extension_id, (*service_->extensions()->begin())->id());
5093 } 5100 }
5094 5101
5095 namespace { 5102 namespace {
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
5752 GetById(good_crx))); 5759 GetById(good_crx)));
5753 EXPECT_EQ(ext_specifics->update_url(), info->update_url().spec()); 5760 EXPECT_EQ(ext_specifics->update_url(), info->update_url().spec());
5754 EXPECT_TRUE(info->is_from_sync()); 5761 EXPECT_TRUE(info->is_from_sync());
5755 EXPECT_TRUE(info->install_silently()); 5762 EXPECT_TRUE(info->install_silently());
5756 EXPECT_EQ(Manifest::INTERNAL, info->install_source()); 5763 EXPECT_EQ(Manifest::INTERNAL, info->install_source());
5757 // TODO(akalin): Figure out a way to test |info.ShouldAllowInstall()|. 5764 // TODO(akalin): Figure out a way to test |info.ShouldAllowInstall()|.
5758 } 5765 }
5759 5766
5760 TEST_F(ExtensionServiceTest, InstallPriorityExternalUpdateUrl) { 5767 TEST_F(ExtensionServiceTest, InstallPriorityExternalUpdateUrl) {
5761 InitializeEmptyExtensionService(); 5768 InitializeEmptyExtensionService();
5769 int expected_pref_count = GetPrefKeyCount();
5762 5770
5763 base::FilePath path = data_dir_.AppendASCII("good.crx"); 5771 base::FilePath path = data_dir_.AppendASCII("good.crx");
5764 InstallCRX(path, INSTALL_NEW); 5772 InstallCRX(path, INSTALL_NEW);
5765 ValidatePrefKeyCount(1u); 5773 ValidatePrefKeyCount(++expected_pref_count);
5766 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 5774 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
5767 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); 5775 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
5768 5776
5769 extensions::PendingExtensionManager* pending = 5777 extensions::PendingExtensionManager* pending =
5770 service_->pending_extension_manager(); 5778 service_->pending_extension_manager();
5771 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 5779 EXPECT_FALSE(pending->IsIdPending(kGoodId));
5772 5780
5773 // Skip install when the location is the same. 5781 // Skip install when the location is the same.
5774 EXPECT_FALSE( 5782 EXPECT_FALSE(
5775 service_->OnExternalExtensionUpdateUrlFound( 5783 service_->OnExternalExtensionUpdateUrlFound(
(...skipping 29 matching lines...) Expand all
5805 Version newer_version("2.0.0.0"); 5813 Version newer_version("2.0.0.0");
5806 5814
5807 // We don't want the extension to be installed. A path that doesn't 5815 // We don't want the extension to be installed. A path that doesn't
5808 // point to a valid CRX ensures this. 5816 // point to a valid CRX ensures this.
5809 const base::FilePath kInvalidPathToCrx = base::FilePath(); 5817 const base::FilePath kInvalidPathToCrx = base::FilePath();
5810 5818
5811 const int kCreationFlags = 0; 5819 const int kCreationFlags = 0;
5812 const bool kDontMarkAcknowledged = false; 5820 const bool kDontMarkAcknowledged = false;
5813 5821
5814 InitializeEmptyExtensionService(); 5822 InitializeEmptyExtensionService();
5823 int expected_pref_count = GetPrefKeyCount();
5815 5824
5816 // The test below uses install source constants to test that 5825 // The test below uses install source constants to test that
5817 // priority is enforced. It assumes a specific ranking of install 5826 // priority is enforced. It assumes a specific ranking of install
5818 // sources: Registry (EXTERNAL_REGISTRY) overrides external pref 5827 // sources: Registry (EXTERNAL_REGISTRY) overrides external pref
5819 // (EXTERNAL_PREF), and external pref overrides user install (INTERNAL). 5828 // (EXTERNAL_PREF), and external pref overrides user install (INTERNAL).
5820 // The following assertions verify these assumptions: 5829 // The following assertions verify these assumptions:
5821 ASSERT_EQ(Manifest::EXTERNAL_REGISTRY, 5830 ASSERT_EQ(Manifest::EXTERNAL_REGISTRY,
5822 Manifest::GetHigherPriorityLocation(Manifest::EXTERNAL_REGISTRY, 5831 Manifest::GetHigherPriorityLocation(Manifest::EXTERNAL_REGISTRY,
5823 Manifest::EXTERNAL_PREF)); 5832 Manifest::EXTERNAL_PREF));
5824 ASSERT_EQ(Manifest::EXTERNAL_REGISTRY, 5833 ASSERT_EQ(Manifest::EXTERNAL_REGISTRY,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
5883 service_->OnExternalExtensionFileFound( 5892 service_->OnExternalExtensionFileFound(
5884 kGoodId, &older_version, kInvalidPathToCrx, 5893 kGoodId, &older_version, kInvalidPathToCrx,
5885 Manifest::INTERNAL, kCreationFlags, kDontMarkAcknowledged)); 5894 Manifest::INTERNAL, kCreationFlags, kDontMarkAcknowledged));
5886 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5895 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5887 5896
5888 pending->Remove(kGoodId); 5897 pending->Remove(kGoodId);
5889 5898
5890 // Install the extension. 5899 // Install the extension.
5891 base::FilePath path = data_dir_.AppendASCII("good.crx"); 5900 base::FilePath path = data_dir_.AppendASCII("good.crx");
5892 const Extension* ext = InstallCRX(path, INSTALL_NEW); 5901 const Extension* ext = InstallCRX(path, INSTALL_NEW);
5893 ValidatePrefKeyCount(1u); 5902 ValidatePrefKeyCount(++expected_pref_count);
5894 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 5903 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
5895 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); 5904 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
5896 5905
5897 // Now test the logic of OnExternalExtensionFileFound() when the extension 5906 // Now test the logic of OnExternalExtensionFileFound() when the extension
5898 // being added is already installed. 5907 // being added is already installed.
5899 5908
5900 // Tests assume |older_version| is less than the installed version, and 5909 // Tests assume |older_version| is less than the installed version, and
5901 // |newer_version| is greater. Verify this: 5910 // |newer_version| is greater. Verify this:
5902 ASSERT_TRUE(older_version.IsOlderThan(ext->VersionString())); 5911 ASSERT_TRUE(older_version.IsOlderThan(ext->VersionString()));
5903 ASSERT_TRUE(ext->version()->IsOlderThan(newer_version.GetString())); 5912 ASSERT_TRUE(ext->version()->IsOlderThan(newer_version.GetString()));
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
6400 EXPECT_TRUE(notifications.CheckNotifications( 6409 EXPECT_TRUE(notifications.CheckNotifications(
6401 chrome::NOTIFICATION_EXTENSION_INSTALLED)); 6410 chrome::NOTIFICATION_EXTENSION_INSTALLED));
6402 6411
6403 EXPECT_TRUE(service_->GetInstalledExtension(id)); 6412 EXPECT_TRUE(service_->GetInstalledExtension(id));
6404 EXPECT_FALSE(service_->extensions()->Contains(id)); 6413 EXPECT_FALSE(service_->extensions()->Contains(id));
6405 EXPECT_TRUE(service_->blacklisted_extensions()->Contains(id)); 6414 EXPECT_TRUE(service_->blacklisted_extensions()->Contains(id));
6406 EXPECT_TRUE(service_->extension_prefs()->IsExtensionBlacklisted(id)); 6415 EXPECT_TRUE(service_->extension_prefs()->IsExtensionBlacklisted(id));
6407 EXPECT_TRUE( 6416 EXPECT_TRUE(
6408 service_->extension_prefs()->IsBlacklistedExtensionAcknowledged(id)); 6417 service_->extension_prefs()->IsBlacklistedExtensionAcknowledged(id));
6409 } 6418 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698