OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 .AppendASCII("good") | 496 .AppendASCII("good") |
497 .AppendASCII("Extensions"); | 497 .AppendASCII("Extensions"); |
498 FilePath pref_path = source_install_dir | 498 FilePath pref_path = source_install_dir |
499 .DirName() | 499 .DirName() |
500 .AppendASCII("Preferences"); | 500 .AppendASCII("Preferences"); |
501 InitializeInstalledExtensionsService(pref_path, source_install_dir); | 501 InitializeInstalledExtensionsService(pref_path, source_install_dir); |
502 | 502 |
503 service_->Init(); | 503 service_->Init(); |
504 loop_.RunAllPending(); | 504 loop_.RunAllPending(); |
505 | 505 |
506 std::vector<std::string> errors = GetErrors(); | |
507 for (std::vector<std::string>::iterator err = errors.begin(); | |
508 err != errors.end(); ++err) { | |
509 LOG(ERROR) << *err; | |
510 } | |
511 ASSERT_EQ(3u, loaded_.size()); | 506 ASSERT_EQ(3u, loaded_.size()); |
512 | 507 |
513 EXPECT_EQ(std::string(good0), loaded_[0]->id()); | 508 EXPECT_EQ(std::string(good0), loaded_[0]->id()); |
514 EXPECT_EQ(std::string("My extension 1"), | 509 EXPECT_EQ(std::string("My extension 1"), |
515 loaded_[0]->name()); | 510 loaded_[0]->name()); |
516 EXPECT_EQ(std::string("The first extension that I made."), | 511 EXPECT_EQ(std::string("The first extension that I made."), |
517 loaded_[0]->description()); | 512 loaded_[0]->description()); |
518 EXPECT_EQ(Extension::INTERNAL, loaded_[0]->location()); | 513 EXPECT_EQ(Extension::INTERNAL, loaded_[0]->location()); |
519 EXPECT_TRUE(service_->GetExtensionById(loaded_[0]->id())); | 514 EXPECT_TRUE(service_->GetExtensionById(loaded_[0]->id())); |
520 EXPECT_EQ(3u, service_->extensions()->size()); | 515 EXPECT_EQ(3u, service_->extensions()->size()); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 | 604 |
610 InitializeInstalledExtensionsService(pref_path, source_install_dir); | 605 InitializeInstalledExtensionsService(pref_path, source_install_dir); |
611 | 606 |
612 service_->Init(); | 607 service_->Init(); |
613 loop_.RunAllPending(); | 608 loop_.RunAllPending(); |
614 | 609 |
615 ASSERT_EQ(4u, GetErrors().size()); | 610 ASSERT_EQ(4u, GetErrors().size()); |
616 ASSERT_EQ(0u, loaded_.size()); | 611 ASSERT_EQ(0u, loaded_.size()); |
617 | 612 |
618 EXPECT_TRUE(MatchPattern(GetErrors()[0], | 613 EXPECT_TRUE(MatchPattern(GetErrors()[0], |
619 std::string("Could not load extension from '*'. * ") + | 614 std::string("Could not load extension from '*'. ") + |
620 base::JSONReader::kBadRootElementType)) << GetErrors()[0]; | 615 extension_manifest_errors::kManifestUnreadable)) << GetErrors()[0]; |
621 | 616 |
622 EXPECT_TRUE(MatchPattern(GetErrors()[1], | 617 EXPECT_TRUE(MatchPattern(GetErrors()[1], |
623 std::string("Could not load extension from '*'. ") + | 618 std::string("Could not load extension from '*'. ") + |
624 extension_manifest_errors::kManifestUnreadable)) << GetErrors()[1]; | 619 extension_manifest_errors::kManifestUnreadable)) << GetErrors()[1]; |
625 | 620 |
626 EXPECT_TRUE(MatchPattern(GetErrors()[2], | 621 EXPECT_TRUE(MatchPattern(GetErrors()[2], |
627 std::string("Could not load extension from '*'. ") + | 622 std::string("Could not load extension from '*'. ") + |
628 extension_manifest_errors::kMissingFile)) << GetErrors()[2]; | 623 extension_manifest_errors::kMissingFile)) << GetErrors()[2]; |
629 | 624 |
630 EXPECT_TRUE(MatchPattern(GetErrors()[3], | 625 EXPECT_TRUE(MatchPattern(GetErrors()[3], |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 | 1098 |
1104 // Load extensions. | 1099 // Load extensions. |
1105 service_->Init(); | 1100 service_->Init(); |
1106 loop_.RunAllPending(); | 1101 loop_.RunAllPending(); |
1107 | 1102 |
1108 std::vector<std::string> errors = GetErrors(); | 1103 std::vector<std::string> errors = GetErrors(); |
1109 for (std::vector<std::string>::iterator err = errors.begin(); | 1104 for (std::vector<std::string>::iterator err = errors.begin(); |
1110 err != errors.end(); ++err) { | 1105 err != errors.end(); ++err) { |
1111 LOG(ERROR) << *err; | 1106 LOG(ERROR) << *err; |
1112 } | 1107 } |
1113 EXPECT_EQ(2u, loaded_.size()); | 1108 ASSERT_EQ(2u, loaded_.size()); |
1114 | 1109 |
1115 EXPECT_NE(std::string(good0), loaded_[0]->id()); | 1110 EXPECT_NE(std::string(good0), loaded_[0]->id()); |
1116 EXPECT_NE(std::string(good0), loaded_[1]->id()); | 1111 EXPECT_NE(std::string(good0), loaded_[1]->id()); |
1117 } | 1112 } |
1118 | 1113 |
1119 // Tests uninstalling normal extensions | 1114 // Tests uninstalling normal extensions |
1120 TEST_F(ExtensionsServiceTest, UninstallExtension) { | 1115 TEST_F(ExtensionsServiceTest, UninstallExtension) { |
1121 InitializeEmptyExtensionsService(); | 1116 InitializeEmptyExtensionsService(); |
1122 FilePath extensions_path; | 1117 FilePath extensions_path; |
1123 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); | 1118 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 | 1562 |
1568 recorder.set_ready(false); | 1563 recorder.set_ready(false); |
1569 command_line.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); | 1564 command_line.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); |
1570 service = new ExtensionsService(&profile, command_line.get(), | 1565 service = new ExtensionsService(&profile, command_line.get(), |
1571 profile.GetPrefs(), install_dir, &loop, &loop, false); | 1566 profile.GetPrefs(), install_dir, &loop, &loop, false); |
1572 EXPECT_FALSE(service->extensions_enabled()); | 1567 EXPECT_FALSE(service->extensions_enabled()); |
1573 service->Init(); | 1568 service->Init(); |
1574 loop.RunAllPending(); | 1569 loop.RunAllPending(); |
1575 EXPECT_TRUE(recorder.ready()); | 1570 EXPECT_TRUE(recorder.ready()); |
1576 } | 1571 } |
OLD | NEW |