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 <vector> | 5 #include <vector> |
6 | 6 |
| 7 #include "base/base_paths.h" |
7 #include "base/file_util.h" | 8 #include "base/file_util.h" |
8 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
10 #include "base/perftimer.h" | 11 #include "base/perftimer.h" |
11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "chrome/common/chrome_paths.h" | |
14 #include "chrome/common/logging_chrome.h" | 14 #include "chrome/common/logging_chrome.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace { | 17 namespace { |
| 18 |
18 class JSONValueSerializerTests : public testing::Test { | 19 class JSONValueSerializerTests : public testing::Test { |
19 protected: | 20 protected: |
20 virtual void SetUp() { | 21 virtual void SetUp() OVERRIDE { |
21 static const char* const kTestFilenames[] = { | 22 static const char* const kTestFilenames[] = { |
22 "serializer_nested_test.js", | 23 "serializer_nested_test.json", |
23 "serializer_test.js", | 24 "serializer_test.json", |
24 "serializer_test_nowhitespace.js", | 25 "serializer_test_nowhitespace.json", |
25 }; | 26 }; |
26 | 27 |
27 // Load test cases | 28 // Load test cases |
28 for (size_t i = 0; i < arraysize(kTestFilenames); ++i) { | 29 for (size_t i = 0; i < arraysize(kTestFilenames); ++i) { |
29 base::FilePath filename; | 30 base::FilePath filename; |
30 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &filename)); | 31 EXPECT_TRUE(PathService::Get(base::DIR_TEST_DATA, &filename)); |
31 filename = filename.AppendASCII(kTestFilenames[i]); | 32 filename = filename.AppendASCII(kTestFilenames[i]); |
32 | 33 |
33 std::string test_case; | 34 std::string test_case; |
34 EXPECT_TRUE(file_util::ReadFileToString(filename, &test_case)); | 35 EXPECT_TRUE(file_util::ReadFileToString(filename, &test_case)); |
35 test_cases_.push_back(test_case); | 36 test_cases_.push_back(test_case); |
36 } | 37 } |
37 } | 38 } |
38 | 39 |
39 // Holds json strings to be tested. | 40 // Holds json strings to be tested. |
40 std::vector<std::string> test_cases_; | 41 std::vector<std::string> test_cases_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 82 } |
82 } | 83 } |
83 chrome_timer.Done(); | 84 chrome_timer.Done(); |
84 | 85 |
85 // Clean up test cases. | 86 // Clean up test cases. |
86 for (size_t i = 0; i < test_cases.size(); ++i) { | 87 for (size_t i = 0; i < test_cases.size(); ++i) { |
87 delete test_cases[i]; | 88 delete test_cases[i]; |
88 test_cases[i] = NULL; | 89 test_cases[i] = NULL; |
89 } | 90 } |
90 } | 91 } |
OLD | NEW |