| 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_reader.h" | 10 #include "base/json_reader.h" |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 loop_.RunAllPending(); | 1190 loop_.RunAllPending(); |
| 1191 EXPECT_EQ(id, unloaded_id_); | 1191 EXPECT_EQ(id, unloaded_id_); |
| 1192 ASSERT_EQ(0u, loaded_.size()); | 1192 ASSERT_EQ(0u, loaded_.size()); |
| 1193 EXPECT_EQ(0u, service_->extensions()->size()); | 1193 EXPECT_EQ(0u, service_->extensions()->size()); |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 // Tests that we generate IDs when they are not specified in the manifest for | 1196 // Tests that we generate IDs when they are not specified in the manifest for |
| 1197 // --load-extension. | 1197 // --load-extension. |
| 1198 TEST_F(ExtensionsServiceTest, GenerateID) { | 1198 TEST_F(ExtensionsServiceTest, GenerateID) { |
| 1199 InitializeEmptyExtensionsService(); | 1199 InitializeEmptyExtensionsService(); |
| 1200 Extension::ResetGeneratedIdCounter(); | |
| 1201 | 1200 |
| 1202 FilePath extensions_path; | 1201 FilePath extensions_path; |
| 1203 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); | 1202 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); |
| 1204 extensions_path = extensions_path.AppendASCII("extensions"); | 1203 extensions_path = extensions_path.AppendASCII("extensions"); |
| 1205 | 1204 |
| 1206 FilePath no_id_ext = extensions_path.AppendASCII("no_id"); | 1205 FilePath no_id_ext = extensions_path.AppendASCII("no_id"); |
| 1207 service_->LoadExtension(no_id_ext); | 1206 service_->LoadExtension(no_id_ext); |
| 1208 loop_.RunAllPending(); | 1207 loop_.RunAllPending(); |
| 1209 EXPECT_EQ(0u, GetErrors().size()); | 1208 EXPECT_EQ(0u, GetErrors().size()); |
| 1210 ASSERT_EQ(1u, loaded_.size()); | 1209 ASSERT_EQ(1u, loaded_.size()); |
| 1211 std::string id1 = loaded_[0]->id(); | 1210 ASSERT_TRUE(Extension::IdIsValid(loaded_[0]->id())); |
| 1212 EXPECT_EQ(all_zero, id1); | |
| 1213 EXPECT_EQ("chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/", | |
| 1214 loaded_[0]->url().spec()); | |
| 1215 EXPECT_EQ(loaded_[0]->location(), Extension::LOAD); | 1211 EXPECT_EQ(loaded_[0]->location(), Extension::LOAD); |
| 1216 | 1212 |
| 1217 // --load-extension doesn't add entries to prefs | 1213 // --load-extension doesn't add entries to prefs |
| 1218 ValidatePrefKeyCount(0); | 1214 ValidatePrefKeyCount(0); |
| 1219 | 1215 |
| 1216 std::string previous_id = loaded_[0]->id(); |
| 1217 |
| 1218 // If we reload the same path, we should get the same extension ID. |
| 1220 service_->LoadExtension(no_id_ext); | 1219 service_->LoadExtension(no_id_ext); |
| 1221 loop_.RunAllPending(); | 1220 loop_.RunAllPending(); |
| 1222 std::string id2 = loaded_[1]->id(); | 1221 ASSERT_EQ(1u, loaded_.size()); |
| 1223 EXPECT_EQ(zero_n_one, id2); | 1222 ASSERT_EQ(previous_id, loaded_[0]->id()); |
| 1224 EXPECT_EQ("chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/", | |
| 1225 loaded_[1]->url().spec()); | |
| 1226 EXPECT_EQ(loaded_[1]->location(), Extension::LOAD); | |
| 1227 | |
| 1228 // --load-extension doesn't add entries to prefs | |
| 1229 ValidatePrefKeyCount(0); | |
| 1230 } | 1223 } |
| 1231 | 1224 |
| 1232 // Tests the external installation feature | 1225 // Tests the external installation feature |
| 1233 #if defined(OS_WIN) | 1226 #if defined(OS_WIN) |
| 1234 | 1227 |
| 1235 TEST_F(ExtensionsServiceTest, ExternalInstallRegistry) { | 1228 TEST_F(ExtensionsServiceTest, ExternalInstallRegistry) { |
| 1236 // This should all work, even when normal extension installation is disabled. | 1229 // This should all work, even when normal extension installation is disabled. |
| 1237 InitializeEmptyExtensionsService(); | 1230 InitializeEmptyExtensionsService(); |
| 1238 set_extensions_enabled(false); | 1231 set_extensions_enabled(false); |
| 1239 // Verify that starting with no providers loads no extensions. | 1232 // Verify that starting with no providers loads no extensions. |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1570 | 1563 |
| 1571 recorder.set_ready(false); | 1564 recorder.set_ready(false); |
| 1572 command_line.reset(new CommandLine(L"")); | 1565 command_line.reset(new CommandLine(L"")); |
| 1573 service = new ExtensionsService(&profile, command_line.get(), | 1566 service = new ExtensionsService(&profile, command_line.get(), |
| 1574 profile.GetPrefs(), install_dir, &loop, &loop, false); | 1567 profile.GetPrefs(), install_dir, &loop, &loop, false); |
| 1575 EXPECT_FALSE(service->extensions_enabled()); | 1568 EXPECT_FALSE(service->extensions_enabled()); |
| 1576 service->Init(); | 1569 service->Init(); |
| 1577 loop.RunAllPending(); | 1570 loop.RunAllPending(); |
| 1578 EXPECT_TRUE(recorder.ready()); | 1571 EXPECT_TRUE(recorder.ready()); |
| 1579 } | 1572 } |
| OLD | NEW |