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

Side by Side Diff: cc/surfaces/surface_factory_unittest.cc

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 10 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/surfaces/surface_factory.cc ('k') | cc/surfaces/surface_manager.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/bind.h" 5 #include "base/bind.h"
6 #include "cc/output/compositor_frame.h" 6 #include "cc/output/compositor_frame.h"
7 #include "cc/output/delegated_frame_data.h" 7 #include "cc/output/delegated_frame_data.h"
8 #include "cc/surfaces/surface.h" 8 #include "cc/surfaces/surface.h"
9 #include "cc/surfaces/surface_factory.h" 9 #include "cc/surfaces/surface_factory.h"
10 #include "cc/surfaces/surface_factory_client.h" 10 #include "cc/surfaces/surface_factory_client.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 { 353 {
354 SCOPED_TRACE("fourth frame, second unref"); 354 SCOPED_TRACE("fourth frame, second unref");
355 ResourceProvider::ResourceId expected_returned_ids[] = {12, 13}; 355 ResourceProvider::ResourceId expected_returned_ids[] = {12, 13};
356 int expected_returned_counts[] = {2, 2}; 356 int expected_returned_counts[] = {2, 2};
357 CheckReturnedResourcesMatchExpected(expected_returned_ids, 357 CheckReturnedResourcesMatchExpected(expected_returned_ids,
358 expected_returned_counts, 358 expected_returned_counts,
359 arraysize(expected_returned_counts)); 359 arraysize(expected_returned_counts));
360 } 360 }
361 } 361 }
362 362
363 void DrawCallback(bool* executed, bool* result, bool drawn) { 363 void DrawCallback(uint32* execute_count,
364 *executed = true; 364 SurfaceDrawStatus* result,
365 SurfaceDrawStatus drawn) {
366 *execute_count += 1;
365 *result = drawn; 367 *result = drawn;
366 } 368 }
367 369
368 // Tests doing a DestroyAll before shutting down the factory; 370 // Tests doing a DestroyAll before shutting down the factory;
369 TEST_F(SurfaceFactoryTest, DestroyAll) { 371 TEST_F(SurfaceFactoryTest, DestroyAll) {
370 SurfaceId id(7); 372 SurfaceId id(7);
371 factory_.Create(id); 373 factory_.Create(id);
372 374
373 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 375 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
374 TransferableResource resource; 376 TransferableResource resource;
375 resource.id = 1; 377 resource.id = 1;
376 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; 378 resource.mailbox_holder.texture_target = GL_TEXTURE_2D;
377 frame_data->resource_list.push_back(resource); 379 frame_data->resource_list.push_back(resource);
378 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 380 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
379 frame->delegated_frame_data = frame_data.Pass(); 381 frame->delegated_frame_data = frame_data.Pass();
380 bool executed = false; 382 uint32 execute_count = 0;
381 bool drawn = false; 383 SurfaceDrawStatus drawn = SurfaceDrawStatus::DRAW_SKIPPED;
382 384
383 factory_.SubmitFrame(id, frame.Pass(), 385 factory_.SubmitFrame(id, frame.Pass(),
384 base::Bind(&DrawCallback, &executed, &drawn)); 386 base::Bind(&DrawCallback, &execute_count, &drawn));
385 387
386 surface_id_ = SurfaceId(); 388 surface_id_ = SurfaceId();
387 EXPECT_FALSE(executed);
388 factory_.DestroyAll(); 389 factory_.DestroyAll();
389 EXPECT_TRUE(executed); 390 EXPECT_EQ(1u, execute_count);
390 EXPECT_FALSE(drawn); 391 EXPECT_EQ(SurfaceDrawStatus::DRAW_SKIPPED, drawn);
391 } 392 }
392 393
393 TEST_F(SurfaceFactoryTest, DestroySequence) { 394 TEST_F(SurfaceFactoryTest, DestroySequence) {
394 SurfaceId id2(5); 395 SurfaceId id2(5);
395 factory_.Create(id2); 396 factory_.Create(id2);
396 397
397 // Check that waiting before the sequence is satisfied works. 398 // Check that waiting before the sequence is satisfied works.
398 manager_.GetSurfaceForId(id2) 399 manager_.GetSurfaceForId(id2)
399 ->AddDestructionDependency(SurfaceSequence(0, 4)); 400 ->AddDestructionDependency(SurfaceSequence(0, 4));
400 factory_.Destroy(id2); 401 factory_.Destroy(id2);
(...skipping 12 matching lines...) Expand all
413 factory_.Create(id2); 414 factory_.Create(id2);
414 DCHECK(manager_.GetSurfaceForId(id2)); 415 DCHECK(manager_.GetSurfaceForId(id2));
415 manager_.GetSurfaceForId(id2) 416 manager_.GetSurfaceForId(id2)
416 ->AddDestructionDependency(SurfaceSequence(0, 6)); 417 ->AddDestructionDependency(SurfaceSequence(0, 6));
417 factory_.Destroy(id2); 418 factory_.Destroy(id2);
418 DCHECK(!manager_.GetSurfaceForId(id2)); 419 DCHECK(!manager_.GetSurfaceForId(id2));
419 } 420 }
420 421
421 } // namespace 422 } // namespace
422 } // namespace cc 423 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory.cc ('k') | cc/surfaces/surface_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698