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

Side by Side Diff: chrome/common/extensions/extension_test_util.cc

Issue 110463003: Create extensions_test_support build target (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase extension_test_util Created 6 years, 11 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 | Annotate | Revision Log
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 "chrome/common/extensions/extension_test_util.h" 5 #include "chrome/common/extensions/extension_test_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
12 #include "extensions/common/extension.h" 12 #include "extensions/common/extension.h"
13 #include "extensions/common/extension_builder.h"
14 #include "extensions/common/manifest_constants.h" 13 #include "extensions/common/manifest_constants.h"
15 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
16 15
17 using extensions::DictionaryBuilder;
18 using extensions::Extension; 16 using extensions::Extension;
19 using extensions::ExtensionBuilder;
20 using extensions::ListBuilder;
21 using extensions::Manifest; 17 using extensions::Manifest;
22 18
23 namespace extensions {
24 namespace extension_test_util { 19 namespace extension_test_util {
25 20
26 ExtensionBuilder& BuildExtension(ExtensionBuilder& builder) {
27 return builder
28 .SetManifest(DictionaryBuilder()
29 .Set("name", "Test extension")
30 .Set("version", "1.0")
31 .Set("manifest_version", 2));
32 }
33
34 ExtensionBuilder& BuildExtensionWithPermissions(ExtensionBuilder& builder,
35 ListBuilder& permissions) {
36 return
37 BuildExtension(builder)
38 .MergeManifest(
39 DictionaryBuilder().Set("permissions", permissions));
40 }
41
42 } // namespace extension_test_util
43 } // namespace extensions
44
45 namespace extension_test_util {
46
47 scoped_refptr<Extension> CreateExtensionWithID(std::string id) {
48 base::DictionaryValue values;
49 values.SetString(extensions::manifest_keys::kName, "test");
50 values.SetString(extensions::manifest_keys::kVersion, "0.1");
51 std::string error;
52 return Extension::Create(base::FilePath(), extensions::Manifest::INTERNAL,
53 values, Extension::NO_FLAGS, id, &error);
54 }
55
56 scoped_refptr<Extension> LoadManifestUnchecked(const std::string& dir, 21 scoped_refptr<Extension> LoadManifestUnchecked(const std::string& dir,
57 const std::string& test_file, 22 const std::string& test_file,
58 Manifest::Location location, 23 Manifest::Location location,
59 int extra_flags, 24 int extra_flags,
60 const std::string& id, 25 const std::string& id,
61 std::string* error) { 26 std::string* error) {
62 base::FilePath path; 27 base::FilePath path;
63 PathService::Get(chrome::DIR_TEST_DATA, &path); 28 PathService::Get(chrome::DIR_TEST_DATA, &path);
64 path = path.AppendASCII("extensions") 29 path = path.AppendASCII("extensions")
65 .AppendASCII(dir) 30 .AppendASCII(dir)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 const std::string& test_file) { 73 const std::string& test_file) {
109 return LoadManifest(dir, test_file, Extension::NO_FLAGS); 74 return LoadManifest(dir, test_file, Extension::NO_FLAGS);
110 } 75 }
111 76
112 scoped_refptr<Extension> LoadManifest(const std::string& dir, 77 scoped_refptr<Extension> LoadManifest(const std::string& dir,
113 const std::string& test_file) { 78 const std::string& test_file) {
114 return LoadManifest(dir, test_file, Extension::NO_FLAGS); 79 return LoadManifest(dir, test_file, Extension::NO_FLAGS);
115 } 80 }
116 81
117 } // namespace extension_test_util 82 } // namespace extension_test_util
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_test_util.h ('k') | extensions/browser/extension_registry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698