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

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

Issue 9718028: Allow autoupdate to update disabled extensions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review fixes and added tests. Created 8 years, 9 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "chrome/browser/extensions/autoupdate_interceptor.h" 7 #include "chrome/browser/extensions/autoupdate_interceptor.h"
8 #include "chrome/browser/extensions/extension_browsertest.h" 8 #include "chrome/browser/extensions/extension_browsertest.h"
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 "ogjcoiohnmldgjemafoockdghcjciccf")); 357 "ogjcoiohnmldgjemafoockdghcjciccf"));
358 358
359 // Make sure the extension state is the same as before. 359 // Make sure the extension state is the same as before.
360 ASSERT_EQ(size_before + 1, service->extensions()->size()); 360 ASSERT_EQ(size_before + 1, service->extensions()->size());
361 extension = service->GetExtensionById( 361 extension = service->GetExtensionById(
362 "ogjcoiohnmldgjemafoockdghcjciccf", false); 362 "ogjcoiohnmldgjemafoockdghcjciccf", false);
363 ASSERT_TRUE(extension); 363 ASSERT_TRUE(extension);
364 ASSERT_EQ("2.0", extension->VersionString()); 364 ASSERT_EQ("2.0", extension->VersionString());
365 } 365 }
366 366
367 // Tests extension autoupdate.
368 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, AutoUpdateDisabledExtensions) {
Matt Tytel 2012/03/20 20:36:37 There is some overlap with the above extension, bu
369 NotificationListener notification_listener;
370 FilePath basedir = test_data_dir_.AppendASCII("autoupdate");
371 // Note: This interceptor gets requests on the IO thread.
372 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor());
373 content::URLFetcher::SetEnableInterceptionForTests(true);
374
375 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest",
376 basedir.AppendASCII("manifest_v2.xml"));
377 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx",
378 basedir.AppendASCII("v2.crx"));
379
380 // Install version 1 of the extension.
381 ExtensionTestMessageListener listener1("v1 installed", false);
382 ExtensionService* service = browser()->profile()->GetExtensionService();
383 const size_t enabled_size_before = service->extensions()->size();
384 const size_t disabled_size_before = service->disabled_extensions()->size();
385 const Extension* extension =
386 InstallExtension(basedir.AppendASCII("v1.crx"), 1);
387 ASSERT_TRUE(extension);
388 listener1.WaitUntilSatisfied();
389 service->DisableExtension(extension->id());
390 ASSERT_EQ(disabled_size_before + 1, service->disabled_extensions()->size());
391 ASSERT_EQ(enabled_size_before, service->extensions()->size());
asargent_no_longer_on_chrome 2012/03/21 18:47:31 shouldn't this be "enabled_size_before - 1", since
Matt Tytel 2012/03/26 05:23:59 I create it, then disable it. So the number of ena
392 ASSERT_EQ("ogjcoiohnmldgjemafoockdghcjciccf", extension->id());
393 ASSERT_EQ("1.0", extension->VersionString());
394
395 // We don't want autoupdate blacklist checks.
396 service->updater()->set_blacklist_checks_enabled(false);
397
398 ExtensionTestMessageListener listener2("v2 installed", false);
399 // Run autoupdate and make sure version 2 of the extension was installed.
400 service->updater()->CheckNow();
401 ASSERT_TRUE(WaitForExtensionInstall());
402 ASSERT_EQ(disabled_size_before + 1, service->disabled_extensions()->size());
403 ASSERT_EQ(enabled_size_before, service->extensions()->size());
asargent_no_longer_on_chrome 2012/03/21 18:47:31 same question here
404 extension = service->GetExtensionById(
405 "ogjcoiohnmldgjemafoockdghcjciccf", true);
406 ASSERT_TRUE(extension);
407 ASSERT_EQ("2.0", extension->VersionString());
408
409 // The extension should have not made the callback because it is disabled.
410 // When we enabled it, it should then make the callback.
411 ASSERT_FALSE(listener2.was_satisfied());
asargent_no_longer_on_chrome 2012/03/21 18:47:31 If there were a bug where the extension did accide
Matt Tytel 2012/03/26 05:23:59 Yea I was debating putting this line in for that r
asargent_no_longer_on_chrome 2012/03/27 00:35:51 Seems fine to leave it in since you added the chec
412 service->EnableExtension(extension->id());
413 listener2.WaitUntilSatisfied();
414 ASSERT_TRUE(notification_listener.started());
415 ASSERT_TRUE(notification_listener.finished());
416 ASSERT_TRUE(ContainsKey(notification_listener.updates(),
417 "ogjcoiohnmldgjemafoockdghcjciccf"));
418 notification_listener.Reset();
419 }
420
367 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) { 421 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) {
368 ExtensionService* service = browser()->profile()->GetExtensionService(); 422 ExtensionService* service = browser()->profile()->GetExtensionService();
369 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; 423 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf";
370 // We don't want autoupdate blacklist checks. 424 // We don't want autoupdate blacklist checks.
371 service->updater()->set_blacklist_checks_enabled(false); 425 service->updater()->set_blacklist_checks_enabled(false);
372 426
373 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); 427 FilePath basedir = test_data_dir_.AppendASCII("autoupdate");
374 428
375 // Note: This interceptor gets requests on the IO thread. 429 // Note: This interceptor gets requests on the IO thread.
376 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); 430 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor());
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 std::string(kExtensionId) + ";http://localhost/autoupdate/manifest")); 653 std::string(kExtensionId) + ";http://localhost/autoupdate/manifest"));
600 } 654 }
601 ASSERT_TRUE(WaitForExtensionInstall()); 655 ASSERT_TRUE(WaitForExtensionInstall());
602 ASSERT_EQ(size_before + 1, service->extensions()->size()); 656 ASSERT_EQ(size_before + 1, service->extensions()->size());
603 extension = service->GetExtensionById(kExtensionId, false); 657 extension = service->GetExtensionById(kExtensionId, false);
604 ASSERT_TRUE(extension); 658 ASSERT_TRUE(extension);
605 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location()); 659 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location());
606 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); 660 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
607 EXPECT_TRUE(service->disabled_extensions()->is_empty()); 661 EXPECT_TRUE(service->disabled_extensions()->is_empty());
608 } 662 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service.h » ('j') | chrome/browser/extensions/updater/extension_updater.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698