| 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" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 | 74 |
| 75 TEST_F(MicroBenchmarkControllerTest, BenchmarkRan) { | 75 TEST_F(MicroBenchmarkControllerTest, BenchmarkRan) { |
| 76 int run_count = 0; | 76 int run_count = 0; |
| 77 int id = layer_tree_host_->ScheduleMicroBenchmark( | 77 int id = layer_tree_host_->ScheduleMicroBenchmark( |
| 78 "unittest_only_benchmark", | 78 "unittest_only_benchmark", |
| 79 nullptr, | 79 nullptr, |
| 80 base::Bind(&IncrementCallCount, base::Unretained(&run_count))); | 80 base::Bind(&IncrementCallCount, base::Unretained(&run_count))); |
| 81 EXPECT_GT(id, 0); | 81 EXPECT_GT(id, 0); |
| 82 | 82 |
| 83 layer_tree_host_->SetOutputSurfaceLostForTesting(false); | |
| 84 layer_tree_host_->UpdateLayers(); | 83 layer_tree_host_->UpdateLayers(); |
| 85 | 84 |
| 86 EXPECT_EQ(1, run_count); | 85 EXPECT_EQ(1, run_count); |
| 87 } | 86 } |
| 88 | 87 |
| 89 TEST_F(MicroBenchmarkControllerTest, MultipleBenchmarkRan) { | 88 TEST_F(MicroBenchmarkControllerTest, MultipleBenchmarkRan) { |
| 90 int run_count = 0; | 89 int run_count = 0; |
| 91 int id = layer_tree_host_->ScheduleMicroBenchmark( | 90 int id = layer_tree_host_->ScheduleMicroBenchmark( |
| 92 "unittest_only_benchmark", | 91 "unittest_only_benchmark", |
| 93 nullptr, | 92 nullptr, |
| 94 base::Bind(&IncrementCallCount, base::Unretained(&run_count))); | 93 base::Bind(&IncrementCallCount, base::Unretained(&run_count))); |
| 95 EXPECT_GT(id, 0); | 94 EXPECT_GT(id, 0); |
| 96 id = layer_tree_host_->ScheduleMicroBenchmark( | 95 id = layer_tree_host_->ScheduleMicroBenchmark( |
| 97 "unittest_only_benchmark", | 96 "unittest_only_benchmark", |
| 98 nullptr, | 97 nullptr, |
| 99 base::Bind(&IncrementCallCount, base::Unretained(&run_count))); | 98 base::Bind(&IncrementCallCount, base::Unretained(&run_count))); |
| 100 EXPECT_GT(id, 0); | 99 EXPECT_GT(id, 0); |
| 101 | 100 |
| 102 layer_tree_host_->SetOutputSurfaceLostForTesting(false); | |
| 103 layer_tree_host_->UpdateLayers(); | 101 layer_tree_host_->UpdateLayers(); |
| 104 | 102 |
| 105 EXPECT_EQ(2, run_count); | 103 EXPECT_EQ(2, run_count); |
| 106 | 104 |
| 107 id = layer_tree_host_->ScheduleMicroBenchmark( | 105 id = layer_tree_host_->ScheduleMicroBenchmark( |
| 108 "unittest_only_benchmark", | 106 "unittest_only_benchmark", |
| 109 nullptr, | 107 nullptr, |
| 110 base::Bind(&IncrementCallCount, base::Unretained(&run_count))); | 108 base::Bind(&IncrementCallCount, base::Unretained(&run_count))); |
| 111 EXPECT_GT(id, 0); | 109 EXPECT_GT(id, 0); |
| 112 id = layer_tree_host_->ScheduleMicroBenchmark( | 110 id = layer_tree_host_->ScheduleMicroBenchmark( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // Send invalid message to valid benchmark | 170 // Send invalid message to valid benchmark |
| 173 message = base::WrapUnique(new base::DictionaryValue); | 171 message = base::WrapUnique(new base::DictionaryValue); |
| 174 message->SetBoolean("can_handle", false); | 172 message->SetBoolean("can_handle", false); |
| 175 message_handled = | 173 message_handled = |
| 176 layer_tree_host_->SendMessageToMicroBenchmark(id, std::move(message)); | 174 layer_tree_host_->SendMessageToMicroBenchmark(id, std::move(message)); |
| 177 EXPECT_FALSE(message_handled); | 175 EXPECT_FALSE(message_handled); |
| 178 } | 176 } |
| 179 | 177 |
| 180 } // namespace | 178 } // namespace |
| 181 } // namespace cc | 179 } // namespace cc |
| OLD | NEW |