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