OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 2514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 2525 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
2526 MessageLoop loop; | 2526 MessageLoop loop; |
2527 BrowserThread ui_thread(BrowserThread::UI, &loop); | 2527 BrowserThread ui_thread(BrowserThread::UI, &loop); |
2528 BrowserThread file_thread(BrowserThread::FILE, &loop); | 2528 BrowserThread file_thread(BrowserThread::FILE, &loop); |
2529 scoped_ptr<CommandLine> command_line; | 2529 scoped_ptr<CommandLine> command_line; |
2530 scoped_refptr<ExtensionsService> service; | 2530 scoped_refptr<ExtensionsService> service; |
2531 FilePath install_dir = profile->GetPath() | 2531 FilePath install_dir = profile->GetPath() |
2532 .AppendASCII(ExtensionsService::kInstallDirectoryName); | 2532 .AppendASCII(ExtensionsService::kInstallDirectoryName); |
2533 | 2533 |
2534 // By default, we are enabled. | 2534 // By default, we are enabled. |
2535 command_line.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); | 2535 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM)); |
2536 service = profile->CreateExtensionsService(command_line.get(), | 2536 service = profile->CreateExtensionsService(command_line.get(), |
2537 install_dir); | 2537 install_dir); |
2538 EXPECT_TRUE(service->extensions_enabled()); | 2538 EXPECT_TRUE(service->extensions_enabled()); |
2539 service->Init(); | 2539 service->Init(); |
2540 loop.RunAllPending(); | 2540 loop.RunAllPending(); |
2541 EXPECT_TRUE(recorder.ready()); | 2541 EXPECT_TRUE(recorder.ready()); |
2542 | 2542 |
2543 // If either the command line or pref is set, we are disabled. | 2543 // If either the command line or pref is set, we are disabled. |
2544 recorder.set_ready(false); | 2544 recorder.set_ready(false); |
2545 profile.reset(new TestingProfile()); | 2545 profile.reset(new TestingProfile()); |
(...skipping 11 matching lines...) Expand all Loading... |
2557 service = profile->CreateExtensionsService(command_line.get(), | 2557 service = profile->CreateExtensionsService(command_line.get(), |
2558 install_dir); | 2558 install_dir); |
2559 EXPECT_FALSE(service->extensions_enabled()); | 2559 EXPECT_FALSE(service->extensions_enabled()); |
2560 service->Init(); | 2560 service->Init(); |
2561 loop.RunAllPending(); | 2561 loop.RunAllPending(); |
2562 EXPECT_TRUE(recorder.ready()); | 2562 EXPECT_TRUE(recorder.ready()); |
2563 | 2563 |
2564 recorder.set_ready(false); | 2564 recorder.set_ready(false); |
2565 profile.reset(new TestingProfile()); | 2565 profile.reset(new TestingProfile()); |
2566 profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true); | 2566 profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true); |
2567 command_line.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); | 2567 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM)); |
2568 service = profile->CreateExtensionsService(command_line.get(), | 2568 service = profile->CreateExtensionsService(command_line.get(), |
2569 install_dir); | 2569 install_dir); |
2570 EXPECT_FALSE(service->extensions_enabled()); | 2570 EXPECT_FALSE(service->extensions_enabled()); |
2571 service->Init(); | 2571 service->Init(); |
2572 loop.RunAllPending(); | 2572 loop.RunAllPending(); |
2573 EXPECT_TRUE(recorder.ready()); | 2573 EXPECT_TRUE(recorder.ready()); |
2574 | 2574 |
2575 // Explicitly delete all the resources used in this test. | 2575 // Explicitly delete all the resources used in this test. |
2576 profile.reset(); | 2576 profile.reset(); |
2577 service = NULL; | 2577 service = NULL; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2671 // Component extensions shouldn't get recourded in the prefs. | 2671 // Component extensions shouldn't get recourded in the prefs. |
2672 ValidatePrefKeyCount(0); | 2672 ValidatePrefKeyCount(0); |
2673 | 2673 |
2674 // Reload all extensions, and make sure it comes back. | 2674 // Reload all extensions, and make sure it comes back. |
2675 std::string extension_id = service_->extensions()->at(0)->id(); | 2675 std::string extension_id = service_->extensions()->at(0)->id(); |
2676 loaded_.clear(); | 2676 loaded_.clear(); |
2677 service_->ReloadExtensions(); | 2677 service_->ReloadExtensions(); |
2678 ASSERT_EQ(1u, service_->extensions()->size()); | 2678 ASSERT_EQ(1u, service_->extensions()->size()); |
2679 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 2679 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); |
2680 } | 2680 } |
OLD | NEW |