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

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 1247033007: cc: Abort frame when becoming invisible and waiting for ready to draw. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove race from test Created 5 years, 4 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/trees/layer_tree_host_impl.cc ('k') | cc/trees/single_thread_proxy.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 265 }
266 266
267 private: 267 private:
268 FakeContentLayerClient client_; 268 FakeContentLayerClient client_;
269 }; 269 };
270 270
271 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in 271 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in
272 // single threaded mode. 272 // single threaded mode.
273 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawNonEmpty); 273 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawNonEmpty);
274 274
275 // This tests if we get the READY_TO_DRAW signal and draw if we become invisible
276 // and then become visible again.
277 class LayerTreeHostTestReadyToDrawVisibility : public LayerTreeHostTest {
278 public:
279 LayerTreeHostTestReadyToDrawVisibility()
280 : LayerTreeHostTest(),
281 toggled_visibility_(false),
282 did_notify_ready_to_draw_(false),
283 did_draw_(false) {}
284
285 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
286
287 void SetupTree() override {
288 client_.set_fill_with_nonsolid_color(true);
289 scoped_refptr<FakePictureLayer> root_layer =
290 FakePictureLayer::Create(layer_settings(), &client_);
291 root_layer->SetBounds(gfx::Size(1024, 1024));
292 root_layer->SetIsDrawable(true);
293
294 layer_tree_host()->SetRootLayer(root_layer);
295 LayerTreeHostTest::SetupTree();
296 }
297
298 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
299 if (!toggled_visibility_) {
300 {
301 DebugScopedSetMainThread main(proxy());
302 layer_tree_host()->SetVisible(false);
303 }
304 toggled_visibility_ = true;
305 EXPECT_FALSE(host_impl->visible());
306 }
307 }
308
309 void NotifyReadyToDrawOnThread(LayerTreeHostImpl* host_impl) override {
310 // Sometimes the worker thread posts NotifyReadyToDraw in the extremely
311 // short duration of time between PrepareTiles and SetVisible(false) so we
312 // might get two NotifyReadyToDraw signals for this test.
313 did_notify_ready_to_draw_ = true;
314 }
315
316 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
317 EXPECT_FALSE(did_draw_);
318 did_draw_ = true;
319 EndTest();
320 }
321
322 void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) override {
323 if (!host_impl->visible()) {
324 {
325 DebugScopedSetMainThread main(proxy());
326 layer_tree_host()->SetVisible(true);
327 }
328 EXPECT_TRUE(host_impl->visible());
329 }
330 }
331
332 void AfterTest() override {
333 EXPECT_TRUE(did_notify_ready_to_draw_);
334 EXPECT_TRUE(did_draw_);
335 }
336
337 private:
338 FakeContentLayerClient client_;
339 bool toggled_visibility_;
340 bool did_notify_ready_to_draw_;
341 bool did_draw_;
342 };
343
344 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in
345 // single threaded mode.
346 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawVisibility);
347
275 class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest { 348 class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest {
276 public: 349 public:
277 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { 350 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
278 auto output_surface = make_scoped_ptr(new testing::StrictMock< 351 auto output_surface = make_scoped_ptr(new testing::StrictMock<
279 MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface>( 352 MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface>(
280 delegating_renderer())); 353 delegating_renderer()));
281 354
282 // At init, we expect one call to set visibility to true. 355 // At init, we expect one call to set visibility to true.
283 testing::Expectation visibility_true = 356 testing::Expectation visibility_true =
284 EXPECT_CALL(*output_surface, 357 EXPECT_CALL(*output_surface,
(...skipping 5770 matching lines...) Expand 10 before | Expand all | Expand 10 after
6055 void AfterTest() override {} 6128 void AfterTest() override {}
6056 6129
6057 std::vector<int> affected_by_page_scale_; 6130 std::vector<int> affected_by_page_scale_;
6058 std::vector<int> not_affected_by_page_scale_; 6131 std::vector<int> not_affected_by_page_scale_;
6059 }; 6132 };
6060 6133
6061 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestPageScaleFlags); 6134 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestPageScaleFlags);
6062 6135
6063 } // namespace 6136 } // namespace
6064 } // namespace cc 6137 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/single_thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698