| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" |
| 7 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 9 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 10 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 11 #include "base/string_piece.h" | 12 #include "base/string_piece.h" |
| 12 #include "cc/content_layer.h" | 13 #include "cc/content_layer.h" |
| 13 #include "cc/nine_patch_layer.h" | 14 #include "cc/nine_patch_layer.h" |
| 14 #include "cc/solid_color_layer.h" | 15 #include "cc/solid_color_layer.h" |
| 15 #include "cc/test/fake_content_layer_client.h" | 16 #include "cc/test/fake_content_layer_client.h" |
| 16 #include "cc/test/layer_tree_test_common.h" | 17 #include "cc/test/layer_tree_test_common.h" |
| 17 #include "cc/test/paths.h" | |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 static const int kTimeLimitMillis = 2000; | 22 static const int kTimeLimitMillis = 2000; |
| 23 | 23 |
| 24 class LayerTreeHostPerfTest : public WebKitTests::ThreadedTest { | 24 class LayerTreeHostPerfTest : public WebKitTests::ThreadedTest { |
| 25 public: | 25 public: |
| 26 LayerTreeHostPerfTest() | 26 LayerTreeHostPerfTest() |
| 27 : num_draws_(0) { | 27 : num_draws_(0) { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 233 } |
| 234 | 234 |
| 235 class LayerTreeHostPerfTestJsonReader : public LayerTreeHostPerfTest { | 235 class LayerTreeHostPerfTestJsonReader : public LayerTreeHostPerfTest { |
| 236 public: | 236 public: |
| 237 LayerTreeHostPerfTestJsonReader() | 237 LayerTreeHostPerfTestJsonReader() |
| 238 : LayerTreeHostPerfTest() { | 238 : LayerTreeHostPerfTest() { |
| 239 } | 239 } |
| 240 | 240 |
| 241 void readTestFile(std::string name) { | 241 void readTestFile(std::string name) { |
| 242 test_name_ = name; | 242 test_name_ = name; |
| 243 FilePath test_data_dir; | 243 FilePath filepath; |
| 244 ASSERT_TRUE(PathService::Get(cc::test::DIR_TEST_DATA, &test_data_dir)); | 244 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &filepath)); |
| 245 FilePath json_file = test_data_dir.AppendASCII(name + ".json"); | 245 filepath = filepath.AppendASCII("cc").AppendASCII("test") |
| 246 .AppendASCII("data").AppendASCII(name + ".json"); |
| 246 std::string json; | 247 std::string json; |
| 247 ASSERT_TRUE(file_util::ReadFileToString(json_file, &json)); | 248 ASSERT_TRUE(file_util::ReadFileToString(filepath, &json)); |
| 248 tree_.reset(base::JSONReader::Read(json)); | 249 tree_.reset(base::JSONReader::Read(json)); |
| 249 ASSERT_TRUE(tree_); | 250 ASSERT_TRUE(tree_); |
| 250 } | 251 } |
| 251 | 252 |
| 252 scoped_refptr<Layer> parseLayer(base::Value* val) { | 253 scoped_refptr<Layer> parseLayer(base::Value* val) { |
| 253 DictionaryValue* dict; | 254 DictionaryValue* dict; |
| 254 bool success = true; | 255 bool success = true; |
| 255 success &= val->GetAsDictionary(&dict); | 256 success &= val->GetAsDictionary(&dict); |
| 256 std::string layer_type; | 257 std::string layer_type; |
| 257 success &= dict->GetString("LayerType", &layer_type); | 258 success &= dict->GetString("LayerType", &layer_type); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 scoped_ptr<base::Value> tree_; | 318 scoped_ptr<base::Value> tree_; |
| 318 }; | 319 }; |
| 319 | 320 |
| 320 TEST_F(LayerTreeHostPerfTestJsonReader, tenTenSingleThread) { | 321 TEST_F(LayerTreeHostPerfTestJsonReader, tenTenSingleThread) { |
| 321 readTestFile("10_10_layer_tree"); | 322 readTestFile("10_10_layer_tree"); |
| 322 runTest(false); | 323 runTest(false); |
| 323 } | 324 } |
| 324 | 325 |
| 325 } // namespace | 326 } // namespace |
| 326 } // namespace cc | 327 } // namespace cc |
| OLD | NEW |