OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/debug/micro_benchmark_controller.h" | 5 #include "cc/debug/micro_benchmark_controller.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "cc/debug/micro_benchmark.h" | 12 #include "cc/debug/micro_benchmark.h" |
13 #include "cc/layers/layer.h" | 13 #include "cc/layers/layer.h" |
14 #include "cc/test/fake_impl_task_runner_provider.h" | 14 #include "cc/test/fake_impl_task_runner_provider.h" |
15 #include "cc/test/fake_layer_tree_host.h" | 15 #include "cc/test/fake_layer_tree_host.h" |
16 #include "cc/test/fake_layer_tree_host_impl.h" | 16 #include "cc/test/fake_layer_tree_host_impl.h" |
17 #include "cc/test/fake_proxy.h" | 17 #include "cc/test/fake_proxy.h" |
18 #include "cc/test/test_task_graph_runner.h" | 18 #include "cc/test/test_task_graph_runner.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 namespace { | 22 namespace { |
23 | 23 |
24 class MicroBenchmarkControllerTest : public testing::Test { | 24 class MicroBenchmarkControllerTest : public testing::Test { |
25 public: | 25 public: |
26 void SetUp() override { | 26 void SetUp() override { |
27 impl_task_runner_provider_ = | 27 impl_task_runner_provider_ = |
28 base::WrapUnique(new FakeImplTaskRunnerProvider); | 28 base::WrapUnique(new FakeImplTaskRunnerProvider); |
29 layer_tree_host_impl_ = base::MakeUnique<FakeLayerTreeHostImpl>( | 29 layer_tree_host_impl_ = base::MakeUnique<FakeLayerTreeHostImpl>( |
30 impl_task_runner_provider_.get(), &shared_bitmap_manager_, | 30 impl_task_runner_provider_.get(), &task_graph_runner_); |
31 &task_graph_runner_); | |
32 | 31 |
33 layer_tree_host_ = FakeLayerTreeHost::Create(&layer_tree_host_client_, | 32 layer_tree_host_ = FakeLayerTreeHost::Create(&layer_tree_host_client_, |
34 &task_graph_runner_); | 33 &task_graph_runner_); |
35 layer_tree_host_->SetRootLayer(Layer::Create()); | 34 layer_tree_host_->SetRootLayer(Layer::Create()); |
36 layer_tree_host_->InitializeForTesting( | 35 layer_tree_host_->InitializeForTesting( |
37 TaskRunnerProvider::Create(nullptr, nullptr), | 36 TaskRunnerProvider::Create(nullptr, nullptr), |
38 std::unique_ptr<Proxy>(new FakeProxy)); | 37 std::unique_ptr<Proxy>(new FakeProxy)); |
39 } | 38 } |
40 | 39 |
41 void TearDown() override { | 40 void TearDown() override { |
42 layer_tree_host_impl_ = nullptr; | 41 layer_tree_host_impl_ = nullptr; |
43 layer_tree_host_ = nullptr; | 42 layer_tree_host_ = nullptr; |
44 impl_task_runner_provider_ = nullptr; | 43 impl_task_runner_provider_ = nullptr; |
45 } | 44 } |
46 | 45 |
47 FakeLayerTreeHostClient layer_tree_host_client_; | 46 FakeLayerTreeHostClient layer_tree_host_client_; |
48 TestTaskGraphRunner task_graph_runner_; | 47 TestTaskGraphRunner task_graph_runner_; |
49 TestSharedBitmapManager shared_bitmap_manager_; | |
50 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; | 48 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; |
51 std::unique_ptr<FakeLayerTreeHostImpl> layer_tree_host_impl_; | 49 std::unique_ptr<FakeLayerTreeHostImpl> layer_tree_host_impl_; |
52 std::unique_ptr<FakeImplTaskRunnerProvider> impl_task_runner_provider_; | 50 std::unique_ptr<FakeImplTaskRunnerProvider> impl_task_runner_provider_; |
53 }; | 51 }; |
54 | 52 |
55 void Noop(std::unique_ptr<base::Value> value) {} | 53 void Noop(std::unique_ptr<base::Value> value) {} |
56 | 54 |
57 void IncrementCallCount(int* count, std::unique_ptr<base::Value> value) { | 55 void IncrementCallCount(int* count, std::unique_ptr<base::Value> value) { |
58 ++(*count); | 56 ++(*count); |
59 } | 57 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // Send invalid message to valid benchmark | 168 // Send invalid message to valid benchmark |
171 message = base::WrapUnique(new base::DictionaryValue); | 169 message = base::WrapUnique(new base::DictionaryValue); |
172 message->SetBoolean("can_handle", false); | 170 message->SetBoolean("can_handle", false); |
173 message_handled = | 171 message_handled = |
174 layer_tree_host_->SendMessageToMicroBenchmark(id, std::move(message)); | 172 layer_tree_host_->SendMessageToMicroBenchmark(id, std::move(message)); |
175 EXPECT_FALSE(message_handled); | 173 EXPECT_FALSE(message_handled); |
176 } | 174 } |
177 | 175 |
178 } // namespace | 176 } // namespace |
179 } // namespace cc | 177 } // namespace cc |
OLD | NEW |