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

Side by Side Diff: chrome/common/extensions/manifest_handlers/settings_overrides_handler_unittest.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/manifest_handlers/settings_overrides_handler. h" 5 #include "chrome/common/extensions/manifest_handlers/settings_overrides_handler. h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // On Mac, this API is limited to trunk. 78 // On Mac, this API is limited to trunk.
79 extensions::ScopedCurrentChannel scoped_channel( 79 extensions::ScopedCurrentChannel scoped_channel(
80 version_info::Channel::UNKNOWN); 80 version_info::Channel::UNKNOWN);
81 #endif // OS_MACOSX 81 #endif // OS_MACOSX
82 82
83 std::string manifest(kManifest); 83 std::string manifest(kManifest);
84 JSONStringValueDeserializer json(manifest); 84 JSONStringValueDeserializer json(manifest);
85 std::string error; 85 std::string error;
86 std::unique_ptr<base::Value> root(json.Deserialize(NULL, &error)); 86 std::unique_ptr<base::Value> root(json.Deserialize(NULL, &error));
87 ASSERT_TRUE(root); 87 ASSERT_TRUE(root);
88 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); 88 ASSERT_TRUE(root->IsType(base::Value::Type::DICTIONARY));
89 scoped_refptr<Extension> extension = Extension::Create( 89 scoped_refptr<Extension> extension = Extension::Create(
90 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), 90 base::FilePath(FILE_PATH_LITERAL("//nonexistent")),
91 Manifest::INVALID_LOCATION, 91 Manifest::INVALID_LOCATION,
92 *static_cast<base::DictionaryValue*>(root.get()), 92 *static_cast<base::DictionaryValue*>(root.get()),
93 Extension::NO_FLAGS, 93 Extension::NO_FLAGS,
94 &error); 94 &error);
95 ASSERT_TRUE(extension.get()); 95 ASSERT_TRUE(extension.get());
96 #if defined(OS_WIN) || defined(OS_MACOSX) 96 #if defined(OS_WIN) || defined(OS_MACOSX)
97 ASSERT_TRUE(extension->manifest()->HasPath(manifest_keys::kSettingsOverride)); 97 ASSERT_TRUE(extension->manifest()->HasPath(manifest_keys::kSettingsOverride));
98 98
(...skipping 28 matching lines...) Expand all
127 // On Mac, this API is limited to trunk. 127 // On Mac, this API is limited to trunk.
128 extensions::ScopedCurrentChannel scoped_channel( 128 extensions::ScopedCurrentChannel scoped_channel(
129 version_info::Channel::UNKNOWN); 129 version_info::Channel::UNKNOWN);
130 #endif // OS_MACOSX 130 #endif // OS_MACOSX
131 131
132 std::string manifest(kPrepopulatedManifest); 132 std::string manifest(kPrepopulatedManifest);
133 JSONStringValueDeserializer json(manifest); 133 JSONStringValueDeserializer json(manifest);
134 std::string error; 134 std::string error;
135 std::unique_ptr<base::Value> root(json.Deserialize(NULL, &error)); 135 std::unique_ptr<base::Value> root(json.Deserialize(NULL, &error));
136 ASSERT_TRUE(root); 136 ASSERT_TRUE(root);
137 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); 137 ASSERT_TRUE(root->IsType(base::Value::Type::DICTIONARY));
138 scoped_refptr<Extension> extension = 138 scoped_refptr<Extension> extension =
139 Extension::Create(base::FilePath(FILE_PATH_LITERAL("//nonexistent")), 139 Extension::Create(base::FilePath(FILE_PATH_LITERAL("//nonexistent")),
140 Manifest::INVALID_LOCATION, 140 Manifest::INVALID_LOCATION,
141 *static_cast<base::DictionaryValue*>(root.get()), 141 *static_cast<base::DictionaryValue*>(root.get()),
142 Extension::NO_FLAGS, 142 Extension::NO_FLAGS,
143 &error); 143 &error);
144 ASSERT_TRUE(extension.get()); 144 ASSERT_TRUE(extension.get());
145 #if defined(OS_WIN) || defined(OS_MACOSX) 145 #if defined(OS_WIN) || defined(OS_MACOSX)
146 ASSERT_TRUE(extension->manifest()->HasPath(manifest_keys::kSettingsOverride)); 146 ASSERT_TRUE(extension->manifest()->HasPath(manifest_keys::kSettingsOverride));
147 147
(...skipping 18 matching lines...) Expand all
166 // On Mac, this API is limited to trunk. 166 // On Mac, this API is limited to trunk.
167 extensions::ScopedCurrentChannel scoped_channel( 167 extensions::ScopedCurrentChannel scoped_channel(
168 version_info::Channel::UNKNOWN); 168 version_info::Channel::UNKNOWN);
169 #endif // OS_MACOSX 169 #endif // OS_MACOSX
170 170
171 std::string manifest(kBrokenManifest); 171 std::string manifest(kBrokenManifest);
172 JSONStringValueDeserializer json(manifest); 172 JSONStringValueDeserializer json(manifest);
173 std::string error; 173 std::string error;
174 std::unique_ptr<base::Value> root(json.Deserialize(NULL, &error)); 174 std::unique_ptr<base::Value> root(json.Deserialize(NULL, &error));
175 ASSERT_TRUE(root); 175 ASSERT_TRUE(root);
176 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); 176 ASSERT_TRUE(root->IsType(base::Value::Type::DICTIONARY));
177 scoped_refptr<Extension> extension = Extension::Create( 177 scoped_refptr<Extension> extension = Extension::Create(
178 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), 178 base::FilePath(FILE_PATH_LITERAL("//nonexistent")),
179 Manifest::INVALID_LOCATION, 179 Manifest::INVALID_LOCATION,
180 *static_cast<base::DictionaryValue*>(root.get()), 180 *static_cast<base::DictionaryValue*>(root.get()),
181 Extension::NO_FLAGS, 181 Extension::NO_FLAGS,
182 &error); 182 &error);
183 #if defined(OS_WIN) || defined(OS_MACOSX) 183 #if defined(OS_WIN) || defined(OS_MACOSX)
184 EXPECT_FALSE(extension.get()); 184 EXPECT_FALSE(extension.get());
185 EXPECT_EQ( 185 EXPECT_EQ(
186 extensions::ErrorUtils::FormatErrorMessage( 186 extensions::ErrorUtils::FormatErrorMessage(
187 extensions::manifest_errors::kInvalidEmptyDictionary, 187 extensions::manifest_errors::kInvalidEmptyDictionary,
188 extensions::manifest_keys::kSettingsOverride), 188 extensions::manifest_keys::kSettingsOverride),
189 error); 189 error);
190 #else 190 #else
191 EXPECT_TRUE(extension.get()); 191 EXPECT_TRUE(extension.get());
192 EXPECT_FALSE( 192 EXPECT_FALSE(
193 extension->manifest()->HasPath(manifest_keys::kSettingsOverride)); 193 extension->manifest()->HasPath(manifest_keys::kSettingsOverride));
194 #endif 194 #endif
195 } 195 }
196 196
197 } // namespace 197 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698