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

Unified Diff: chrome/browser/policy/policy_browsertest.cc

Issue 16102004: Adding browsertest to verify that updating forced-installed extensions is possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/policy_browsertest.cc
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 78070ed76f5f0821b7e8e0cd45d01a45818a4c35..3704777768b7288218890abe4a1f78e02b49959d 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -33,6 +33,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/unpacked_installer.h"
+#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/media_stream_devices_controller.h"
@@ -40,6 +41,7 @@
#include "chrome/browser/net/url_request_mock_util.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/policy/browser_policy_connector.h"
+#include "chrome/browser/policy/cloud/test_request_interceptor.h"
#include "chrome/browser/policy/mock_configuration_policy_provider.h"
#include "chrome/browser/policy/policy_map.h"
#include "chrome/browser/prefs/session_startup_pref.h"
@@ -154,6 +156,10 @@ const char kHostedAppCrxId[] = "kbmnembihfiondgfjekmnmcbddelicoi";
const base::FilePath::CharType kGoodCrxManifestName[] =
FILE_PATH_LITERAL("good_update_manifest.xml");
+const base::FilePath::CharType kGood2CrxManifestName[] =
+ FILE_PATH_LITERAL("good2_update_manifest.xml");
+const base::FilePath::CharType kGoodV1CrxManifestName[] =
+ FILE_PATH_LITERAL("good_v1_update_manifest.xml");
Joao da Silva 2013/05/28 08:27:31 Use consistent names for the files: "good_v1_*" an
csorba 2013/05/28 12:00:39 I tried to introduce as few new crx files as possi
const base::FilePath::CharType kGoodUnpackedExt[] =
FILE_PATH_LITERAL("good_unpacked");
const base::FilePath::CharType kAppUnpackedExt[] =
@@ -1304,12 +1310,12 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallForcelist) {
// Extensions that are force-installed come from an update URL, which defaults
// to the webstore. Use a mock URL for this test with an update manifest
- // that includes "good.crx".
+ // that includes "good_v1.crx".
base::FilePath path =
- base::FilePath(kTestExtensionsDir).Append(kGoodCrxManifestName);
+ base::FilePath(kTestExtensionsDir).Append(kGoodV1CrxManifestName);
GURL url(URLRequestMockHTTPJob::GetMockUrl(path));
- // Setting the forcelist extension should install "good.crx".
+ // Setting the forcelist extension should install "good_v1.crx".
base::ListValue forcelist;
forcelist.Append(base::Value::CreateStringValue(base::StringPrintf(
"%s;%s", kGoodCrxId, url.spec().c_str())));
@@ -1336,6 +1342,33 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallForcelist) {
// Loading other unpacked extensions are not blocked.
LoadUnpackedExtension(kAppUnpackedExt, true);
+
+ const std::string old_version_number =
+ service->GetExtensionById(kGoodCrxId, true)->version()->GetString();
+
+ base::FilePath test_path;
+ PathService::Get(chrome::DIR_TEST_DATA, &test_path);
Joao da Silva 2013/05/28 08:27:31 ASSERT_TRUE( ... )
csorba 2013/05/28 12:00:39 Done.
+
+ scoped_ptr<TestRequestInterceptor> interceptor;
Joao da Silva 2013/05/28 08:27:31 No need to have this in a scoped_ptr, just use a v
+ interceptor.reset(new TestRequestInterceptor("update.extension"));
+ interceptor->PushJobCallback(
+ TestRequestInterceptor::MockJob(
+ test_path.Append(kTestExtensionsDir).Append(kGood2CrxManifestName)));
+
+ // Updating the force-installed extension.
+ extensions::ExtensionUpdater* updater = service->updater();
+ extensions::ExtensionUpdater::CheckParams params;
+ params.install_immediately = true;
+ content::WindowedNotificationObserver update_observer(
+ chrome::NOTIFICATION_EXTENSION_INSTALLED,
+ content::NotificationService::AllSources());
+ updater->CheckNow(params);
+ update_observer.Wait();
+
+ const base::Version* new_version =
+ service->GetExtensionById(kGoodCrxId, true)->version();
Joao da Silva 2013/05/28 08:27:31 nit: indent
csorba 2013/05/28 12:00:39 Done.
+
+ EXPECT_FALSE(new_version->IsOlderThan(old_version_number));
Joao da Silva 2013/05/28 08:27:31 This would pass even if new_version == old_version
csorba 2013/05/28 12:00:39 Done + ASSERT_TRUE(new_version->IsValid()) added.
}
Joao da Silva 2013/05/28 08:27:31 Verify that the expected callback jobs were used b
csorba 2013/05/28 12:00:39 Done.
IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionAllowedTypes) {

Powered by Google App Engine
This is Rietveld 408576698