summaryrefslogtreecommitdiffstats
path: root/chromium/cc/debug/micro_benchmark_controller_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/cc/debug/micro_benchmark_controller_unittest.cc')
-rw-r--r--chromium/cc/debug/micro_benchmark_controller_unittest.cc69
1 files changed, 51 insertions, 18 deletions
diff --git a/chromium/cc/debug/micro_benchmark_controller_unittest.cc b/chromium/cc/debug/micro_benchmark_controller_unittest.cc
index 4894947a6da..83faeabf9a1 100644
--- a/chromium/cc/debug/micro_benchmark_controller_unittest.cc
+++ b/chromium/cc/debug/micro_benchmark_controller_unittest.cc
@@ -20,8 +20,9 @@ class MicroBenchmarkControllerTest : public testing::Test {
public:
virtual void SetUp() OVERRIDE {
impl_proxy_ = make_scoped_ptr(new FakeImplProxy);
- layer_tree_host_impl_ =
- make_scoped_ptr(new FakeLayerTreeHostImpl(impl_proxy_.get()));
+ shared_bitmap_manager_.reset(new TestSharedBitmapManager());
+ layer_tree_host_impl_ = make_scoped_ptr(new FakeLayerTreeHostImpl(
+ impl_proxy_.get(), shared_bitmap_manager_.get()));
layer_tree_host_ = FakeLayerTreeHost::Create();
layer_tree_host_->SetRootLayer(Layer::Create());
@@ -35,6 +36,7 @@ class MicroBenchmarkControllerTest : public testing::Test {
}
scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
+ scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
scoped_ptr<FakeLayerTreeHostImpl> layer_tree_host_impl_;
scoped_ptr<FakeImplProxy> impl_proxy_;
};
@@ -47,26 +49,26 @@ void IncrementCallCount(int* count, scoped_ptr<base::Value> value) {
}
TEST_F(MicroBenchmarkControllerTest, ScheduleFail) {
- bool result = layer_tree_host_->ScheduleMicroBenchmark(
+ int id = layer_tree_host_->ScheduleMicroBenchmark(
"non_existant_benchmark", scoped_ptr<base::Value>(), base::Bind(&Noop));
- EXPECT_FALSE(result);
+ EXPECT_EQ(id, 0);
}
TEST_F(MicroBenchmarkControllerTest, CommitScheduled) {
EXPECT_FALSE(layer_tree_host_->needs_commit());
- bool result = layer_tree_host_->ScheduleMicroBenchmark(
+ int id = layer_tree_host_->ScheduleMicroBenchmark(
"unittest_only_benchmark", scoped_ptr<base::Value>(), base::Bind(&Noop));
- EXPECT_TRUE(result);
+ EXPECT_GT(id, 0);
EXPECT_TRUE(layer_tree_host_->needs_commit());
}
TEST_F(MicroBenchmarkControllerTest, BenchmarkRan) {
int run_count = 0;
- bool result = layer_tree_host_->ScheduleMicroBenchmark(
+ int id = layer_tree_host_->ScheduleMicroBenchmark(
"unittest_only_benchmark",
scoped_ptr<base::Value>(),
base::Bind(&IncrementCallCount, base::Unretained(&run_count)));
- EXPECT_TRUE(result);
+ EXPECT_GT(id, 0);
scoped_ptr<ResourceUpdateQueue> queue(new ResourceUpdateQueue);
layer_tree_host_->SetOutputSurfaceLostForTesting(false);
@@ -77,16 +79,16 @@ TEST_F(MicroBenchmarkControllerTest, BenchmarkRan) {
TEST_F(MicroBenchmarkControllerTest, MultipleBenchmarkRan) {
int run_count = 0;
- bool result = layer_tree_host_->ScheduleMicroBenchmark(
+ int id = layer_tree_host_->ScheduleMicroBenchmark(
"unittest_only_benchmark",
scoped_ptr<base::Value>(),
base::Bind(&IncrementCallCount, base::Unretained(&run_count)));
- EXPECT_TRUE(result);
- result = layer_tree_host_->ScheduleMicroBenchmark(
+ EXPECT_GT(id, 0);
+ id = layer_tree_host_->ScheduleMicroBenchmark(
"unittest_only_benchmark",
scoped_ptr<base::Value>(),
base::Bind(&IncrementCallCount, base::Unretained(&run_count)));
- EXPECT_TRUE(result);
+ EXPECT_GT(id, 0);
scoped_ptr<ResourceUpdateQueue> queue(new ResourceUpdateQueue);
layer_tree_host_->SetOutputSurfaceLostForTesting(false);
@@ -94,16 +96,16 @@ TEST_F(MicroBenchmarkControllerTest, MultipleBenchmarkRan) {
EXPECT_EQ(2, run_count);
- result = layer_tree_host_->ScheduleMicroBenchmark(
+ id = layer_tree_host_->ScheduleMicroBenchmark(
"unittest_only_benchmark",
scoped_ptr<base::Value>(),
base::Bind(&IncrementCallCount, base::Unretained(&run_count)));
- EXPECT_TRUE(result);
- result = layer_tree_host_->ScheduleMicroBenchmark(
+ EXPECT_GT(id, 0);
+ id = layer_tree_host_->ScheduleMicroBenchmark(
"unittest_only_benchmark",
scoped_ptr<base::Value>(),
base::Bind(&IncrementCallCount, base::Unretained(&run_count)));
- EXPECT_TRUE(result);
+ EXPECT_GT(id, 0);
layer_tree_host_->UpdateLayers(queue.get());
EXPECT_EQ(4, run_count);
@@ -118,11 +120,11 @@ TEST_F(MicroBenchmarkControllerTest, BenchmarkImplRan) {
settings->SetBoolean("run_benchmark_impl", true);
// Schedule a main thread benchmark.
- bool result = layer_tree_host_->ScheduleMicroBenchmark(
+ int id = layer_tree_host_->ScheduleMicroBenchmark(
"unittest_only_benchmark",
settings.PassAs<base::Value>(),
base::Bind(&IncrementCallCount, base::Unretained(&run_count)));
- EXPECT_TRUE(result);
+ EXPECT_GT(id, 0);
// Schedule impl benchmarks. In production code, this is run in commit.
layer_tree_host_->GetMicroBenchmarkController()->ScheduleImplBenchmarks(
@@ -137,5 +139,36 @@ TEST_F(MicroBenchmarkControllerTest, BenchmarkImplRan) {
EXPECT_EQ(1, run_count);
}
+TEST_F(MicroBenchmarkControllerTest, SendMessage) {
+ // Send valid message to invalid benchmark (id = 0)
+ scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue);
+ message->SetBoolean("can_handle", true);
+ bool message_handled = layer_tree_host_->SendMessageToMicroBenchmark(
+ 0, message.PassAs<base::Value>());
+ EXPECT_FALSE(message_handled);
+
+ // Schedule a benchmark
+ int run_count = 0;
+ int id = layer_tree_host_->ScheduleMicroBenchmark(
+ "unittest_only_benchmark",
+ scoped_ptr<base::Value>(),
+ base::Bind(&IncrementCallCount, base::Unretained(&run_count)));
+ EXPECT_GT(id, 0);
+
+ // Send valid message to valid benchmark
+ message = scoped_ptr<base::DictionaryValue>(new base::DictionaryValue);
+ message->SetBoolean("can_handle", true);
+ message_handled = layer_tree_host_->SendMessageToMicroBenchmark(
+ id, message.PassAs<base::Value>());
+ EXPECT_TRUE(message_handled);
+
+ // Send invalid message to valid benchmark
+ message = scoped_ptr<base::DictionaryValue>(new base::DictionaryValue);
+ message->SetBoolean("can_handle", false);
+ message_handled = layer_tree_host_->SendMessageToMicroBenchmark(
+ id, message.PassAs<base::Value>());
+ EXPECT_FALSE(message_handled);
+}
+
} // namespace
} // namespace cc