Chromium Code Reviews| 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 "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 6 | 6 |
| 7 #include <algorithm> | |
| 8 | |
| 7 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 9 #include "base/json/json_file_value_serializer.h" | 11 #include "base/json/json_file_value_serializer.h" |
| 12 #include "base/json/json_string_value_serializer.h" | |
| 10 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 11 #include "base/values.h" | 14 #include "base/values.h" |
| 12 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 13 #include "chrome/common/extensions/extension_l10n_util.h" | 16 #include "chrome/common/extensions/extension_l10n_util.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 15 | 18 |
| 16 using extensions::Extension; | 19 using extensions::Extension; |
| 17 | 20 |
| 18 namespace { | 21 namespace { |
| 19 | 22 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 | 84 |
| 82 base::FilePath filename_path; | 85 base::FilePath filename_path; |
| 83 filename_path = filename_path.AppendASCII("extensions") | 86 filename_path = filename_path.AppendASCII("extensions") |
| 84 .AppendASCII(test_data_dir) | 87 .AppendASCII(test_data_dir) |
| 85 .AppendASCII(name_); | 88 .AppendASCII(name_); |
| 86 manifest_ = LoadManifestFile(filename_path, error); | 89 manifest_ = LoadManifestFile(filename_path, error); |
| 87 manifest_holder_.reset(manifest_); | 90 manifest_holder_.reset(manifest_); |
| 88 return manifest_; | 91 return manifest_; |
| 89 } | 92 } |
| 90 | 93 |
| 94 ExtensionManifestTest::ManifestFromString::ManifestFromString( | |
| 95 const char* manifest_as_string_with_single_quotes) | |
| 96 : Manifest("") { | |
| 97 std::string manifest_string = manifest_as_string_with_single_quotes; | |
|
Jeffrey Yasskin
2014/02/28 01:54:37
If you're going to copy a string anyway, just take
scheib
2014/03/03 19:54:00
Done.
| |
| 98 std::replace(manifest_string.begin(), manifest_string.end(), '\'', '"'); | |
| 99 JSONStringValueSerializer serializer(manifest_string); | |
|
Jeffrey Yasskin
2014/02/28 01:54:37
Let's use one of the existing parse-json-for-test
scheib
2014/03/03 19:54:00
Moved this functionality to base::test::ParseJsonD
| |
| 100 parsed_manifest_holder_.reset(serializer.Deserialize(NULL, NULL)); | |
| 101 CHECK(parsed_manifest_holder_); | |
| 102 CHECK(parsed_manifest_holder_->GetAsDictionary(&manifest_)); | |
| 103 } | |
| 104 | |
| 105 ExtensionManifestTest::ManifestFromString::~ManifestFromString() {} | |
| 106 | |
| 91 char const* ExtensionManifestTest::test_data_dir() { | 107 char const* ExtensionManifestTest::test_data_dir() { |
| 92 return "manifest_tests"; | 108 return "manifest_tests"; |
| 93 } | 109 } |
| 94 | 110 |
| 95 scoped_ptr<base::DictionaryValue> ExtensionManifestTest::LoadManifest( | 111 scoped_ptr<base::DictionaryValue> ExtensionManifestTest::LoadManifest( |
| 96 char const* manifest_name, std::string* error) { | 112 char const* manifest_name, std::string* error) { |
| 97 base::FilePath filename_path; | 113 base::FilePath filename_path; |
| 98 filename_path = filename_path.AppendASCII("extensions") | 114 filename_path = filename_path.AppendASCII("extensions") |
| 99 .AppendASCII(test_data_dir()) | 115 .AppendASCII(test_data_dir()) |
| 100 .AppendASCII(manifest_name); | 116 .AppendASCII(manifest_name); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 testcase.location_, | 266 testcase.location_, |
| 251 testcase.flags_); | 267 testcase.flags_); |
| 252 break; | 268 break; |
| 253 case EXPECT_TYPE_SUCCESS: | 269 case EXPECT_TYPE_SUCCESS: |
| 254 LoadAndExpectSuccess(testcase.manifest_filename_.c_str(), | 270 LoadAndExpectSuccess(testcase.manifest_filename_.c_str(), |
| 255 testcase.location_, | 271 testcase.location_, |
| 256 testcase.flags_); | 272 testcase.flags_); |
| 257 break; | 273 break; |
| 258 } | 274 } |
| 259 } | 275 } |
| OLD | NEW |