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