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

Side by Side Diff: chrome/common/extensions/api/storage/storage_schema_manifest_handler_unittest.cc

Issue 2888073002: Remove raw DictionaryValue::Set in //chrome (Closed)
Patch Set: Fix Tests Created 3 years, 7 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 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/api/storage/storage_schema_manifest_handler.h " 5 #include "chrome/common/extensions/api/storage/storage_schema_manifest_handler.h "
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/memory/ptr_util.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "components/version_info/version_info.h" 15 #include "components/version_info/version_info.h"
15 #include "extensions/common/extension.h" 16 #include "extensions/common/extension.h"
16 #include "extensions/common/features/feature_channel.h" 17 #include "extensions/common/features/feature_channel.h"
17 #include "extensions/common/file_util.h" 18 #include "extensions/common/file_util.h"
18 #include "extensions/common/manifest.h" 19 #include "extensions/common/manifest.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace extensions { 22 namespace extensions {
22 23
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 82
82 // All good now. 83 // All good now.
83 manifest_.SetString("storage.managed_schema", "schema.json"); 84 manifest_.SetString("storage.managed_schema", "schema.json");
84 extension = CreateExtension(""); 85 extension = CreateExtension("");
85 ASSERT_TRUE(extension.get()); 86 ASSERT_TRUE(extension.get());
86 } 87 }
87 88
88 TEST_F(StorageSchemaManifestHandlerTest, Validate) { 89 TEST_F(StorageSchemaManifestHandlerTest, Validate) {
89 base::ListValue permissions; 90 base::ListValue permissions;
90 permissions.AppendString("storage"); 91 permissions.AppendString("storage");
91 manifest_.Set("permissions", permissions.DeepCopy()); 92 manifest_.Set("permissions", base::MakeUnique<base::Value>(permissions));
92 93
93 // Absolute path. 94 // Absolute path.
94 manifest_.SetString("storage.managed_schema", "/etc/passwd"); 95 manifest_.SetString("storage.managed_schema", "/etc/passwd");
95 EXPECT_FALSE(Validates("")); 96 EXPECT_FALSE(Validates(""));
96 97
97 // Path with .. 98 // Path with ..
98 manifest_.SetString("storage.managed_schema", "../../../../../etc/passwd"); 99 manifest_.SetString("storage.managed_schema", "../../../../../etc/passwd");
99 EXPECT_FALSE(Validates("")); 100 EXPECT_FALSE(Validates(""));
100 101
101 // Does not exist. 102 // Does not exist.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 139
139 // All good now. 140 // All good now.
140 EXPECT_TRUE(Validates( 141 EXPECT_TRUE(Validates(
141 "{" 142 "{"
142 " \"$schema\": \"http://json-schema.org/draft-03/schema#\"," 143 " \"$schema\": \"http://json-schema.org/draft-03/schema#\","
143 " \"type\": \"object\"" 144 " \"type\": \"object\""
144 "}")); 145 "}"));
145 } 146 }
146 147
147 } // namespace extensions 148 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698