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 14973007: Auto-install/uninstall shared module dependencies for extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 7 years, 6 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 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 "hpiknbiabeeppbpihjehijgoemciehgk/2"))); 1443 "hpiknbiabeeppbpihjehijgoemciehgk/2")));
1444 EXPECT_FALSE(file_util::PathExists(extensions_install_dir_.AppendASCII( 1444 EXPECT_FALSE(file_util::PathExists(extensions_install_dir_.AppendASCII(
1445 "hpiknbiabeeppbpihjehijgoemciehgk/3"))); 1445 "hpiknbiabeeppbpihjehijgoemciehgk/3")));
1446 1446
1447 // Make sure update information got deleted. 1447 // Make sure update information got deleted.
1448 ExtensionPrefs* prefs = service_->extension_prefs(); 1448 ExtensionPrefs* prefs = service_->extension_prefs();
1449 EXPECT_FALSE( 1449 EXPECT_FALSE(
1450 prefs->GetDelayedInstallInfo("bjafgdebaacbbbecmhlhpofkepfkgcpa")); 1450 prefs->GetDelayedInstallInfo("bjafgdebaacbbbecmhlhpofkepfkgcpa"));
1451 } 1451 }
1452 1452
1453 // Test various cases for delayed install because of missing imports.
1454 TEST_F(ExtensionServiceTest, PendingImports) {
1455 InitPluginService();
1456
1457 base::FilePath source_install_dir = data_dir_
1458 .AppendASCII("pending_updates_with_imports")
1459 .AppendASCII("Extensions");
1460 base::FilePath pref_path = source_install_dir
1461 .DirName()
1462 .AppendASCII("Preferences");
1463
1464 InitializeInstalledExtensionService(pref_path, source_install_dir);
1465
1466 // Verify there are no pending extensions initially.
1467 EXPECT_FALSE(service_->pending_extension_manager()->HasPendingExtensions());
1468
1469 service_->Init();
1470 // Wait for GarbageCollectExtensions task to complete.
1471 loop_.RunUntilIdle();
1472
1473 // These extensions are used by the extensions we test below, they must be
1474 // installed.
1475 EXPECT_TRUE(file_util::PathExists(extensions_install_dir_.AppendASCII(
1476 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0")));
1477 EXPECT_TRUE(file_util::PathExists(extensions_install_dir_.AppendASCII(
1478 "hpiknbiabeeppbpihjehijgoemciehgk/2")));
1479
1480 // Each of these extensions should have been rejected because of dependencies
1481 // that cannot be satisfied.
1482 ExtensionPrefs* prefs = service_->extension_prefs();
1483 EXPECT_FALSE(
1484 prefs->GetDelayedInstallInfo("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
1485 EXPECT_FALSE(
1486 prefs->GetInstalledExtensionInfo("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
1487 EXPECT_FALSE(
1488 prefs->GetDelayedInstallInfo("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"));
1489 EXPECT_FALSE(
1490 prefs->GetInstalledExtensionInfo("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"));
1491 EXPECT_FALSE(
1492 prefs->GetDelayedInstallInfo("cccccccccccccccccccccccccccccccc"));
1493 EXPECT_FALSE(
1494 prefs->GetInstalledExtensionInfo("cccccccccccccccccccccccccccccccc"));
1495
1496 // Make sure the import started for the extension with a dependency.
1497 EXPECT_TRUE(
1498 prefs->GetDelayedInstallInfo("behllobkkfkfnphdnhnkndlbkcpglgmj"));
1499 EXPECT_EQ(ExtensionPrefs::DELAY_REASON_WAIT_FOR_IMPORTS,
1500 prefs->GetDelayedInstallReason("behllobkkfkfnphdnhnkndlbkcpglgmj"));
1501
1502 EXPECT_FALSE(file_util::PathExists(extensions_install_dir_.AppendASCII(
1503 "behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0")));
1504
1505 EXPECT_TRUE(service_->pending_extension_manager()->HasPendingExtensions());
1506 std::string pending_id("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
1507 EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(pending_id));
1508 // Remove it because we are not testing the pending extension manager's
1509 // ability to download and install extensions.
1510 EXPECT_TRUE(service_->pending_extension_manager()->Remove(pending_id));
1511 }
1512
1453 // Test installing extensions. This test tries to install few extensions using 1513 // Test installing extensions. This test tries to install few extensions using
1454 // crx files. If you need to change those crx files, feel free to repackage 1514 // crx files. If you need to change those crx files, feel free to repackage
1455 // them, throw away the key used and change the id's above. 1515 // them, throw away the key used and change the id's above.
1456 TEST_F(ExtensionServiceTest, InstallExtension) { 1516 TEST_F(ExtensionServiceTest, InstallExtension) {
1457 InitializeEmptyExtensionService(); 1517 InitializeEmptyExtensionService();
1458 1518
1459 // Extensions not enabled. 1519 // Extensions not enabled.
1460 set_extensions_enabled(false); 1520 set_extensions_enabled(false);
1461 base::FilePath path = data_dir_.AppendASCII("good.crx"); 1521 base::FilePath path = data_dir_.AppendASCII("good.crx");
1462 InstallCRX(path, INSTALL_FAILED); 1522 InstallCRX(path, INSTALL_FAILED);
(...skipping 4564 matching lines...) Expand 10 before | Expand all | Expand 10 after
6027 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF); 6087 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF);
6028 AddMockExternalProvider(provider); 6088 AddMockExternalProvider(provider);
6029 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); 6089 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path);
6030 6090
6031 service_->CheckForExternalUpdates(); 6091 service_->CheckForExternalUpdates();
6032 loop_.RunUntilIdle(); 6092 loop_.RunUntilIdle();
6033 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); 6093 EXPECT_TRUE(extensions::HasExternalInstallError(service_));
6034 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); 6094 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_));
6035 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); 6095 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore));
6036 } 6096 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/installed_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698