OLD | NEW |
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 "extensions/common/manifest_test.h" | 5 #include "extensions/common/manifest_test.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "extensions/common/extension_l10n_util.h" | 13 #include "extensions/common/extension_l10n_util.h" |
14 #include "extensions/common/extension_paths.h" | 14 #include "extensions/common/extension_paths.h" |
15 #include "extensions/common/test_util.h" | 15 #include "extensions/common/test_util.h" |
16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 namespace { | 19 namespace { |
20 | 20 |
21 // |manifest_path| is an absolute path to a manifest file. | 21 // |manifest_path| is an absolute path to a manifest file. |
22 base::DictionaryValue* LoadManifestFile(const base::FilePath& manifest_path, | 22 base::DictionaryValue* LoadManifestFile(const base::FilePath& manifest_path, |
23 std::string* error) { | 23 std::string* error) { |
24 base::FilePath extension_path = manifest_path.DirName(); | 24 base::FilePath extension_path = manifest_path.DirName(); |
25 | 25 |
26 EXPECT_TRUE(base::PathExists(manifest_path)) << | 26 EXPECT_TRUE(base::PathExists(manifest_path)) << |
27 "Couldn't find " << manifest_path.value(); | 27 "Couldn't find " << manifest_path.value(); |
28 | 28 |
29 JSONFileValueSerializer serializer(manifest_path); | 29 JSONFileValueDeserializer deserializer(manifest_path); |
30 base::DictionaryValue* manifest = | 30 base::DictionaryValue* manifest = static_cast<base::DictionaryValue*>( |
31 static_cast<base::DictionaryValue*>(serializer.Deserialize(NULL, error)); | 31 deserializer.Deserialize(NULL, error)); |
32 | 32 |
33 // Most unit tests don't need localization, and they'll fail if we try to | 33 // Most unit tests don't need localization, and they'll fail if we try to |
34 // localize them, since their manifests don't have a default_locale key. | 34 // localize them, since their manifests don't have a default_locale key. |
35 // Only localize manifests that indicate they want to be localized. | 35 // Only localize manifests that indicate they want to be localized. |
36 // Calling LocalizeExtension at this point mirrors file_util::LoadExtension. | 36 // Calling LocalizeExtension at this point mirrors file_util::LoadExtension. |
37 if (manifest && | 37 if (manifest && |
38 manifest_path.value().find(FILE_PATH_LITERAL("localized")) != | 38 manifest_path.value().find(FILE_PATH_LITERAL("localized")) != |
39 std::string::npos) | 39 std::string::npos) |
40 extension_l10n_util::LocalizeExtension(extension_path, manifest, error); | 40 extension_l10n_util::LocalizeExtension(extension_path, manifest, error); |
41 | 41 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 break; | 253 break; |
254 case EXPECT_TYPE_SUCCESS: | 254 case EXPECT_TYPE_SUCCESS: |
255 LoadAndExpectSuccess(testcase.manifest_filename_.c_str(), | 255 LoadAndExpectSuccess(testcase.manifest_filename_.c_str(), |
256 testcase.location_, | 256 testcase.location_, |
257 testcase.flags_); | 257 testcase.flags_); |
258 break; | 258 break; |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 } // namespace extensions | 262 } // namespace extensions |
OLD | NEW |