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

Side by Side Diff: extensions/common/test_util.cc

Issue 569493003: Remove CreateEmptyExtension from extension_function_test_utils (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/common/test_util.h" 5 #include "extensions/common/test_util.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "components/crx_file/id_util.h"
9 #include "extensions/common/extension.h" 10 #include "extensions/common/extension.h"
10 #include "extensions/common/extension_builder.h" 11 #include "extensions/common/extension_builder.h"
11 #include "extensions/common/value_builder.h" 12 #include "extensions/common/value_builder.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace extensions { 15 namespace extensions {
15 namespace test_util { 16 namespace test_util {
16 17
17 ExtensionBuilder& BuildExtension(ExtensionBuilder& builder) { 18 ExtensionBuilder& BuildExtension(ExtensionBuilder& builder) {
18 return builder 19 return builder
19 .SetManifest(DictionaryBuilder() 20 .SetManifest(DictionaryBuilder()
20 .Set("name", "Test extension") 21 .Set("name", "Test extension")
21 .Set("version", "1.0") 22 .Set("version", "1.0")
22 .Set("manifest_version", 2)); 23 .Set("manifest_version", 2));
23 } 24 }
24 25
25 scoped_refptr<Extension> CreateEmptyExtension() { 26 scoped_refptr<Extension> CreateEmptyExtension() {
26 scoped_refptr<Extension> empty_extension( 27 return ExtensionBuilder()
27 ExtensionBuilder() 28 .SetManifest(
28 .SetManifest( 29 DictionaryBuilder().Set("name", "Test").Set("version", "1.0"))
29 DictionaryBuilder().Set("name", "Test").Set("version", "1.0")) 30 .Build();
30 .Build());
31 return empty_extension;
32 } 31 }
33 32
34 scoped_refptr<Extension> CreateExtensionWithID(const std::string& id) { 33 scoped_refptr<Extension> CreateEmptyExtension(const std::string& id) {
35 return ExtensionBuilder() 34 return ExtensionBuilder()
36 .SetManifest( 35 .SetManifest(
37 DictionaryBuilder().Set("name", "test").Set("version", "0.1")) 36 DictionaryBuilder().Set("name", "test").Set("version", "0.1"))
38 .SetID(id) 37 .SetID(id)
39 .Build(); 38 .Build();
40 } 39 }
41 40
42 scoped_ptr<base::DictionaryValue> ParseJsonDictionaryWithSingleQuotes( 41 scoped_ptr<base::DictionaryValue> ParseJsonDictionaryWithSingleQuotes(
43 std::string json) { 42 std::string json) {
44 std::replace(json.begin(), json.end(), '\'', '"'); 43 std::replace(json.begin(), json.end(), '\'', '"');
45 std::string error_msg; 44 std::string error_msg;
46 scoped_ptr<base::Value> result(base::JSONReader::ReadAndReturnError( 45 scoped_ptr<base::Value> result(base::JSONReader::ReadAndReturnError(
47 json, base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error_msg)); 46 json, base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error_msg));
48 scoped_ptr<base::DictionaryValue> result_dict; 47 scoped_ptr<base::DictionaryValue> result_dict;
49 if (result && result->IsType(base::Value::TYPE_DICTIONARY)) { 48 if (result && result->IsType(base::Value::TYPE_DICTIONARY)) {
50 result_dict.reset(static_cast<base::DictionaryValue*>(result.release())); 49 result_dict.reset(static_cast<base::DictionaryValue*>(result.release()));
51 } else { 50 } else {
52 ADD_FAILURE() << "Failed to parse \"" << json << "\": " << error_msg; 51 ADD_FAILURE() << "Failed to parse \"" << json << "\": " << error_msg;
53 result_dict.reset(new base::DictionaryValue()); 52 result_dict.reset(new base::DictionaryValue());
54 } 53 }
55 return result_dict.Pass(); 54 return result_dict.Pass();
56 } 55 }
57 56
58 } // namespace test_util 57 } // namespace test_util
59 } // namespace extensions 58 } // namespace extensions
OLDNEW
« chrome/browser/extensions/api/identity/identity_apitest.cc ('K') | « extensions/common/test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698