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

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

Issue 2819023: Reworked ExtensionsService::AddPendingExtension(). (Closed)
Patch Set: Fixed browsertest test failure Created 10 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 EXPECT_FALSE(installed_) << path.value(); 422 EXPECT_FALSE(installed_) << path.value();
423 EXPECT_EQ(0u, loaded_.size()) << path.value(); 423 EXPECT_EQ(0u, loaded_.size()) << path.value();
424 EXPECT_EQ(1u, errors.size()) << path.value(); 424 EXPECT_EQ(1u, errors.size()) << path.value();
425 } 425 }
426 426
427 installed_ = NULL; 427 installed_ = NULL;
428 loaded_.clear(); 428 loaded_.clear();
429 ExtensionErrorReporter::GetInstance()->ClearErrors(); 429 ExtensionErrorReporter::GetInstance()->ClearErrors();
430 } 430 }
431 431
432 enum UpdateState {
433 FAILED_SILENTLY,
434 FAILED,
435 UPDATED,
436 INSTALLED,
437 ENABLED
438 };
439
432 void UpdateExtension(const std::string& id, const FilePath& in_path, 440 void UpdateExtension(const std::string& id, const FilePath& in_path,
433 bool should_succeed, bool should_install, 441 UpdateState expected_state) {
434 bool expect_report_on_failure) {
435 ASSERT_TRUE(file_util::PathExists(in_path)); 442 ASSERT_TRUE(file_util::PathExists(in_path));
436 443
437 // We need to copy this to a temporary location because Update() will delete 444 // We need to copy this to a temporary location because Update() will delete
438 // it. 445 // it.
439 FilePath path = temp_dir_.path(); 446 FilePath path = temp_dir_.path();
440 path = path.Append(in_path.BaseName()); 447 path = path.Append(in_path.BaseName());
441 ASSERT_TRUE(file_util::CopyFile(in_path, path)); 448 ASSERT_TRUE(file_util::CopyFile(in_path, path));
442 449
450 int previous_enabled_extension_count =
451 service_->extensions()->size();
452 int previous_installed_extension_count =
453 previous_enabled_extension_count +
454 service_->disabled_extensions()->size();
455
443 service_->UpdateExtension(id, path, GURL()); 456 service_->UpdateExtension(id, path, GURL());
444 loop_.RunAllPending(); 457 loop_.RunAllPending();
458
445 std::vector<std::string> errors = GetErrors(); 459 std::vector<std::string> errors = GetErrors();
460 int error_count = errors.size();
461 int enabled_extension_count =
462 service_->extensions()->size();
463 int installed_extension_count =
464 enabled_extension_count + service_->disabled_extensions()->size();
446 465
447 if (should_succeed) { 466 int expected_error_count = (expected_state == FAILED) ? 1 : 0;
448 EXPECT_EQ(0u, errors.size()) << path.value(); 467 EXPECT_EQ(expected_error_count, error_count) << path.value();
449 EXPECT_EQ(should_install ? 1u : 0u, service_->extensions()->size()); 468
469 if (expected_state <= FAILED) {
470 EXPECT_EQ(previous_enabled_extension_count,
471 enabled_extension_count);
472 EXPECT_EQ(previous_installed_extension_count,
473 installed_extension_count);
450 } else { 474 } else {
451 if (expect_report_on_failure) { 475 int expected_installed_extension_count =
452 EXPECT_EQ(1u, errors.size()) << path.value(); 476 (expected_state >= INSTALLED) ? 1 : 0;
453 } 477 int expected_enabled_extension_count =
478 (expected_state >= ENABLED) ? 1 : 0;
479 EXPECT_EQ(expected_installed_extension_count,
480 installed_extension_count);
481 EXPECT_EQ(expected_enabled_extension_count,
482 enabled_extension_count);
454 } 483 }
455 484
456 // Update() should delete the temporary input file. 485 // Update() should delete the temporary input file.
457 EXPECT_FALSE(file_util::PathExists(path)); 486 EXPECT_FALSE(file_util::PathExists(path));
458 } 487 }
459 488
460 void ValidatePrefKeyCount(size_t count) { 489 void ValidatePrefKeyCount(size_t count) {
461 DictionaryValue* dict = 490 DictionaryValue* dict =
462 prefs_->GetMutableDictionary(L"extensions.settings"); 491 prefs_->GetMutableDictionary(L"extensions.settings");
463 ASSERT_TRUE(dict != NULL); 492 ASSERT_TRUE(dict != NULL);
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 extensions_path = extensions_path.AppendASCII("extensions"); 1161 extensions_path = extensions_path.AppendASCII("extensions");
1133 1162
1134 FilePath path = extensions_path.AppendASCII("good.crx"); 1163 FilePath path = extensions_path.AppendASCII("good.crx");
1135 1164
1136 InstallExtension(path, true); 1165 InstallExtension(path, true);
1137 Extension* good = service_->extensions()->at(0); 1166 Extension* good = service_->extensions()->at(0);
1138 ASSERT_EQ("1.0.0.0", good->VersionString()); 1167 ASSERT_EQ("1.0.0.0", good->VersionString());
1139 ASSERT_EQ(good_crx, good->id()); 1168 ASSERT_EQ(good_crx, good->id());
1140 1169
1141 path = extensions_path.AppendASCII("good2.crx"); 1170 path = extensions_path.AppendASCII("good2.crx");
1142 UpdateExtension(good_crx, path, true, true, true); 1171 UpdateExtension(good_crx, path, ENABLED);
1143 ASSERT_EQ("1.0.0.1", loaded_[0]->version()->GetString()); 1172 ASSERT_EQ("1.0.0.1", loaded_[0]->version()->GetString());
1144 } 1173 }
1145 1174
1146 // Test updating a not-already-installed extension - this should fail 1175 // Test updating a not-already-installed extension - this should fail
1147 TEST_F(ExtensionsServiceTest, UpdateNotInstalledExtension) { 1176 TEST_F(ExtensionsServiceTest, UpdateNotInstalledExtension) {
1148 InitializeEmptyExtensionsService(); 1177 InitializeEmptyExtensionsService();
1149 FilePath extensions_path; 1178 FilePath extensions_path;
1150 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); 1179 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1151 extensions_path = extensions_path.AppendASCII("extensions"); 1180 extensions_path = extensions_path.AppendASCII("extensions");
1152 1181
1153 FilePath path = extensions_path.AppendASCII("good.crx"); 1182 FilePath path = extensions_path.AppendASCII("good.crx");
1154 UpdateExtension(good_crx, path, true, false, true); 1183 UpdateExtension(good_crx, path, UPDATED);
1155 loop_.RunAllPending(); 1184 loop_.RunAllPending();
1156 1185
1157 ASSERT_EQ(0u, service_->extensions()->size()); 1186 ASSERT_EQ(0u, service_->extensions()->size());
1158 ASSERT_FALSE(installed_); 1187 ASSERT_FALSE(installed_);
1159 ASSERT_EQ(0u, loaded_.size()); 1188 ASSERT_EQ(0u, loaded_.size());
1160 } 1189 }
1161 1190
1162 // Makes sure you can't downgrade an extension via UpdateExtension 1191 // Makes sure you can't downgrade an extension via UpdateExtension
1163 TEST_F(ExtensionsServiceTest, UpdateWillNotDowngrade) { 1192 TEST_F(ExtensionsServiceTest, UpdateWillNotDowngrade) {
1164 InitializeEmptyExtensionsService(); 1193 InitializeEmptyExtensionsService();
1165 FilePath extensions_path; 1194 FilePath extensions_path;
1166 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); 1195 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1167 extensions_path = extensions_path.AppendASCII("extensions"); 1196 extensions_path = extensions_path.AppendASCII("extensions");
1168 1197
1169 FilePath path = extensions_path.AppendASCII("good2.crx"); 1198 FilePath path = extensions_path.AppendASCII("good2.crx");
1170 1199
1171 InstallExtension(path, true); 1200 InstallExtension(path, true);
1172 Extension* good = service_->extensions()->at(0); 1201 Extension* good = service_->extensions()->at(0);
1173 ASSERT_EQ("1.0.0.1", good->VersionString()); 1202 ASSERT_EQ("1.0.0.1", good->VersionString());
1174 ASSERT_EQ(good_crx, good->id()); 1203 ASSERT_EQ(good_crx, good->id());
1175 1204
1176 // Change path from good2.crx -> good.crx 1205 // Change path from good2.crx -> good.crx
1177 path = extensions_path.AppendASCII("good.crx"); 1206 path = extensions_path.AppendASCII("good.crx");
1178 UpdateExtension(good_crx, path, false, false, true); 1207 UpdateExtension(good_crx, path, FAILED);
1179 ASSERT_EQ("1.0.0.1", service_->extensions()->at(0)->VersionString()); 1208 ASSERT_EQ("1.0.0.1", service_->extensions()->at(0)->VersionString());
1180 } 1209 }
1181 1210
1182 // Make sure calling update with an identical version does nothing 1211 // Make sure calling update with an identical version does nothing
1183 TEST_F(ExtensionsServiceTest, UpdateToSameVersionIsNoop) { 1212 TEST_F(ExtensionsServiceTest, UpdateToSameVersionIsNoop) {
1184 InitializeEmptyExtensionsService(); 1213 InitializeEmptyExtensionsService();
1185 FilePath extensions_path; 1214 FilePath extensions_path;
1186 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); 1215 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1187 extensions_path = extensions_path.AppendASCII("extensions"); 1216 extensions_path = extensions_path.AppendASCII("extensions");
1188 1217
1189 FilePath path = extensions_path.AppendASCII("good.crx"); 1218 FilePath path = extensions_path.AppendASCII("good.crx");
1190 1219
1191 InstallExtension(path, true); 1220 InstallExtension(path, true);
1192 Extension* good = service_->extensions()->at(0); 1221 Extension* good = service_->extensions()->at(0);
1193 ASSERT_EQ(good_crx, good->id()); 1222 ASSERT_EQ(good_crx, good->id());
1194 UpdateExtension(good_crx, path, false, false, false); 1223 UpdateExtension(good_crx, path, FAILED_SILENTLY);
1195 } 1224 }
1196 1225
1197 // Test adding a pending extension. 1226 // Test adding a pending extension.
1198 TEST_F(ExtensionsServiceTest, AddPendingExtension) { 1227 TEST_F(ExtensionsServiceTest, AddPendingExtension) {
1199 InitializeEmptyExtensionsService(); 1228 InitializeEmptyExtensionsService();
1200 1229
1201 const std::string kFakeId("fake-id"); 1230 const std::string kFakeId("fake-id");
1202 const GURL kFakeUpdateURL("http:://fake.update/url"); 1231 const GURL kFakeUpdateURL("http:://fake.update/url");
1203 scoped_ptr<Version> fake_version(Version::GetVersionFromString("4.3.2.1"));
1204 ASSERT_TRUE(fake_version.get());
1205 const bool kFakeIsTheme(false); 1232 const bool kFakeIsTheme(false);
1206 const bool kFakeInstallSilently(true); 1233 const bool kFakeInstallSilently(true);
1234 const Extension::State kFakeInitialState(Extension::ENABLED);
1235 const bool kFakeInitialIncognitoEnabled(false);
1207 1236
1208 service_->AddPendingExtension(kFakeId, kFakeUpdateURL, 1237 service_->AddPendingExtension(
1209 *fake_version, kFakeIsTheme, 1238 kFakeId, kFakeUpdateURL, kFakeIsTheme, kFakeInstallSilently,
1210 kFakeInstallSilently); 1239 kFakeInitialState, kFakeInitialIncognitoEnabled);
1211 PendingExtensionMap::const_iterator it = 1240 PendingExtensionMap::const_iterator it =
1212 service_->pending_extensions().find(kFakeId); 1241 service_->pending_extensions().find(kFakeId);
1213 ASSERT_TRUE(it != service_->pending_extensions().end()); 1242 ASSERT_TRUE(it != service_->pending_extensions().end());
1214 EXPECT_EQ(kFakeUpdateURL, it->second.update_url); 1243 EXPECT_EQ(kFakeUpdateURL, it->second.update_url);
1215 EXPECT_EQ(kFakeIsTheme, it->second.is_theme); 1244 EXPECT_EQ(kFakeIsTheme, it->second.is_theme);
1216 EXPECT_EQ(kFakeInstallSilently, it->second.install_silently); 1245 EXPECT_EQ(kFakeInstallSilently, it->second.install_silently);
1217 EXPECT_TRUE(it->second.version.Equals(*fake_version));
1218 } 1246 }
1219 1247
1220 namespace { 1248 namespace {
1221 const char kGoodId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; 1249 const char kGoodId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf";
1222 const char kGoodUpdateURL[] = "http://good.update/url"; 1250 const char kGoodUpdateURL[] = "http://good.update/url";
1223 const bool kGoodIsTheme = false; 1251 const bool kGoodIsTheme = false;
1224 const bool kGoodInstallSilently = true; 1252 const bool kGoodInstallSilently = true;
1225 const char kGoodVersion[] = "1.2.3.4"; 1253 const Extension::State kGoodInitialState = Extension::DISABLED;
1254 const bool kGoodInitialIncognitoEnabled = true;
1226 } // namespace 1255 } // namespace
1227 1256
1228 // Test updating a pending extension. 1257 // Test updating a pending extension.
1229 TEST_F(ExtensionsServiceTest, UpdatePendingExtension) { 1258 TEST_F(ExtensionsServiceTest, UpdatePendingExtension) {
1230 InitializeEmptyExtensionsService(); 1259 InitializeEmptyExtensionsService();
1231 scoped_ptr<Version> good_version( 1260 service_->AddPendingExtension(
1232 Version::GetVersionFromString(kGoodVersion)); 1261 kGoodId, GURL(kGoodUpdateURL), kGoodIsTheme,
1233 ASSERT_TRUE(good_version.get()); 1262 kGoodInstallSilently, kGoodInitialState,
1234 service_->AddPendingExtension(kGoodId, GURL(kGoodUpdateURL), 1263 kGoodInitialIncognitoEnabled);
1235 *good_version, kGoodIsTheme,
1236 kGoodInstallSilently);
1237 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), kGoodId)); 1264 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), kGoodId));
1238 1265
1239 FilePath extensions_path; 1266 FilePath extensions_path;
1240 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); 1267 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1241 extensions_path = extensions_path.AppendASCII("extensions"); 1268 extensions_path = extensions_path.AppendASCII("extensions");
1242 FilePath path = extensions_path.AppendASCII("good.crx"); 1269 FilePath path = extensions_path.AppendASCII("good.crx");
1243 UpdateExtension(kGoodId, path, true, true, false); 1270 UpdateExtension(kGoodId, path, INSTALLED);
1244 1271
1245 EXPECT_FALSE(ContainsKey(service_->pending_extensions(), kGoodId)); 1272 EXPECT_FALSE(ContainsKey(service_->pending_extensions(), kGoodId));
1273
1274 Extension* extension = service_->GetExtensionById(kGoodId, true);
1275 ASSERT_TRUE(extension);
1276
1277 bool enabled = service_->GetExtensionById(kGoodId, false);
1278 EXPECT_EQ(kGoodInitialState == Extension::ENABLED, enabled);
1279 EXPECT_EQ(kGoodInitialState,
1280 service_->extension_prefs()->GetExtensionState(extension->id()));
1281 EXPECT_EQ(kGoodInitialIncognitoEnabled,
1282 service_->IsIncognitoEnabled(extension));
1246 } 1283 }
1247 1284
1248 // TODO(akalin): Test updating a pending extension non-silently once 1285 // TODO(akalin): Test updating a pending extension non-silently once
1249 // we can mock out ExtensionInstallUI and inject our version into 1286 // we can mock out ExtensionInstallUI and inject our version into
1250 // UpdateExtension(). 1287 // UpdateExtension().
1251 1288
1252 // Test updating a pending extension with wrong is_theme. 1289 // Test updating a pending extension with wrong is_theme.
1253 TEST_F(ExtensionsServiceTest, UpdatePendingExtensionWrongIsTheme) { 1290 TEST_F(ExtensionsServiceTest, UpdatePendingExtensionWrongIsTheme) {
1254 InitializeEmptyExtensionsService(); 1291 InitializeEmptyExtensionsService();
1255 scoped_ptr<Version> good_version(
1256 Version::GetVersionFromString(kGoodVersion));
1257 ASSERT_TRUE(good_version.get());
1258 // Add pending extension with a flipped is_theme. 1292 // Add pending extension with a flipped is_theme.
1259 service_->AddPendingExtension(kGoodId, GURL(kGoodUpdateURL), 1293 service_->AddPendingExtension(
1260 *good_version, !kGoodIsTheme, 1294 kGoodId, GURL(kGoodUpdateURL), !kGoodIsTheme,
1261 kGoodInstallSilently); 1295 kGoodInstallSilently, kGoodInitialState,
1296 kGoodInitialIncognitoEnabled);
1262 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), kGoodId)); 1297 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), kGoodId));
1263 1298
1264 FilePath extensions_path; 1299 FilePath extensions_path;
1265 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); 1300 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1266 extensions_path = extensions_path.AppendASCII("extensions"); 1301 extensions_path = extensions_path.AppendASCII("extensions");
1267 FilePath path = extensions_path.AppendASCII("good.crx"); 1302 FilePath path = extensions_path.AppendASCII("good.crx");
1268 UpdateExtension(kGoodId, path, true, false, false); 1303 UpdateExtension(kGoodId, path, UPDATED);
1269 1304
1270 // TODO(akalin): Figure out how to check that the extensions 1305 // TODO(akalin): Figure out how to check that the extensions
1271 // directory is cleaned up properly in OnExtensionInstalled(). 1306 // directory is cleaned up properly in OnExtensionInstalled().
1272 1307
1273 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), kGoodId)); 1308 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), kGoodId));
1274 } 1309 }
1275 1310
1276 // Test updating a pending extension for one that is not pending. 1311 // Test updating a pending extension for one that is not pending.
1277 TEST_F(ExtensionsServiceTest, UpdatePendingExtensionNotPending) { 1312 TEST_F(ExtensionsServiceTest, UpdatePendingExtensionNotPending) {
1278 InitializeEmptyExtensionsService(); 1313 InitializeEmptyExtensionsService();
1279 1314
1280 FilePath extensions_path; 1315 FilePath extensions_path;
1281 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); 1316 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1282 extensions_path = extensions_path.AppendASCII("extensions"); 1317 extensions_path = extensions_path.AppendASCII("extensions");
1283 FilePath path = extensions_path.AppendASCII("good.crx"); 1318 FilePath path = extensions_path.AppendASCII("good.crx");
1284 UpdateExtension(kGoodId, path, true, false, false); 1319 UpdateExtension(kGoodId, path, UPDATED);
1285 1320
1286 EXPECT_FALSE(ContainsKey(service_->pending_extensions(), kGoodId)); 1321 EXPECT_FALSE(ContainsKey(service_->pending_extensions(), kGoodId));
1287 } 1322 }
1288 1323
1289 // Test updating a pending extension for one that is already 1324 // Test updating a pending extension for one that is already
1290 // installed. 1325 // installed.
1291 TEST_F(ExtensionsServiceTest, UpdatePendingExtensionAlreadyInstalled) { 1326 TEST_F(ExtensionsServiceTest, UpdatePendingExtensionAlreadyInstalled) {
1292 InitializeEmptyExtensionsService(); 1327 InitializeEmptyExtensionsService();
1293 1328
1294 FilePath extensions_path; 1329 FilePath extensions_path;
1295 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); 1330 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1296 extensions_path = extensions_path.AppendASCII("extensions"); 1331 extensions_path = extensions_path.AppendASCII("extensions");
1297 FilePath path = extensions_path.AppendASCII("good.crx"); 1332 FilePath path = extensions_path.AppendASCII("good.crx");
1298 InstallExtension(path, true); 1333 InstallExtension(path, true);
1299 ASSERT_EQ(1u, service_->extensions()->size()); 1334 ASSERT_EQ(1u, service_->extensions()->size());
1300 Extension* good = service_->extensions()->at(0); 1335 Extension* good = service_->extensions()->at(0);
1301 1336
1302 // Use AddPendingExtensionInternal() as AddPendingExtension() would 1337 // Use AddPendingExtensionInternal() as AddPendingExtension() would
1303 // balk. 1338 // balk.
1304 service_->AddPendingExtensionInternal( 1339 service_->AddPendingExtensionInternal(
1305 good->id(), good->update_url(), *good->version(), 1340 good->id(), good->update_url(), good->is_theme(),
1306 good->is_theme(), kGoodInstallSilently); 1341 kGoodInstallSilently, kGoodInitialState,
1342 kGoodInitialIncognitoEnabled);
1307 1343
1308 UpdateExtension(good->id(), path, true, true, false); 1344 UpdateExtension(good->id(), path, INSTALLED);
1309 1345
1310 EXPECT_FALSE(ContainsKey(service_->pending_extensions(), kGoodId)); 1346 EXPECT_FALSE(ContainsKey(service_->pending_extensions(), kGoodId));
1311 } 1347 }
1312 1348
1313 // Test pref settings for blacklist and unblacklist extensions. 1349 // Test pref settings for blacklist and unblacklist extensions.
1314 TEST_F(ExtensionsServiceTest, SetUnsetBlacklistInPrefs) { 1350 TEST_F(ExtensionsServiceTest, SetUnsetBlacklistInPrefs) {
1315 InitializeEmptyExtensionsService(); 1351 InitializeEmptyExtensionsService();
1316 std::vector<std::string> blacklist; 1352 std::vector<std::string> blacklist;
1317 blacklist.push_back(good0); 1353 blacklist.push_back(good0);
1318 blacklist.push_back("invalid_id"); // an invalid id 1354 blacklist.push_back("invalid_id"); // an invalid id
(...skipping 25 matching lines...) Expand all
1344 InitializeEmptyExtensionsService(); 1380 InitializeEmptyExtensionsService();
1345 FilePath extensions_path; 1381 FilePath extensions_path;
1346 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); 1382 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1347 extensions_path = extensions_path.AppendASCII("extensions"); 1383 extensions_path = extensions_path.AppendASCII("extensions");
1348 1384
1349 FilePath path = extensions_path.AppendASCII("good.crx"); 1385 FilePath path = extensions_path.AppendASCII("good.crx");
1350 1386
1351 InstallExtension(path, true); 1387 InstallExtension(path, true);
1352 Extension* good = service_->extensions()->at(0); 1388 Extension* good = service_->extensions()->at(0);
1353 EXPECT_EQ(good_crx, good->id()); 1389 EXPECT_EQ(good_crx, good->id());
1354 UpdateExtension(good_crx, path, false, false, false); 1390 UpdateExtension(good_crx, path, FAILED_SILENTLY);
1355 1391
1356 std::vector<std::string> blacklist; 1392 std::vector<std::string> blacklist;
1357 blacklist.push_back(good_crx); 1393 blacklist.push_back(good_crx);
1358 service_->UpdateExtensionBlacklist(blacklist); 1394 service_->UpdateExtensionBlacklist(blacklist);
1359 // Make sure pref is updated 1395 // Make sure pref is updated
1360 loop_.RunAllPending(); 1396 loop_.RunAllPending();
1361 1397
1362 // Now, the good_crx is blacklisted. 1398 // Now, the good_crx is blacklisted.
1363 ValidateBooleanPref(good_crx, L"blacklist", true); 1399 ValidateBooleanPref(good_crx, L"blacklist", true);
1364 EXPECT_EQ(0u, service_->extensions()->size()); 1400 EXPECT_EQ(0u, service_->extensions()->size());
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 // Component extensions shouldn't get recourded in the prefs. 2031 // Component extensions shouldn't get recourded in the prefs.
1996 ValidatePrefKeyCount(0); 2032 ValidatePrefKeyCount(0);
1997 2033
1998 // Reload all extensions, and make sure it comes back. 2034 // Reload all extensions, and make sure it comes back.
1999 std::string extension_id = service_->extensions()->at(0)->id(); 2035 std::string extension_id = service_->extensions()->at(0)->id();
2000 loaded_.clear(); 2036 loaded_.clear();
2001 service_->ReloadExtensions(); 2037 service_->ReloadExtensions();
2002 ASSERT_EQ(1u, service_->extensions()->size()); 2038 ASSERT_EQ(1u, service_->extensions()->size());
2003 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); 2039 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id());
2004 } 2040 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | chrome/browser/extensions/test_extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698