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

Side by Side Diff: extensions/common/manifest_handlers/oauth2_manifest_unittest.cc

Issue 2899743002: Remove raw base::DictionaryValue::Set in //extensions (Closed)
Patch Set: Addressed nit Created 3 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
« no previous file with comments | « extensions/common/file_util_unittest.cc ('k') | extensions/common/message_bundle_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility> 5 #include <utility>
6 6
7 #include "base/memory/ptr_util.h"
7 #include "base/test/values_test_util.h" 8 #include "base/test/values_test_util.h"
9 #include "base/values.h"
8 #include "extensions/common/manifest_constants.h" 10 #include "extensions/common/manifest_constants.h"
9 #include "extensions/common/manifest_handlers/oauth2_manifest_handler.h" 11 #include "extensions/common/manifest_handlers/oauth2_manifest_handler.h"
10 #include "extensions/common/manifest_test.h" 12 #include "extensions/common/manifest_test.h"
11 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
12 14
13 namespace extensions { 15 namespace extensions {
14 16
15 namespace keys = manifest_keys; 17 namespace keys = manifest_keys;
16 namespace errors = manifest_errors; 18 namespace errors = manifest_errors;
17 19
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 88
87 }; 89 };
88 90
89 TEST_F(OAuth2ManifestTest, OAuth2SectionParsing) { 91 TEST_F(OAuth2ManifestTest, OAuth2SectionParsing) {
90 base::DictionaryValue base_manifest; 92 base::DictionaryValue base_manifest;
91 93
92 base_manifest.SetString(keys::kName, "test"); 94 base_manifest.SetString(keys::kName, "test");
93 base_manifest.SetString(keys::kVersion, "0.1"); 95 base_manifest.SetString(keys::kVersion, "0.1");
94 base_manifest.SetInteger(keys::kManifestVersion, 2); 96 base_manifest.SetInteger(keys::kManifestVersion, 2);
95 base_manifest.SetString(keys::kOAuth2ClientId, "client1"); 97 base_manifest.SetString(keys::kOAuth2ClientId, "client1");
96 base::ListValue* scopes = new base::ListValue(); 98 auto scopes = base::MakeUnique<base::ListValue>();
97 scopes->AppendString("scope1"); 99 scopes->AppendString("scope1");
98 scopes->AppendString("scope2"); 100 scopes->AppendString("scope2");
99 base_manifest.Set(keys::kOAuth2Scopes, scopes); 101 base_manifest.Set(keys::kOAuth2Scopes, std::move(scopes));
100 102
101 // OAuth2 section should be parsed for an extension. 103 // OAuth2 section should be parsed for an extension.
102 { 104 {
103 base::DictionaryValue ext_manifest; 105 base::DictionaryValue ext_manifest;
104 // Lack of "app" section representa an extension. So the base manifest 106 // Lack of "app" section representa an extension. So the base manifest
105 // itself represents an extension. 107 // itself represents an extension.
106 ext_manifest.MergeDictionary(&base_manifest); 108 ext_manifest.MergeDictionary(&base_manifest);
107 ext_manifest.SetString(keys::kKey, kExtensionKey); 109 ext_manifest.SetString(keys::kKey, kExtensionKey);
108 ext_manifest.SetBoolean(keys::kOAuth2AutoApprove, true); 110 ext_manifest.SetBoolean(keys::kOAuth2AutoApprove, true);
109 111
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 TEST_F(OAuth2ManifestTest, ComponentWithStandardClientId) { 313 TEST_F(OAuth2ManifestTest, ComponentWithStandardClientId) {
312 std::unique_ptr<base::DictionaryValue> ext_manifest = 314 std::unique_ptr<base::DictionaryValue> ext_manifest =
313 CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_DEFAULT); 315 CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_DEFAULT);
314 ManifestData manifest(std::move(ext_manifest), "test"); 316 ManifestData manifest(std::move(ext_manifest), "test");
315 scoped_refptr<extensions::Extension> extension = 317 scoped_refptr<extensions::Extension> extension =
316 LoadAndExpectSuccess(manifest, extensions::Manifest::COMPONENT); 318 LoadAndExpectSuccess(manifest, extensions::Manifest::COMPONENT);
317 EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension.get()).client_id); 319 EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension.get()).client_id);
318 } 320 }
319 321
320 } // namespace extensions 322 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/file_util_unittest.cc ('k') | extensions/common/message_bundle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698