OLD | NEW |
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 "extensions/common/file_util.h" | 5 #include "extensions/common/file_util.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
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/json/json_string_value_serializer.h" | 13 #include "base/json/json_string_value_serializer.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" |
15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/values.h" |
18 #include "build/build_config.h" | 20 #include "build/build_config.h" |
19 #include "extensions/common/constants.h" | 21 #include "extensions/common/constants.h" |
20 #include "extensions/common/extension.h" | 22 #include "extensions/common/extension.h" |
21 #include "extensions/common/extension_paths.h" | 23 #include "extensions/common/extension_paths.h" |
22 #include "extensions/common/manifest.h" | 24 #include "extensions/common/manifest.h" |
23 #include "extensions/common/manifest_constants.h" | 25 #include "extensions/common/manifest_constants.h" |
24 #include "extensions/strings/grit/extensions_strings.h" | 26 #include "extensions/strings/grit/extensions_strings.h" |
25 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
27 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 285 |
284 TEST_F(FileUtilTest, BackgroundScriptsMustExist) { | 286 TEST_F(FileUtilTest, BackgroundScriptsMustExist) { |
285 base::ScopedTempDir temp; | 287 base::ScopedTempDir temp; |
286 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 288 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
287 | 289 |
288 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 290 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
289 value->SetString("name", "test"); | 291 value->SetString("name", "test"); |
290 value->SetString("version", "1"); | 292 value->SetString("version", "1"); |
291 value->SetInteger("manifest_version", 1); | 293 value->SetInteger("manifest_version", 1); |
292 | 294 |
293 base::ListValue* scripts = new base::ListValue(); | 295 base::ListValue* scripts = |
| 296 value->SetList("background.scripts", base::MakeUnique<base::ListValue>()); |
294 scripts->AppendString("foo.js"); | 297 scripts->AppendString("foo.js"); |
295 value->Set("background.scripts", scripts); | |
296 | 298 |
297 std::string error; | 299 std::string error; |
298 std::vector<extensions::InstallWarning> warnings; | 300 std::vector<extensions::InstallWarning> warnings; |
299 scoped_refptr<Extension> extension = LoadExtensionManifest( | 301 scoped_refptr<Extension> extension = LoadExtensionManifest( |
300 *value, temp.GetPath(), Manifest::UNPACKED, 0, &error); | 302 *value, temp.GetPath(), Manifest::UNPACKED, 0, &error); |
301 ASSERT_TRUE(extension.get()) << error; | 303 ASSERT_TRUE(extension.get()) << error; |
302 | 304 |
303 EXPECT_FALSE( | 305 EXPECT_FALSE( |
304 file_util::ValidateExtension(extension.get(), &error, &warnings)); | 306 file_util::ValidateExtension(extension.get(), &error, &warnings)); |
305 EXPECT_EQ( | 307 EXPECT_EQ( |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 base::FilePath actual_path = | 484 base::FilePath actual_path = |
483 extensions::file_util::ExtensionURLToRelativeFilePath(url); | 485 extensions::file_util::ExtensionURLToRelativeFilePath(url); |
484 EXPECT_FALSE(actual_path.IsAbsolute()) << | 486 EXPECT_FALSE(actual_path.IsAbsolute()) << |
485 " For the path " << actual_path.value(); | 487 " For the path " << actual_path.value(); |
486 EXPECT_EQ(expected_path.value(), actual_path.value()) << | 488 EXPECT_EQ(expected_path.value(), actual_path.value()) << |
487 " For the path " << url; | 489 " For the path " << url; |
488 } | 490 } |
489 } | 491 } |
490 | 492 |
491 } // namespace extensions | 493 } // namespace extensions |
OLD | NEW |