Commit 1fa235b6 authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Extensions] Update extensions unittests to use manifest v2

A bunch of extension unittests generate extension objects at runtime.
Update these to generate extensions with manifest_version: 2. Where
trivial, update these to use ExtensionBuilder (if they weren't already),
which uses manifest v2 by default.

Bug: 816679
Bug: 756488

Change-Id: Iec80a5dd288452e70e5dbdd1902180611f6bbcca
Reviewed-on: https://chromium-review.googlesource.com/1007501
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550180}
parent 74d30d0b
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/browser/uninstall_reason.h" #include "extensions/browser/uninstall_reason.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/manifest.h" #include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_constants.h"
#include "extensions/common/permissions/api_permission.h" #include "extensions/common/permissions/api_permission.h"
...@@ -281,18 +282,12 @@ class ExtensionGCMAppHandlerTest : public testing::Test { ...@@ -281,18 +282,12 @@ class ExtensionGCMAppHandlerTest : public testing::Test {
// Returns a barebones test extension. // Returns a barebones test extension.
scoped_refptr<Extension> CreateExtension() { scoped_refptr<Extension> CreateExtension() {
base::DictionaryValue manifest; scoped_refptr<Extension> extension =
manifest.SetString(manifest_keys::kVersion, "1.0.0.0"); ExtensionBuilder(kTestExtensionName)
manifest.SetString(manifest_keys::kName, kTestExtensionName); .AddPermission("gcm")
auto permission_list = std::make_unique<base::ListValue>(); .SetPath(temp_dir_.GetPath())
permission_list->AppendString("gcm"); .SetID("ldnnhddmnhbkjipkidpdiheffobcpfmf")
manifest.Set(manifest_keys::kPermissions, std::move(permission_list)); .Build();
std::string error;
scoped_refptr<Extension> extension = Extension::Create(
temp_dir_.GetPath(), Manifest::UNPACKED, manifest, Extension::NO_FLAGS,
"ldnnhddmnhbkjipkidpdiheffobcpfmf", &error);
EXPECT_TRUE(extension.get()) << error;
EXPECT_TRUE( EXPECT_TRUE(
extension->permissions_data()->HasAPIPermission(APIPermission::kGcm)); extension->permissions_data()->HasAPIPermission(APIPermission::kGcm));
......
...@@ -237,6 +237,7 @@ class ExtensionManagementServiceTest : public testing::Test { ...@@ -237,6 +237,7 @@ class ExtensionManagementServiceTest : public testing::Test {
base::DictionaryValue manifest_dict; base::DictionaryValue manifest_dict;
manifest_dict.SetString(manifest_keys::kName, "test"); manifest_dict.SetString(manifest_keys::kName, "test");
manifest_dict.SetString(manifest_keys::kVersion, version); manifest_dict.SetString(manifest_keys::kVersion, version);
manifest_dict.SetInteger(manifest_keys::kManifestVersion, 2);
manifest_dict.SetString(manifest_keys::kUpdateURL, update_url); manifest_dict.SetString(manifest_keys::kUpdateURL, update_url);
std::string error; std::string error;
scoped_refptr<const Extension> extension = scoped_refptr<const Extension> extension =
...@@ -275,6 +276,7 @@ class ExtensionAdminPolicyTest : public ExtensionManagementServiceTest { ...@@ -275,6 +276,7 @@ class ExtensionAdminPolicyTest : public ExtensionManagementServiceTest {
base::DictionaryValue* values) { base::DictionaryValue* values) {
values->SetString(extensions::manifest_keys::kName, "test"); values->SetString(extensions::manifest_keys::kName, "test");
values->SetString(extensions::manifest_keys::kVersion, "0.1"); values->SetString(extensions::manifest_keys::kVersion, "0.1");
values->SetInteger(extensions::manifest_keys::kManifestVersion, 2);
std::string error; std::string error;
extension_ = Extension::Create(base::FilePath(), location, *values, extension_ = Extension::Create(base::FilePath(), location, *values,
Extension::NO_FLAGS, &error); Extension::NO_FLAGS, &error);
......
...@@ -450,6 +450,7 @@ class ExtensionPrefsDelayedInstallInfo : public ExtensionPrefsTest { ...@@ -450,6 +450,7 @@ class ExtensionPrefsDelayedInstallInfo : public ExtensionPrefsTest {
base::DictionaryValue manifest; base::DictionaryValue manifest;
manifest.SetString(manifest_keys::kName, "test"); manifest.SetString(manifest_keys::kName, "test");
manifest.SetString(manifest_keys::kVersion, "1." + base::IntToString(num)); manifest.SetString(manifest_keys::kVersion, "1." + base::IntToString(num));
manifest.SetInteger(manifest_keys::kManifestVersion, 2);
base::FilePath path = base::FilePath path =
prefs_.extensions_dir().AppendASCII(base::IntToString(num)); prefs_.extensions_dir().AppendASCII(base::IntToString(num));
std::string errors; std::string errors;
...@@ -562,6 +563,7 @@ class ExtensionPrefsFinishDelayedInstallInfo : public ExtensionPrefsTest { ...@@ -562,6 +563,7 @@ class ExtensionPrefsFinishDelayedInstallInfo : public ExtensionPrefsTest {
base::DictionaryValue dictionary; base::DictionaryValue dictionary;
dictionary.SetString(manifest_keys::kName, "test"); dictionary.SetString(manifest_keys::kName, "test");
dictionary.SetString(manifest_keys::kVersion, "0.1"); dictionary.SetString(manifest_keys::kVersion, "0.1");
dictionary.SetInteger(manifest_keys::kManifestVersion, 2);
dictionary.SetString(manifest_keys::kBackgroundPage, "background.html"); dictionary.SetString(manifest_keys::kBackgroundPage, "background.html");
scoped_refptr<Extension> extension = scoped_refptr<Extension> extension =
prefs_.AddExtensionWithManifest(dictionary, Manifest::INTERNAL); prefs_.AddExtensionWithManifest(dictionary, Manifest::INTERNAL);
...@@ -572,6 +574,7 @@ class ExtensionPrefsFinishDelayedInstallInfo : public ExtensionPrefsTest { ...@@ -572,6 +574,7 @@ class ExtensionPrefsFinishDelayedInstallInfo : public ExtensionPrefsTest {
base::DictionaryValue manifest; base::DictionaryValue manifest;
manifest.SetString(manifest_keys::kName, "test"); manifest.SetString(manifest_keys::kName, "test");
manifest.SetString(manifest_keys::kVersion, "0.2"); manifest.SetString(manifest_keys::kVersion, "0.2");
manifest.SetInteger(manifest_keys::kManifestVersion, 2);
std::unique_ptr<base::ListValue> scripts(new base::ListValue); std::unique_ptr<base::ListValue> scripts(new base::ListValue);
scripts->AppendString("test.js"); scripts->AppendString("test.js");
manifest.Set(manifest_keys::kBackgroundScripts, std::move(scripts)); manifest.Set(manifest_keys::kBackgroundScripts, std::move(scripts));
...@@ -671,6 +674,7 @@ class ExtensionPrefsFlags : public ExtensionPrefsTest { ...@@ -671,6 +674,7 @@ class ExtensionPrefsFlags : public ExtensionPrefsTest {
base::DictionaryValue dictionary; base::DictionaryValue dictionary;
dictionary.SetString(manifest_keys::kName, "from_webstore"); dictionary.SetString(manifest_keys::kName, "from_webstore");
dictionary.SetString(manifest_keys::kVersion, "0.1"); dictionary.SetString(manifest_keys::kVersion, "0.1");
dictionary.SetInteger(manifest_keys::kManifestVersion, 2);
webstore_extension_ = prefs_.AddExtensionWithManifestAndFlags( webstore_extension_ = prefs_.AddExtensionWithManifestAndFlags(
dictionary, Manifest::INTERNAL, Extension::FROM_WEBSTORE); dictionary, Manifest::INTERNAL, Extension::FROM_WEBSTORE);
} }
...@@ -679,6 +683,7 @@ class ExtensionPrefsFlags : public ExtensionPrefsTest { ...@@ -679,6 +683,7 @@ class ExtensionPrefsFlags : public ExtensionPrefsTest {
base::DictionaryValue dictionary; base::DictionaryValue dictionary;
dictionary.SetString(manifest_keys::kName, "from_bookmark"); dictionary.SetString(manifest_keys::kName, "from_bookmark");
dictionary.SetString(manifest_keys::kVersion, "0.1"); dictionary.SetString(manifest_keys::kVersion, "0.1");
dictionary.SetInteger(manifest_keys::kManifestVersion, 2);
bookmark_extension_ = prefs_.AddExtensionWithManifestAndFlags( bookmark_extension_ = prefs_.AddExtensionWithManifestAndFlags(
dictionary, Manifest::INTERNAL, Extension::FROM_BOOKMARK); dictionary, Manifest::INTERNAL, Extension::FROM_BOOKMARK);
} }
...@@ -687,6 +692,7 @@ class ExtensionPrefsFlags : public ExtensionPrefsTest { ...@@ -687,6 +692,7 @@ class ExtensionPrefsFlags : public ExtensionPrefsTest {
base::DictionaryValue dictionary; base::DictionaryValue dictionary;
dictionary.SetString(manifest_keys::kName, "was_installed_by_default"); dictionary.SetString(manifest_keys::kName, "was_installed_by_default");
dictionary.SetString(manifest_keys::kVersion, "0.1"); dictionary.SetString(manifest_keys::kVersion, "0.1");
dictionary.SetInteger(manifest_keys::kManifestVersion, 2);
default_extension_ = prefs_.AddExtensionWithManifestAndFlags( default_extension_ = prefs_.AddExtensionWithManifestAndFlags(
dictionary, dictionary,
Manifest::INTERNAL, Manifest::INTERNAL,
...@@ -697,6 +703,7 @@ class ExtensionPrefsFlags : public ExtensionPrefsTest { ...@@ -697,6 +703,7 @@ class ExtensionPrefsFlags : public ExtensionPrefsTest {
base::DictionaryValue dictionary; base::DictionaryValue dictionary;
dictionary.SetString(manifest_keys::kName, "was_installed_by_oem"); dictionary.SetString(manifest_keys::kName, "was_installed_by_oem");
dictionary.SetString(manifest_keys::kVersion, "0.1"); dictionary.SetString(manifest_keys::kVersion, "0.1");
dictionary.SetInteger(manifest_keys::kManifestVersion, 2);
oem_extension_ = prefs_.AddExtensionWithManifestAndFlags( oem_extension_ = prefs_.AddExtensionWithManifestAndFlags(
dictionary, Manifest::INTERNAL, Extension::WAS_INSTALLED_BY_OEM); dictionary, Manifest::INTERNAL, Extension::WAS_INSTALLED_BY_OEM);
} }
...@@ -727,6 +734,7 @@ PrefsPrepopulatedTestBase::PrefsPrepopulatedTestBase() ...@@ -727,6 +734,7 @@ PrefsPrepopulatedTestBase::PrefsPrepopulatedTestBase()
std::string error; std::string error;
simple_dict.SetString(manifest_keys::kVersion, "1.0.0.0"); simple_dict.SetString(manifest_keys::kVersion, "1.0.0.0");
simple_dict.SetInteger(manifest_keys::kManifestVersion, 2);
simple_dict.SetString(manifest_keys::kName, "unused"); simple_dict.SetString(manifest_keys::kName, "unused");
extension1_ = Extension::Create( extension1_ = Extension::Create(
...@@ -925,11 +933,7 @@ class ExtensionPrefsComponentExtension : public ExtensionPrefsTest { ...@@ -925,11 +933,7 @@ class ExtensionPrefsComponentExtension : public ExtensionPrefsTest {
void Initialize() override { void Initialize() override {
// Adding a component extension. // Adding a component extension.
component_extension_ = component_extension_ =
ExtensionBuilder() ExtensionBuilder("a")
.SetManifest(DictionaryBuilder()
.Set(manifest_keys::kName, "a")
.Set(manifest_keys::kVersion, "0.1")
.Build())
.SetLocation(Manifest::COMPONENT) .SetLocation(Manifest::COMPONENT)
.SetPath(prefs_.extensions_dir().AppendASCII("a")) .SetPath(prefs_.extensions_dir().AppendASCII("a"))
.Build(); .Build();
...@@ -937,11 +941,7 @@ class ExtensionPrefsComponentExtension : public ExtensionPrefsTest { ...@@ -937,11 +941,7 @@ class ExtensionPrefsComponentExtension : public ExtensionPrefsTest {
// Adding a non component extension. // Adding a non component extension.
no_component_extension_ = no_component_extension_ =
ExtensionBuilder() ExtensionBuilder("b")
.SetManifest(DictionaryBuilder()
.Set(manifest_keys::kName, "b")
.Set(manifest_keys::kVersion, "0.1")
.Build())
.SetLocation(Manifest::INTERNAL) .SetLocation(Manifest::INTERNAL)
.SetPath(prefs_.extensions_dir().AppendASCII("b")) .SetPath(prefs_.extensions_dir().AppendASCII("b"))
.Build(); .Build();
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "extensions/common/extension_builder.h" #include "extensions/common/extension_builder.h"
#include "extensions/common/extension_paths.h" #include "extensions/common/extension_paths.h"
#include "extensions/common/file_util.h" #include "extensions/common/file_util.h"
#include "extensions/common/value_builder.h"
#include "extensions/test/test_extension_dir.h" #include "extensions/test/test_extension_dir.h"
#include "net/base/request_priority.h" #include "net/base/request_priority.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
...@@ -120,22 +121,13 @@ scoped_refptr<Extension> CreateWebStoreExtension() { ...@@ -120,22 +121,13 @@ scoped_refptr<Extension> CreateWebStoreExtension() {
} }
scoped_refptr<Extension> CreateTestResponseHeaderExtension() { scoped_refptr<Extension> CreateTestResponseHeaderExtension() {
base::DictionaryValue manifest; DictionaryBuilder web_accessible_resources;
manifest.SetString("name", "An extension with web-accessible resources"); web_accessible_resources.Set("web_accessible_resources",
manifest.SetString("version", "2"); ListBuilder().Append("test.dat").Build());
return ExtensionBuilder("An extension with web-accessible resources")
auto web_accessible_list = std::make_unique<base::ListValue>(); .MergeManifest(web_accessible_resources.Build())
web_accessible_list->AppendString("test.dat"); .SetPath(GetTestPath("response_headers"))
manifest.Set("web_accessible_resources", std::move(web_accessible_list)); .Build();
base::FilePath path = GetTestPath("response_headers");
std::string error;
scoped_refptr<Extension> extension(
Extension::Create(path, Manifest::UNPACKED, manifest,
Extension::NO_FLAGS, &error));
EXPECT_TRUE(extension.get()) << error;
return extension;
} }
// Helper function to create a |ResourceRequest| for testing purposes. // Helper function to create a |ResourceRequest| for testing purposes.
......
...@@ -75,6 +75,7 @@ TEST_F(ExtensionWebUITest, ExtensionURLOverride) { ...@@ -75,6 +75,7 @@ TEST_F(ExtensionWebUITest, ExtensionURLOverride) {
DictionaryBuilder manifest; DictionaryBuilder manifest;
manifest.Set(manifest_keys::kName, "ext1") manifest.Set(manifest_keys::kName, "ext1")
.Set(manifest_keys::kVersion, "0.1") .Set(manifest_keys::kVersion, "0.1")
.Set(manifest_keys::kManifestVersion, 2)
.Set(std::string(manifest_keys::kChromeURLOverrides), .Set(std::string(manifest_keys::kChromeURLOverrides),
DictionaryBuilder().Set("bookmarks", kOverrideResource).Build()); DictionaryBuilder().Set("bookmarks", kOverrideResource).Build());
scoped_refptr<Extension> ext_unpacked( scoped_refptr<Extension> ext_unpacked(
...@@ -110,6 +111,7 @@ TEST_F(ExtensionWebUITest, ExtensionURLOverride) { ...@@ -110,6 +111,7 @@ TEST_F(ExtensionWebUITest, ExtensionURLOverride) {
DictionaryBuilder manifest2; DictionaryBuilder manifest2;
manifest2.Set(manifest_keys::kName, "ext2") manifest2.Set(manifest_keys::kName, "ext2")
.Set(manifest_keys::kVersion, "0.1") .Set(manifest_keys::kVersion, "0.1")
.Set(manifest_keys::kManifestVersion, 2)
.Set(std::string(manifest_keys::kChromeURLOverrides), .Set(std::string(manifest_keys::kChromeURLOverrides),
DictionaryBuilder().Set("bookmarks", kOverrideResource2).Build()); DictionaryBuilder().Set("bookmarks", kOverrideResource2).Build());
scoped_refptr<Extension> ext_component( scoped_refptr<Extension> ext_component(
......
...@@ -2,13 +2,15 @@ ...@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/extensions/install_tracker.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "chrome/browser/extensions/active_install_data.h" #include "chrome/browser/extensions/active_install_data.h"
#include "chrome/browser/extensions/install_tracker.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_constants.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -27,20 +29,10 @@ const char kExtensionId2[] = "ahionppacfhbbmpmlcbkdgcpokfpflji"; ...@@ -27,20 +29,10 @@ const char kExtensionId2[] = "ahionppacfhbbmpmlcbkdgcpokfpflji";
const char kExtensionId3[] = "ladmcjmmmmgonboiadnaindoekpbljde"; const char kExtensionId3[] = "ladmcjmmmmgonboiadnaindoekpbljde";
scoped_refptr<Extension> CreateDummyExtension(const std::string& id) { scoped_refptr<Extension> CreateDummyExtension(const std::string& id) {
base::DictionaryValue manifest; return extensions::ExtensionBuilder("Dummy name")
manifest.SetString(extensions::manifest_keys::kVersion, "1.0"); .SetLocation(extensions::Manifest::INTERNAL)
manifest.SetString(extensions::manifest_keys::kName, "Dummy name"); .SetID(id)
.Build();
std::string error;
scoped_refptr<Extension> extension;
extension = Extension::Create(base::FilePath(),
extensions::Manifest::INTERNAL,
manifest,
Extension::NO_FLAGS,
id,
&error);
EXPECT_TRUE(extension.get()) << "Error creating extension: " << error;
return extension;
} }
} // namespace } // namespace
......
...@@ -64,6 +64,7 @@ class PermissionsBasedManagementPolicyProviderTest : public testing::Test { ...@@ -64,6 +64,7 @@ class PermissionsBasedManagementPolicyProviderTest : public testing::Test {
base::DictionaryValue manifest_dict; base::DictionaryValue manifest_dict;
manifest_dict.SetString(manifest_keys::kName, "test"); manifest_dict.SetString(manifest_keys::kName, "test");
manifest_dict.SetString(manifest_keys::kVersion, "0.1"); manifest_dict.SetString(manifest_keys::kVersion, "0.1");
manifest_dict.SetInteger(manifest_keys::kManifestVersion, 2);
if (required_permissions) { if (required_permissions) {
manifest_dict.Set(manifest_keys::kPermissions, manifest_dict.Set(manifest_keys::kPermissions,
required_permissions->CreateDeepCopy()); required_permissions->CreateDeepCopy());
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chrome/browser/extensions/test_extension_prefs.h" #include "chrome/browser/extensions/test_extension_prefs.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_constants.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -31,16 +32,8 @@ class StandardManagementPolicyProviderTest : public testing::Test { ...@@ -31,16 +32,8 @@ class StandardManagementPolicyProviderTest : public testing::Test {
return prefs_.prefs(); return prefs_.prefs();
} }
scoped_refptr<const Extension> CreateExtension(Manifest::Location location, scoped_refptr<const Extension> CreateExtension(Manifest::Location location) {
bool required) { return ExtensionBuilder("test").SetLocation(location).Build();
base::DictionaryValue values;
values.SetString(manifest_keys::kName, "test");
values.SetString(manifest_keys::kVersion, "0.1");
std::string error;
scoped_refptr<const Extension> extension = Extension::Create(
base::FilePath(), location, values, Extension::NO_FLAGS, &error);
CHECK(extension.get()) << error;
return extension;
} }
content::TestBrowserThreadBundle test_browser_thread_bundle_; content::TestBrowserThreadBundle test_browser_thread_bundle_;
...@@ -55,7 +48,7 @@ class StandardManagementPolicyProviderTest : public testing::Test { ...@@ -55,7 +48,7 @@ class StandardManagementPolicyProviderTest : public testing::Test {
// extension required by policy. // extension required by policy.
TEST_F(StandardManagementPolicyProviderTest, RequiredExtension) { TEST_F(StandardManagementPolicyProviderTest, RequiredExtension) {
scoped_refptr<const Extension> extension = scoped_refptr<const Extension> extension =
CreateExtension(Manifest::EXTERNAL_POLICY_DOWNLOAD, true); CreateExtension(Manifest::EXTERNAL_POLICY_DOWNLOAD);
base::string16 error16; base::string16 error16;
EXPECT_TRUE(provider_.UserMayLoad(extension.get(), &error16)); EXPECT_TRUE(provider_.UserMayLoad(extension.get(), &error16));
...@@ -73,7 +66,7 @@ TEST_F(StandardManagementPolicyProviderTest, RequiredExtension) { ...@@ -73,7 +66,7 @@ TEST_F(StandardManagementPolicyProviderTest, RequiredExtension) {
// extension required by policy. // extension required by policy.
TEST_F(StandardManagementPolicyProviderTest, NotRequiredExtension) { TEST_F(StandardManagementPolicyProviderTest, NotRequiredExtension) {
scoped_refptr<const Extension> extension = scoped_refptr<const Extension> extension =
CreateExtension(Manifest::INTERNAL, false); CreateExtension(Manifest::INTERNAL);
base::string16 error16; base::string16 error16;
EXPECT_TRUE(provider_.UserMayLoad(extension.get(), &error16)); EXPECT_TRUE(provider_.UserMayLoad(extension.get(), &error16));
......
...@@ -142,6 +142,7 @@ scoped_refptr<Extension> TestExtensionPrefs::AddExtension( ...@@ -142,6 +142,7 @@ scoped_refptr<Extension> TestExtensionPrefs::AddExtension(
base::DictionaryValue dictionary; base::DictionaryValue dictionary;
dictionary.SetString(manifest_keys::kName, name); dictionary.SetString(manifest_keys::kName, name);
dictionary.SetString(manifest_keys::kVersion, "0.1"); dictionary.SetString(manifest_keys::kVersion, "0.1");
dictionary.SetInteger(manifest_keys::kManifestVersion, 2);
return AddExtensionWithManifest(dictionary, Manifest::INTERNAL); return AddExtensionWithManifest(dictionary, Manifest::INTERNAL);
} }
......
...@@ -342,6 +342,7 @@ class MockService : public TestExtensionService { ...@@ -342,6 +342,7 @@ class MockService : public TestExtensionService {
base::StringPrintf("%d.0.0.0", i)); base::StringPrintf("%d.0.0.0", i));
manifest.SetString(manifest_keys::kName, manifest.SetString(manifest_keys::kName,
base::StringPrintf("Extension %d.%d", id, i)); base::StringPrintf("Extension %d.%d", id, i));
manifest.SetInteger(manifest_keys::kManifestVersion, 2);
if (update_url) if (update_url)
manifest.SetString(manifest_keys::kUpdateURL, *update_url); manifest.SetString(manifest_keys::kUpdateURL, *update_url);
scoped_refptr<Extension> e = scoped_refptr<Extension> e =
......
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
namespace { namespace {
const char kManifest[] = "{" const char kManifest[] =
"{"
" \"version\" : \"1.0.0.0\"," " \"version\" : \"1.0.0.0\","
" \"manifest_version\" : 2,"
" \"name\" : \"Test\"," " \"name\" : \"Test\","
" \"chrome_settings_overrides\" : {" " \"chrome_settings_overrides\" : {"
" \"homepage\" : \"http://www.homepage.com\"," " \"homepage\" : \"http://www.homepage.com\","
...@@ -40,6 +42,7 @@ const char kManifest[] = "{" ...@@ -40,6 +42,7 @@ const char kManifest[] = "{"
const char kPrepopulatedManifest[] = const char kPrepopulatedManifest[] =
"{" "{"
" \"version\" : \"1.0.0.0\"," " \"version\" : \"1.0.0.0\","
" \"manifest_version\" : 2,"
" \"name\" : \"Test\"," " \"name\" : \"Test\","
" \"chrome_settings_overrides\" : {" " \"chrome_settings_overrides\" : {"
" \"search_provider\" : {" " \"search_provider\" : {"
...@@ -50,8 +53,10 @@ const char kPrepopulatedManifest[] = ...@@ -50,8 +53,10 @@ const char kPrepopulatedManifest[] =
" }" " }"
"}"; "}";
const char kBrokenManifest[] = "{" const char kBrokenManifest[] =
"{"
" \"version\" : \"1.0.0.0\"," " \"version\" : \"1.0.0.0\","
" \"manifest_version\" : 2,"
" \"name\" : \"Test\"," " \"name\" : \"Test\","
" \"chrome_settings_overrides\" : {" " \"chrome_settings_overrides\" : {"
" \"homepage\" : \"{invalid}\"," " \"homepage\" : \"{invalid}\","
......
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
namespace { namespace {
const char kManifest[] = "{" const char kManifest[] =
"{"
" \"version\" : \"1.0.0.0\"," " \"version\" : \"1.0.0.0\","
" \"manifest_version\" : 2,"
" \"name\" : \"Test\"," " \"name\" : \"Test\","
" \"chrome_ui_overrides\" : {" " \"chrome_ui_overrides\" : {"
" \"bookmarks_ui\" : {" " \"bookmarks_ui\" : {"
...@@ -30,8 +32,10 @@ const char kManifest[] = "{" ...@@ -30,8 +32,10 @@ const char kManifest[] = "{"
" }" " }"
"}"; "}";
const char kBrokenManifest[] = "{" const char kBrokenManifest[] =
"{"
" \"version\" : \"1.0.0.0\"," " \"version\" : \"1.0.0.0\","
" \"manifest_version\" : 2,"
" \"name\" : \"Test\"," " \"name\" : \"Test\","
" \"chrome_ui_overrides\" : {" " \"chrome_ui_overrides\" : {"
" }" " }"
......
...@@ -1284,14 +1284,7 @@ TEST(PermissionsTest, GetWarningMessages_PlatformAppHosts) { ...@@ -1284,14 +1284,7 @@ TEST(PermissionsTest, GetWarningMessages_PlatformAppHosts) {
testing::AssertionResult ShowsAllHostsWarning(const std::string& pattern) { testing::AssertionResult ShowsAllHostsWarning(const std::string& pattern) {
scoped_refptr<Extension> extension = scoped_refptr<Extension> extension =
ExtensionBuilder() ExtensionBuilder("TLDWildCardTest").AddPermission(pattern).Build();
.SetManifest(
DictionaryBuilder()
.Set("name", "TLDWildCardTest")
.Set("version", "0.1.0")
.Set("permissions", ListBuilder().Append(pattern).Build())
.Build())
.Build();
return VerifyHasPermissionMessage( return VerifyHasPermissionMessage(
extension->permissions_data(), extension->permissions_data(),
......
...@@ -38,6 +38,7 @@ class ExtensionSyncTypeTest : public testing::Test { ...@@ -38,6 +38,7 @@ class ExtensionSyncTypeTest : public testing::Test {
base::DictionaryValue source; base::DictionaryValue source;
source.SetString(keys::kName, "PossiblySyncableExtension"); source.SetString(keys::kName, "PossiblySyncableExtension");
source.SetString(keys::kVersion, "0.0.0.0"); source.SetString(keys::kVersion, "0.0.0.0");
source.SetInteger(keys::kManifestVersion, 2);
if (type == APP) if (type == APP)
source.SetString(keys::kApp, "true"); source.SetString(keys::kApp, "true");
if (type == THEME) if (type == THEME)
......
{ {
"name": "test", "name": "test",
"version": "1", "version": "1",
"manifest_version": 2,
"background": { "background": {
"scripts": [ "scripts": [
"foo.js", "foo.js",
......
{ {
"name": "PageAction Test", "name": "PageAction Test",
"version": "1.0", "version": "1.0",
"manifest_version": 2,
"page_action": { "page_action": {
"default_icon": "image1.png", "default_icon": "image1.png",
"default_title": "MyExtensionActionTitle" "default_title": "MyExtensionActionTitle"
......
{ {
"name": "PageAction Test", "name": "PageAction Test",
"version": "1.0", "version": "1.0",
"manifest_version": 2,
"page_action": { "page_action": {
"default_title": 42 "default_title": 42
} }
......
...@@ -127,15 +127,8 @@ TEST(RulesRegistryTest, FillOptionalIdentifiers) { ...@@ -127,15 +127,8 @@ TEST(RulesRegistryTest, FillOptionalIdentifiers) {
EXPECT_EQ(kRuleId, *get_rules_4b[0]->id); EXPECT_EQ(kRuleId, *get_rules_4b[0]->id);
// Create extension // Create extension
std::unique_ptr<base::DictionaryValue> manifest = ParseDictionary( scoped_refptr<Extension> extension =
"{" ExtensionBuilder("Test").SetID(kExtensionId).Build();
" \"name\": \"Test\","
" \"version\": \"1\""
"}");
scoped_refptr<Extension> extension = ExtensionBuilder()
.SetManifest(std::move(manifest))
.SetID(kExtensionId)
.Build();
registry->OnExtensionUninstalled(extension.get()); registry->OnExtensionUninstalled(extension.get());
EXPECT_EQ(0u /*extensions*/ + 0u /*rules*/, EXPECT_EQ(0u /*extensions*/ + 0u /*rules*/,
registry->GetNumberOfUsedRuleIdentifiersForTesting()); registry->GetNumberOfUsedRuleIdentifiersForTesting());
...@@ -189,6 +182,7 @@ TEST(RulesRegistryTest, TwoRulesInManifest) { ...@@ -189,6 +182,7 @@ TEST(RulesRegistryTest, TwoRulesInManifest) {
"{" "{"
" \"name\": \"Test\"," " \"name\": \"Test\","
" \"version\": \"1\"," " \"version\": \"1\","
" \"manifest_version\": 2,"
" \"event_rules\": [" " \"event_rules\": ["
" {" " {"
" \"id\": \"000\"," " \"id\": \"000\","
...@@ -269,6 +263,7 @@ TEST(RulesRegistryTest, DeleteRuleInManifest) { ...@@ -269,6 +263,7 @@ TEST(RulesRegistryTest, DeleteRuleInManifest) {
"{" "{"
" \"name\": \"Test\"," " \"name\": \"Test\","
" \"version\": \"1\"," " \"version\": \"1\","
" \"manifest_version\": 2,"
" \"event_rules\": [{" " \"event_rules\": [{"
" \"id\": \"manifest_rule_0\"," " \"id\": \"manifest_rule_0\","
" \"event\": \"declarativeContent.onPageChanged\"," " \"event\": \"declarativeContent.onPageChanged\","
......
...@@ -276,7 +276,7 @@ TEST_F(PowerAPITest, MultipleExtensions) { ...@@ -276,7 +276,7 @@ TEST_F(PowerAPITest, MultipleExtensions) {
// Create a second extension that blocks system suspend. No additional // Create a second extension that blocks system suspend. No additional
// wake lock is needed; the wake lock from the first extension // wake lock is needed; the wake lock from the first extension
// already covers the behavior requested by the second extension. // already covers the behavior requested by the second extension.
scoped_refptr<Extension> extension2(ExtensionBuilder("Test").Build()); scoped_refptr<Extension> extension2(ExtensionBuilder("Test2").Build());
ASSERT_TRUE(CallFunction(REQUEST, kSystemArgs, extension2.get())); ASSERT_TRUE(CallFunction(REQUEST, kSystemArgs, extension2.get()));
EXPECT_EQ(NONE, manager_->PopFirstRequest()); EXPECT_EQ(NONE, manager_->PopFirstRequest());
......
...@@ -74,6 +74,7 @@ scoped_refptr<const Extension> AddExtensionWithIdAndPermissions( ...@@ -74,6 +74,7 @@ scoped_refptr<const Extension> AddExtensionWithIdAndPermissions(
base::DictionaryValue manifest; base::DictionaryValue manifest;
manifest.SetString("name", std::string("Test extension ") + id); manifest.SetString("name", std::string("Test extension ") + id);
manifest.SetString("version", "1.0"); manifest.SetString("version", "1.0");
manifest.SetInteger("manifest_version", 2);
std::unique_ptr<base::ListValue> permissions(new base::ListValue()); std::unique_ptr<base::ListValue> permissions(new base::ListValue());
for (std::set<std::string>::const_iterator it = permissions_set.begin(); for (std::set<std::string>::const_iterator it = permissions_set.begin();
......
...@@ -114,7 +114,12 @@ scoped_refptr<Extension> CreateExtension( ...@@ -114,7 +114,12 @@ scoped_refptr<Extension> CreateExtension(
scoped_refptr<Extension> CreateEmptyExtensionWithLocation( scoped_refptr<Extension> CreateEmptyExtensionWithLocation(
Manifest::Location location) { Manifest::Location location) {
std::unique_ptr<base::DictionaryValue> test_extension_value = std::unique_ptr<base::DictionaryValue> test_extension_value =
ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}"); ParseDictionary(R"(
{
"name": "Test",
"version": "1.0",
"manifest_version": 2
})");
return CreateExtension(location, test_extension_value.get(), std::string()); return CreateExtension(location, test_extension_value.get(), std::string());
} }
......
...@@ -37,13 +37,7 @@ void ApiUnitTest::SetUp() { ...@@ -37,13 +37,7 @@ void ApiUnitTest::SetUp() {
user_prefs::UserPrefs::Set(browser_context(), &testing_pref_service_); user_prefs::UserPrefs::Set(browser_context(), &testing_pref_service_);
extension_ = ExtensionBuilder() extension_ = ExtensionBuilder("Test").Build();
.SetManifest(DictionaryBuilder()
.Set("name", "Test")
.Set("version", "1.0")
.Build())
.SetLocation(Manifest::UNPACKED)
.Build();
} }
void ApiUnitTest::TearDown() { void ApiUnitTest::TearDown() {
......
...@@ -27,11 +27,7 @@ const char kWindowId2[] = "windowid2"; ...@@ -27,11 +27,7 @@ const char kWindowId2[] = "windowid2";
// Create a very simple extension with id. // Create a very simple extension with id.
scoped_refptr<Extension> CreateExtension(const std::string& id) { scoped_refptr<Extension> CreateExtension(const std::string& id) {
return ExtensionBuilder() return ExtensionBuilder("test").SetID(id).Build();
.SetManifest(
DictionaryBuilder().Set("name", "test").Set("version", "0.1").Build())
.SetID(id)
.Build();
} }
} // namespace } // namespace
...@@ -126,13 +122,7 @@ std::string AppWindowGeometryCacheTest::AddExtensionWithPrefs( ...@@ -126,13 +122,7 @@ std::string AppWindowGeometryCacheTest::AddExtensionWithPrefs(
base::FilePath path = base::FilePath path =
browser_context()->GetPath().AppendASCII("Extensions").AppendASCII(name); browser_context()->GetPath().AppendASCII("Extensions").AppendASCII(name);
scoped_refptr<Extension> extension = scoped_refptr<Extension> extension =
ExtensionBuilder() ExtensionBuilder(name).SetPath(path).Build();
.SetManifest(DictionaryBuilder()
.Set("name", "test")
.Set("version", "0.1")
.Build())
.SetPath(path)
.Build();
extension_prefs_->OnExtensionInstalled( extension_prefs_->OnExtensionInstalled(
extension.get(), extension.get(),
......
...@@ -280,6 +280,7 @@ TEST_F(ExtensionRegistryTest, TerminatedExtensionStoredVersion) { ...@@ -280,6 +280,7 @@ TEST_F(ExtensionRegistryTest, TerminatedExtensionStoredVersion) {
.SetManifest(DictionaryBuilder() .SetManifest(DictionaryBuilder()
.Set("name", "Test") .Set("name", "Test")
.Set("version", kVersionString) .Set("version", kVersionString)
.Set("manifest_version", 2)
.Build()) .Build())
.Build(); .Build();
const ExtensionId extension_id = extension->id(); const ExtensionId extension_id = extension->id();
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_paths.h" #include "extensions/common/extension_paths.h"
#include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_constants.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -28,20 +29,7 @@ static scoped_refptr<Extension> CreateExtension(const std::string& name) { ...@@ -28,20 +29,7 @@ static scoped_refptr<Extension> CreateExtension(const std::string& name) {
base::FilePath path; base::FilePath path;
PathService::Get(DIR_TEST_DATA, &path); PathService::Get(DIR_TEST_DATA, &path);
base::DictionaryValue manifest; return ExtensionBuilder(name).SetPath(path.AppendASCII(name)).Build();
manifest.SetString(keys::kVersion, "1.0.0.0");
manifest.SetString(keys::kName, name);
std::string error;
scoped_refptr<Extension> extension =
Extension::Create(path.AppendASCII(name),
Manifest::INVALID_LOCATION,
manifest,
Extension::NO_FLAGS,
&error);
EXPECT_TRUE(extension.get()) << error;
return extension;
} }
// Test that the InfoMap handles refcounting properly. // Test that the InfoMap handles refcounting properly.
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "extensions/browser/test_extensions_browser_client.h" #include "extensions/browser/test_extensions_browser_client.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -76,14 +77,7 @@ class PolicyCheckTest : public ExtensionsTest { ...@@ -76,14 +77,7 @@ class PolicyCheckTest : public ExtensionsTest {
// Replace the MockExtensionSystemFactory set by ExtensionsTest. // Replace the MockExtensionSystemFactory set by ExtensionsTest.
extensions_browser_client()->set_extension_system_factory(&factory_); extensions_browser_client()->set_extension_system_factory(&factory_);
base::DictionaryValue manifest_dict; extension_ = ExtensionBuilder("dummy name").Build();
manifest_dict.SetString("name", "dummy name");
manifest_dict.SetString("version", "1");
std::string error;
extension_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
manifest_dict, Extension::NO_FLAGS, &error);
EXPECT_TRUE(extension_.get()) << error;
} }
protected: protected:
......
...@@ -56,6 +56,7 @@ class RequirementsCheckerTest : public ExtensionsTest { ...@@ -56,6 +56,7 @@ class RequirementsCheckerTest : public ExtensionsTest {
void CreateExtension() { void CreateExtension() {
manifest_dict_->SetString("name", "dummy name"); manifest_dict_->SetString("name", "dummy name");
manifest_dict_->SetString("version", "1"); manifest_dict_->SetString("version", "1");
manifest_dict_->SetInteger("manifest_version", 2);
std::string error; std::string error;
extension_ = extension_ =
......
...@@ -19,13 +19,12 @@ namespace { ...@@ -19,13 +19,12 @@ namespace {
// Creates a very simple extension with a background page. // Creates a very simple extension with a background page.
scoped_refptr<Extension> CreateExtensionWithBackgroundPage() { scoped_refptr<Extension> CreateExtensionWithBackgroundPage() {
return ExtensionBuilder() return ExtensionBuilder("test")
.SetManifest(DictionaryBuilder() .MergeManifest(
.Set("name", "test") DictionaryBuilder()
.Set("version", "0.1") .Set("background",
.Set("background", DictionaryBuilder().Set("page", "bg.html").Build())
DictionaryBuilder().Set("page", "bg.html").Build()) .Build())
.Build())
.SetID("id2") .SetID("id2")
.Build(); .Build();
} }
......
...@@ -39,6 +39,7 @@ TEST_F(DeclarativeManifestTest, ConditionMissingType) { ...@@ -39,6 +39,7 @@ TEST_F(DeclarativeManifestTest, ConditionMissingType) {
"{" "{"
" \"name\": \"Test\"," " \"name\": \"Test\","
" \"version\": \"1\"," " \"version\": \"1\","
" \"manifest_version\": 2,"
" \"event_rules\": [" " \"event_rules\": ["
" {" " {"
" \"event\": \"declarativeContent.onPageChanged\"," " \"event\": \"declarativeContent.onPageChanged\","
...@@ -61,6 +62,7 @@ TEST_F(DeclarativeManifestTest, ConditionNotDictionary) { ...@@ -61,6 +62,7 @@ TEST_F(DeclarativeManifestTest, ConditionNotDictionary) {
"{" "{"
" \"name\": \"Test\"," " \"name\": \"Test\","
" \"version\": \"1\"," " \"version\": \"1\","
" \"manifest_version\": 2,"
" \"event_rules\": [" " \"event_rules\": ["
" {" " {"
" \"event\": \"declarativeContent.onPageChanged\"," " \"event\": \"declarativeContent.onPageChanged\","
...@@ -81,6 +83,7 @@ TEST_F(DeclarativeManifestTest, ActionMissingType) { ...@@ -81,6 +83,7 @@ TEST_F(DeclarativeManifestTest, ActionMissingType) {
"{" "{"
" \"name\": \"Test\"," " \"name\": \"Test\","
" \"version\": \"1\"," " \"version\": \"1\","
" \"manifest_version\": 2,"
" \"event_rules\": [" " \"event_rules\": ["
" {" " {"
" \"event\": \"declarativeContent.onPageChanged\"," " \"event\": \"declarativeContent.onPageChanged\","
...@@ -102,6 +105,7 @@ TEST_F(DeclarativeManifestTest, ActionNotDictionary) { ...@@ -102,6 +105,7 @@ TEST_F(DeclarativeManifestTest, ActionNotDictionary) {
"{" "{"
" \"name\": \"Test\"," " \"name\": \"Test\","
" \"version\": \"1\"," " \"version\": \"1\","
" \"manifest_version\": 2,"
" \"event_rules\": [" " \"event_rules\": ["
" {" " {"
" \"event\": \"declarativeContent.onPageChanged\"," " \"event\": \"declarativeContent.onPageChanged\","
...@@ -123,6 +127,7 @@ TEST_F(DeclarativeManifestTest, EventRulesNotList) { ...@@ -123,6 +127,7 @@ TEST_F(DeclarativeManifestTest, EventRulesNotList) {
"{" "{"
" \"name\": \"Test\"," " \"name\": \"Test\","
" \"version\": \"1\"," " \"version\": \"1\","
" \"manifest_version\": 2,"
" \"event_rules\": {}" " \"event_rules\": {}"
"}"); "}");
ManifestData manifest(std::move(manifest_data), "test"); ManifestData manifest(std::move(manifest_data), "test");
...@@ -135,6 +140,7 @@ TEST_F(DeclarativeManifestTest, EventRuleNotDictionary) { ...@@ -135,6 +140,7 @@ TEST_F(DeclarativeManifestTest, EventRuleNotDictionary) {
"{" "{"
" \"name\": \"Test\"," " \"name\": \"Test\","
" \"version\": \"1\"," " \"version\": \"1\","
" \"manifest_version\": 2,"
" \"event_rules\": [0,1,2]" " \"event_rules\": [0,1,2]"
"}"); "}");
ManifestData manifest(std::move(manifest_data), "test"); ManifestData manifest(std::move(manifest_data), "test");
...@@ -147,6 +153,7 @@ TEST_F(DeclarativeManifestTest, EventMissingFromRule) { ...@@ -147,6 +153,7 @@ TEST_F(DeclarativeManifestTest, EventMissingFromRule) {
"{" "{"
" \"name\": \"Test\"," " \"name\": \"Test\","
" \"version\": \"1\"," " \"version\": \"1\","
" \"manifest_version\": 2,"
" \"event_rules\": [" " \"event_rules\": ["
" {" " {"
" \"actions\": [{" " \"actions\": [{"
...@@ -169,6 +176,7 @@ TEST_F(DeclarativeManifestTest, RuleFailedToPopulate) { ...@@ -169,6 +176,7 @@ TEST_F(DeclarativeManifestTest, RuleFailedToPopulate) {
"{" "{"
" \"name\": \"Test\"," " \"name\": \"Test\","
" \"version\": \"1\"," " \"version\": \"1\","
" \"manifest_version\": 2,"
" \"event_rules\": [" " \"event_rules\": ["
" {" " {"
" \"event\": \"declarativeContent.onPageChanged\"" " \"event\": \"declarativeContent.onPageChanged\""
......
...@@ -32,6 +32,7 @@ scoped_refptr<Extension> CreateTestExtension(const std::string& name, ...@@ -32,6 +32,7 @@ scoped_refptr<Extension> CreateTestExtension(const std::string& name,
base::DictionaryValue manifest; base::DictionaryValue manifest;
manifest.SetString("name", name); manifest.SetString("name", name);
manifest.SetString("version", "1"); manifest.SetString("version", "1");
manifest.SetInteger("manifest_version", 2);
if (!launch_url.empty()) if (!launch_url.empty())
manifest.SetString("app.launch.web_url", launch_url); manifest.SetString("app.launch.web_url", launch_url);
......
...@@ -349,7 +349,7 @@ TEST_F(FileUtilTest, BackgroundScriptsMustExist) { ...@@ -349,7 +349,7 @@ TEST_F(FileUtilTest, BackgroundScriptsMustExist) {
std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
value->SetString("name", "test"); value->SetString("name", "test");
value->SetString("version", "1"); value->SetString("version", "1");
value->SetInteger("manifest_version", 1); value->SetInteger("manifest_version", 2);
base::ListValue* scripts = base::ListValue* scripts =
value->SetList("background.scripts", std::make_unique<base::ListValue>()); value->SetList("background.scripts", std::make_unique<base::ListValue>());
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/values.h" #include "base/values.h"
#include "extensions/browser/api_unittest.h" #include "extensions/browser/api_unittest.h"
#include "extensions/common/extension_builder.h" #include "extensions/common/extension_builder.h"
#include "extensions/common/value_builder.h"
#include "extensions/shell/browser/shell_oauth2_token_service.h" #include "extensions/shell/browser/shell_oauth2_token_service.h"
#include "google_apis/gaia/oauth2_mint_token_flow.h" #include "google_apis/gaia/oauth2_mint_token_flow.h"
...@@ -61,25 +62,16 @@ class IdentityApiTest : public ApiUnitTest { ...@@ -61,25 +62,16 @@ class IdentityApiTest : public ApiUnitTest {
// testing::Test: // testing::Test:
void SetUp() override { void SetUp() override {
ApiUnitTest::SetUp(); ApiUnitTest::SetUp();
DictionaryBuilder oauth2;
oauth2.Set("client_id", "123456.apps.googleusercontent.com")
.Set("scopes", ListBuilder()
.Append("https://www.googleapis.com/auth/drive")
.Build());
// Create an extension with OAuth2 scopes. // Create an extension with OAuth2 scopes.
set_extension( set_extension(
ExtensionBuilder() ExtensionBuilder("Test")
.SetManifest( .MergeManifest(
DictionaryBuilder() DictionaryBuilder().Set("oauth2", oauth2.Build()).Build())
.Set("name", "Test")
.Set("version", "1.0")
.Set("oauth2",
DictionaryBuilder()
.Set("client_id",
"123456.apps.googleusercontent.com")
.Set("scopes",
ListBuilder()
.Append("https://www.googleapis.com/"
"auth/drive")
.Build())
.Build())
.Build())
.SetLocation(Manifest::UNPACKED)
.Build()); .Build());
} }
}; };
......
...@@ -33,11 +33,8 @@ class ShellSystemLogsFetcherTest : public ExtensionsTest { ...@@ -33,11 +33,8 @@ class ShellSystemLogsFetcherTest : public ExtensionsTest {
scoped_refptr<Extension> BuildExtension(const std::string& name, scoped_refptr<Extension> BuildExtension(const std::string& name,
const std::string& version, const std::string& version,
const std::string& id) { const std::string& id) {
return ExtensionBuilder() return ExtensionBuilder(name)
.SetManifest(DictionaryBuilder() .MergeManifest(DictionaryBuilder().Set("version", version).Build())
.Set("name", name)
.Set("version", version)
.Build())
.SetID(id) .SetID(id)
.Build(); .Build();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment