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

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

Issue 9150016: Move creation and ownership of ResourceDispatcherHost and PluginService to content. This gives a ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 PluginPrefsFactory::GetInstance()->ForceRegisterPrefsForTest(prefs); 424 PluginPrefsFactory::GetInstance()->ForceRegisterPrefsForTest(prefs);
425 425
426 profile_.reset(profile); 426 profile_.reset(profile);
427 427
428 service_ = profile->CreateExtensionService( 428 service_ = profile->CreateExtensionService(
429 CommandLine::ForCurrentProcess(), 429 CommandLine::ForCurrentProcess(),
430 extensions_install_dir, 430 extensions_install_dir,
431 autoupdate_enabled); 431 autoupdate_enabled);
432 service_->set_extensions_enabled(true); 432 service_->set_extensions_enabled(true);
433 service_->set_show_extensions_prompts(false); 433 service_->set_show_extensions_prompts(false);
434 service_->set_use_utility_process_for_testing(false);
434 profile->set_extensions_service(service_); 435 profile->set_extensions_service(service_);
435 436
436 // When we start up, we want to make sure there is no external provider, 437 // When we start up, we want to make sure there is no external provider,
437 // since the ExtensionService on Windows will use the Registry as a default 438 // since the ExtensionService on Windows will use the Registry as a default
438 // provider and if there is something already registered there then it will 439 // provider and if there is something already registered there then it will
439 // interfere with the tests. Those tests that need an external provider 440 // interfere with the tests. Those tests that need an external provider
440 // will register one specifically. 441 // will register one specifically.
441 service_->ClearProvidersForTesting(); 442 service_->ClearProvidersForTesting();
442 443
443 expected_extensions_count_ = 0; 444 expected_extensions_count_ = 0;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 // method directly. Instead, use InstallCrx(), which waits for 590 // method directly. Instead, use InstallCrx(), which waits for
590 // the crx to be installed and does extra error checking. 591 // the crx to be installed and does extra error checking.
591 void StartCRXInstall(const FilePath& crx_path) { 592 void StartCRXInstall(const FilePath& crx_path) {
592 StartCRXInstall(crx_path, false); 593 StartCRXInstall(crx_path, false);
593 } 594 }
594 595
595 void StartCRXInstall(const FilePath& crx_path, bool from_webstore) { 596 void StartCRXInstall(const FilePath& crx_path, bool from_webstore) {
596 ASSERT_TRUE(file_util::PathExists(crx_path)) 597 ASSERT_TRUE(file_util::PathExists(crx_path))
597 << "Path does not exist: "<< crx_path.value().c_str(); 598 << "Path does not exist: "<< crx_path.value().c_str();
598 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); 599 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL));
600 installer->set_use_utility_process(false);
599 installer->set_allow_silent_install(true); 601 installer->set_allow_silent_install(true);
600 installer->set_is_gallery_install(from_webstore); 602 installer->set_is_gallery_install(from_webstore);
601 installer->InstallCrx(crx_path); 603 installer->InstallCrx(crx_path);
602 } 604 }
603 605
604 enum InstallState { 606 enum InstallState {
605 INSTALL_FAILED, 607 INSTALL_FAILED,
606 INSTALL_UPDATED, 608 INSTALL_UPDATED,
607 INSTALL_NEW 609 INSTALL_NEW
608 }; 610 };
(...skipping 28 matching lines...) Expand all
637 } 639 }
638 640
639 const Extension* InstallCRXWithLocation(const FilePath& crx_path, 641 const Extension* InstallCRXWithLocation(const FilePath& crx_path,
640 Extension::Location install_location, 642 Extension::Location install_location,
641 InstallState install_state) { 643 InstallState install_state) {
642 EXPECT_TRUE(file_util::PathExists(crx_path)) 644 EXPECT_TRUE(file_util::PathExists(crx_path))
643 << "Path does not exist: "<< crx_path.value().c_str(); 645 << "Path does not exist: "<< crx_path.value().c_str();
644 // no client (silent install) 646 // no client (silent install)
645 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); 647 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL));
646 648
649 installer->set_use_utility_process(false);
647 installer->set_install_source(install_location); 650 installer->set_install_source(install_location);
648 installer->InstallCrx(crx_path); 651 installer->InstallCrx(crx_path);
649 652
650 return WaitForCrxInstall(crx_path, install_state); 653 return WaitForCrxInstall(crx_path, install_state);
651 } 654 }
652 655
653 // Wait for a CrxInstaller to finish. Used by InstallCRX. 656 // Wait for a CrxInstaller to finish. Used by InstallCRX.
654 // Returns an Extension pointer if the install succeeded, NULL otherwise. 657 // Returns an Extension pointer if the install succeeded, NULL otherwise.
655 const Extension* WaitForCrxInstall(const FilePath& path, 658 const Extension* WaitForCrxInstall(const FilePath& path,
656 InstallState install_state) { 659 InstallState install_state) {
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 TEST_F(ExtensionServiceTest, InstallUserScript) { 1416 TEST_F(ExtensionServiceTest, InstallUserScript) {
1414 // The details of script conversion are tested elsewhere, this just tests 1417 // The details of script conversion are tested elsewhere, this just tests
1415 // integration with ExtensionService. 1418 // integration with ExtensionService.
1416 InitializeEmptyExtensionService(); 1419 InitializeEmptyExtensionService();
1417 1420
1418 FilePath path = data_dir_ 1421 FilePath path = data_dir_
1419 .AppendASCII("user_script_basic.user.js"); 1422 .AppendASCII("user_script_basic.user.js");
1420 1423
1421 ASSERT_TRUE(file_util::PathExists(path)); 1424 ASSERT_TRUE(file_util::PathExists(path));
1422 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); 1425 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL));
1426 installer->set_use_utility_process(false);
1423 installer->set_allow_silent_install(true); 1427 installer->set_allow_silent_install(true);
1424 installer->InstallUserScript( 1428 installer->InstallUserScript(
1425 path, 1429 path,
1426 GURL("http://www.aaronboodman.com/scripts/user_script_basic.user.js")); 1430 GURL("http://www.aaronboodman.com/scripts/user_script_basic.user.js"));
1427 1431
1428 loop_.RunAllPending(); 1432 loop_.RunAllPending();
1429 std::vector<string16> errors = GetErrors(); 1433 std::vector<string16> errors = GetErrors();
1430 EXPECT_TRUE(installed_) << "Nothing was installed."; 1434 EXPECT_TRUE(installed_) << "Nothing was installed.";
1431 ASSERT_EQ(1u, loaded_.size()) << "Nothing was loaded."; 1435 ASSERT_EQ(1u, loaded_.size()) << "Nothing was loaded.";
1432 EXPECT_EQ(0u, errors.size()) << "There were errors: " 1436 EXPECT_EQ(0u, errors.size()) << "There were errors: "
(...skipping 2945 matching lines...) Expand 10 before | Expand all | Expand 10 after
4378 ASSERT_FALSE(AddPendingSyncInstall()); 4382 ASSERT_FALSE(AddPendingSyncInstall());
4379 4383
4380 // Wait for the external source to install. 4384 // Wait for the external source to install.
4381 WaitForCrxInstall(crx_path_, INSTALL_NEW); 4385 WaitForCrxInstall(crx_path_, INSTALL_NEW);
4382 ASSERT_TRUE(IsCrxInstalled()); 4386 ASSERT_TRUE(IsCrxInstalled());
4383 4387
4384 // Now that the extension is installed, sync request should fail 4388 // Now that the extension is installed, sync request should fail
4385 // because the extension is already installed. 4389 // because the extension is already installed.
4386 ASSERT_FALSE(AddPendingSyncInstall()); 4390 ASSERT_FALSE(AddPendingSyncInstall());
4387 } 4391 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698