Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: cc/debug/micro_benchmark_controller_unittest.cc

Issue 609663003: cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cc-passas: PassAs-presubmit-warning Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/debug/micro_benchmark_controller.cc ('k') | cc/debug/picture_record_benchmark.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/resources/resource_update_queue.h" 10 #include "cc/resources/resource_update_queue.h"
(...skipping 15 matching lines...) Expand all
26 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); 26 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
27 layer_tree_host_impl_ = make_scoped_ptr(new FakeLayerTreeHostImpl( 27 layer_tree_host_impl_ = make_scoped_ptr(new FakeLayerTreeHostImpl(
28 impl_proxy_.get(), shared_bitmap_manager_.get())); 28 impl_proxy_.get(), shared_bitmap_manager_.get()));
29 29
30 layer_tree_host_ = FakeLayerTreeHost::Create(&layer_tree_host_client_); 30 layer_tree_host_ = FakeLayerTreeHost::Create(&layer_tree_host_client_);
31 layer_tree_host_->SetRootLayer(Layer::Create()); 31 layer_tree_host_->SetRootLayer(Layer::Create());
32 layer_tree_host_->InitializeForTesting(scoped_ptr<Proxy>(new FakeProxy)); 32 layer_tree_host_->InitializeForTesting(scoped_ptr<Proxy>(new FakeProxy));
33 } 33 }
34 34
35 virtual void TearDown() OVERRIDE { 35 virtual void TearDown() OVERRIDE {
36 layer_tree_host_impl_.reset(); 36 layer_tree_host_impl_ = nullptr;
37 layer_tree_host_.reset(); 37 layer_tree_host_ = nullptr;
38 impl_proxy_.reset(); 38 impl_proxy_ = nullptr;
39 } 39 }
40 40
41 FakeLayerTreeHostClient layer_tree_host_client_; 41 FakeLayerTreeHostClient layer_tree_host_client_;
42 scoped_ptr<FakeLayerTreeHost> layer_tree_host_; 42 scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
43 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 43 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
44 scoped_ptr<FakeLayerTreeHostImpl> layer_tree_host_impl_; 44 scoped_ptr<FakeLayerTreeHostImpl> layer_tree_host_impl_;
45 scoped_ptr<FakeImplProxy> impl_proxy_; 45 scoped_ptr<FakeImplProxy> impl_proxy_;
46 }; 46 };
47 47
48 void Noop(scoped_ptr<base::Value> value) { 48 void Noop(scoped_ptr<base::Value> value) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 120
121 TEST_F(MicroBenchmarkControllerTest, BenchmarkImplRan) { 121 TEST_F(MicroBenchmarkControllerTest, BenchmarkImplRan) {
122 int run_count = 0; 122 int run_count = 0;
123 scoped_ptr<base::DictionaryValue> settings(new base::DictionaryValue); 123 scoped_ptr<base::DictionaryValue> settings(new base::DictionaryValue);
124 settings->SetBoolean("run_benchmark_impl", true); 124 settings->SetBoolean("run_benchmark_impl", true);
125 125
126 // Schedule a main thread benchmark. 126 // Schedule a main thread benchmark.
127 int id = layer_tree_host_->ScheduleMicroBenchmark( 127 int id = layer_tree_host_->ScheduleMicroBenchmark(
128 "unittest_only_benchmark", 128 "unittest_only_benchmark",
129 settings.PassAs<base::Value>(), 129 settings.Pass(),
130 base::Bind(&IncrementCallCount, base::Unretained(&run_count))); 130 base::Bind(&IncrementCallCount, base::Unretained(&run_count)));
131 EXPECT_GT(id, 0); 131 EXPECT_GT(id, 0);
132 132
133 // Schedule impl benchmarks. In production code, this is run in commit. 133 // Schedule impl benchmarks. In production code, this is run in commit.
134 layer_tree_host_->GetMicroBenchmarkController()->ScheduleImplBenchmarks( 134 layer_tree_host_->GetMicroBenchmarkController()->ScheduleImplBenchmarks(
135 layer_tree_host_impl_.get()); 135 layer_tree_host_impl_.get());
136 136
137 // Now complete the commit (as if on the impl thread). 137 // Now complete the commit (as if on the impl thread).
138 layer_tree_host_impl_->CommitComplete(); 138 layer_tree_host_impl_->CommitComplete();
139 139
140 // Make sure all posted messages run. 140 // Make sure all posted messages run.
141 base::MessageLoop::current()->RunUntilIdle(); 141 base::MessageLoop::current()->RunUntilIdle();
142 142
143 EXPECT_EQ(1, run_count); 143 EXPECT_EQ(1, run_count);
144 } 144 }
145 145
146 TEST_F(MicroBenchmarkControllerTest, SendMessage) { 146 TEST_F(MicroBenchmarkControllerTest, SendMessage) {
147 // Send valid message to invalid benchmark (id = 0) 147 // Send valid message to invalid benchmark (id = 0)
148 scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue); 148 scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue);
149 message->SetBoolean("can_handle", true); 149 message->SetBoolean("can_handle", true);
150 bool message_handled = layer_tree_host_->SendMessageToMicroBenchmark( 150 bool message_handled =
151 0, message.PassAs<base::Value>()); 151 layer_tree_host_->SendMessageToMicroBenchmark(0, message.Pass());
152 EXPECT_FALSE(message_handled); 152 EXPECT_FALSE(message_handled);
153 153
154 // Schedule a benchmark 154 // Schedule a benchmark
155 int run_count = 0; 155 int run_count = 0;
156 int id = layer_tree_host_->ScheduleMicroBenchmark( 156 int id = layer_tree_host_->ScheduleMicroBenchmark(
157 "unittest_only_benchmark", 157 "unittest_only_benchmark",
158 scoped_ptr<base::Value>(), 158 scoped_ptr<base::Value>(),
159 base::Bind(&IncrementCallCount, base::Unretained(&run_count))); 159 base::Bind(&IncrementCallCount, base::Unretained(&run_count)));
160 EXPECT_GT(id, 0); 160 EXPECT_GT(id, 0);
161 161
162 // Send valid message to valid benchmark 162 // Send valid message to valid benchmark
163 message = scoped_ptr<base::DictionaryValue>(new base::DictionaryValue); 163 message = make_scoped_ptr(new base::DictionaryValue);
164 message->SetBoolean("can_handle", true); 164 message->SetBoolean("can_handle", true);
165 message_handled = layer_tree_host_->SendMessageToMicroBenchmark( 165 message_handled =
166 id, message.PassAs<base::Value>()); 166 layer_tree_host_->SendMessageToMicroBenchmark(id, message.Pass());
167 EXPECT_TRUE(message_handled); 167 EXPECT_TRUE(message_handled);
168 168
169 // Send invalid message to valid benchmark 169 // Send invalid message to valid benchmark
170 message = scoped_ptr<base::DictionaryValue>(new base::DictionaryValue); 170 message = make_scoped_ptr(new base::DictionaryValue);
171 message->SetBoolean("can_handle", false); 171 message->SetBoolean("can_handle", false);
172 message_handled = layer_tree_host_->SendMessageToMicroBenchmark( 172 message_handled =
173 id, message.PassAs<base::Value>()); 173 layer_tree_host_->SendMessageToMicroBenchmark(id, message.Pass());
174 EXPECT_FALSE(message_handled); 174 EXPECT_FALSE(message_handled);
175 } 175 }
176 176
177 } // namespace 177 } // namespace
178 } // namespace cc 178 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/micro_benchmark_controller.cc ('k') | cc/debug/picture_record_benchmark.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698