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

Side by Side Diff: extensions/common/manifest_test.h

Issue 1908953003: Convert //extensions/{common,shell} from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? Created 4 years, 8 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/manifest_handlers/webview_info.cc ('k') | extensions/common/manifest_test.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 #ifndef EXTENSIONS_COMMON_MANIFEST_TEST_H_ 5 #ifndef EXTENSIONS_COMMON_MANIFEST_TEST_H_
6 #define EXTENSIONS_COMMON_MANIFEST_TEST_H_ 6 #define EXTENSIONS_COMMON_MANIFEST_TEST_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "extensions/common/extension.h" 15 #include "extensions/common/extension.h"
15 #include "extensions/common/manifest.h" 16 #include "extensions/common/manifest.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace base { 19 namespace base {
19 class FilePath; 20 class FilePath;
20 } 21 }
21 22
22 namespace extensions { 23 namespace extensions {
23 24
24 // Base class for tests that parse a manifest file. 25 // Base class for tests that parse a manifest file.
25 class ManifestTest : public testing::Test { 26 class ManifestTest : public testing::Test {
26 public: 27 public:
27 ManifestTest(); 28 ManifestTest();
28 ~ManifestTest() override; 29 ~ManifestTest() override;
29 30
30 protected: 31 protected:
31 // Helper class that simplifies creating methods that take either a filename 32 // Helper class that simplifies creating methods that take either a filename
32 // to a manifest or the manifest itself. 33 // to a manifest or the manifest itself.
33 class ManifestData { 34 class ManifestData {
34 public: 35 public:
35 explicit ManifestData(const char* name); 36 explicit ManifestData(const char* name);
36 ManifestData(base::DictionaryValue* manifest, const char* name); 37 ManifestData(base::DictionaryValue* manifest, const char* name);
37 explicit ManifestData(scoped_ptr<base::DictionaryValue> manifest); 38 explicit ManifestData(std::unique_ptr<base::DictionaryValue> manifest);
38 explicit ManifestData(scoped_ptr<base::DictionaryValue> manifest, 39 explicit ManifestData(std::unique_ptr<base::DictionaryValue> manifest,
39 const char* name); 40 const char* name);
40 // C++98 requires the copy constructor for a type to be visible if you 41 // C++98 requires the copy constructor for a type to be visible if you
41 // take a const-ref of a temporary for that type. Since Manifest 42 // take a const-ref of a temporary for that type. Since Manifest
42 // contains a scoped_ptr, its implicit copy constructor is declared 43 // contains a scoped_ptr, its implicit copy constructor is declared
43 // Manifest(Manifest&) according to spec 12.8.5. This breaks the first 44 // Manifest(Manifest&) according to spec 12.8.5. This breaks the first
44 // requirement and thus you cannot use it with LoadAndExpectError() or 45 // requirement and thus you cannot use it with LoadAndExpectError() or
45 // LoadAndExpectSuccess() easily. 46 // LoadAndExpectSuccess() easily.
46 // 47 //
47 // To get around this spec pedantry, we declare the copy constructor 48 // To get around this spec pedantry, we declare the copy constructor
48 // explicitly. It will never get invoked. 49 // explicitly. It will never get invoked.
49 ManifestData(const ManifestData& m); 50 ManifestData(const ManifestData& m);
50 51
51 ~ManifestData(); 52 ~ManifestData();
52 53
53 const std::string& name() const { return name_; }; 54 const std::string& name() const { return name_; };
54 55
55 base::DictionaryValue* GetManifest(base::FilePath manifest_path, 56 base::DictionaryValue* GetManifest(base::FilePath manifest_path,
56 std::string* error) const; 57 std::string* error) const;
57 58
58 private: 59 private:
59 const std::string name_; 60 const std::string name_;
60 mutable base::DictionaryValue* manifest_; 61 mutable base::DictionaryValue* manifest_;
61 mutable scoped_ptr<base::DictionaryValue> manifest_holder_; 62 mutable std::unique_ptr<base::DictionaryValue> manifest_holder_;
62 }; 63 };
63 64
64 // Allows the test implementation to override a loaded test manifest's 65 // Allows the test implementation to override a loaded test manifest's
65 // extension ID. Useful for testing features behind a whitelist. 66 // extension ID. Useful for testing features behind a whitelist.
66 virtual std::string GetTestExtensionID() const; 67 virtual std::string GetTestExtensionID() const;
67 68
68 // Returns the path in which to find test manifest data files, for example 69 // Returns the path in which to find test manifest data files, for example
69 // extensions/test/data/manifest_tests. 70 // extensions/test/data/manifest_tests.
70 virtual base::FilePath GetTestDataDir(); 71 virtual base::FilePath GetTestDataDir();
71 72
72 scoped_ptr<base::DictionaryValue> LoadManifest( 73 std::unique_ptr<base::DictionaryValue> LoadManifest(char const* manifest_name,
73 char const* manifest_name, 74 std::string* error);
74 std::string* error);
75 75
76 scoped_refptr<extensions::Extension> LoadExtension( 76 scoped_refptr<extensions::Extension> LoadExtension(
77 const ManifestData& manifest, 77 const ManifestData& manifest,
78 std::string* error, 78 std::string* error,
79 extensions::Manifest::Location location = 79 extensions::Manifest::Location location =
80 extensions::Manifest::INTERNAL, 80 extensions::Manifest::INTERNAL,
81 int flags = extensions::Extension::NO_FLAGS); 81 int flags = extensions::Extension::NO_FLAGS);
82 82
83 scoped_refptr<extensions::Extension> LoadAndExpectSuccess( 83 scoped_refptr<extensions::Extension> LoadAndExpectSuccess(
84 const ManifestData& manifest, 84 const ManifestData& manifest,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 bool enable_apps_; 164 bool enable_apps_;
165 165
166 private: 166 private:
167 DISALLOW_COPY_AND_ASSIGN(ManifestTest); 167 DISALLOW_COPY_AND_ASSIGN(ManifestTest);
168 }; 168 };
169 169
170 } // namespace extensions 170 } // namespace extensions
171 171
172 #endif // EXTENSIONS_COMMON_MANIFEST_TEST_H_ 172 #endif // EXTENSIONS_COMMON_MANIFEST_TEST_H_
OLDNEW
« no previous file with comments | « extensions/common/manifest_handlers/webview_info.cc ('k') | extensions/common/manifest_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698