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

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

Issue 2855723002: Don't submit frames with no render passes in cc tests (Closed)
Patch Set: c Created 3 years, 7 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_aggregator_unittest.cc ('k') | cc/surfaces/surface_hittest.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 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 "cc/surfaces/surface_factory.h" 5 #include "cc/surfaces/surface_factory.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "cc/output/compositor_frame.h" 15 #include "cc/output/compositor_frame.h"
16 #include "cc/output/copy_output_request.h" 16 #include "cc/output/copy_output_request.h"
17 #include "cc/output/copy_output_result.h" 17 #include "cc/output/copy_output_result.h"
18 #include "cc/resources/resource_provider.h" 18 #include "cc/resources/resource_provider.h"
19 #include "cc/surfaces/frame_sink_manager_client.h" 19 #include "cc/surfaces/frame_sink_manager_client.h"
20 #include "cc/surfaces/surface.h" 20 #include "cc/surfaces/surface.h"
21 #include "cc/surfaces/surface_factory_client.h" 21 #include "cc/surfaces/surface_factory_client.h"
22 #include "cc/surfaces/surface_info.h" 22 #include "cc/surfaces/surface_info.h"
23 #include "cc/surfaces/surface_manager.h" 23 #include "cc/surfaces/surface_manager.h"
24 #include "cc/surfaces/surface_resource_holder_client.h" 24 #include "cc/surfaces/surface_resource_holder_client.h"
25 #include "cc/test/compositor_frame_helpers.h"
25 #include "cc/test/fake_surface_resource_holder_client.h" 26 #include "cc/test/fake_surface_resource_holder_client.h"
26 #include "cc/test/scheduler_test_common.h" 27 #include "cc/test/scheduler_test_common.h"
27 #include "cc/test/stub_surface_factory_client.h" 28 #include "cc/test/stub_surface_factory_client.h"
28 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
29 #include "ui/gfx/geometry/size.h" 30 #include "ui/gfx/geometry/size.h"
30 31
31 namespace cc { 32 namespace cc {
32 namespace { 33 namespace {
33 34
34 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); 35 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 *changed = true; 76 *changed = true;
76 } 77 }
77 78
78 ~SurfaceFactoryTest() override { 79 ~SurfaceFactoryTest() override {
79 manager_.RemoveObserver(this); 80 manager_.RemoveObserver(this);
80 factory_->EvictSurface(); 81 factory_->EvictSurface();
81 } 82 }
82 83
83 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, 84 void SubmitCompositorFrameWithResources(ResourceId* resource_ids,
84 size_t num_resource_ids) { 85 size_t num_resource_ids) {
85 CompositorFrame frame; 86 CompositorFrame frame = test::MakeCompositorFrame();
86 for (size_t i = 0u; i < num_resource_ids; ++i) { 87 for (size_t i = 0u; i < num_resource_ids; ++i) {
87 TransferableResource resource; 88 TransferableResource resource;
88 resource.id = resource_ids[i]; 89 resource.id = resource_ids[i];
89 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; 90 resource.mailbox_holder.texture_target = GL_TEXTURE_2D;
90 resource.mailbox_holder.sync_token = frame_sync_token_; 91 resource.mailbox_holder.sync_token = frame_sync_token_;
91 frame.resource_list.push_back(resource); 92 frame.resource_list.push_back(resource);
92 } 93 }
93 factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), 94 factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame),
94 SurfaceFactory::DrawCallback(), 95 SurfaceFactory::DrawCallback(),
95 SurfaceFactory::WillDrawCallback()); 96 SurfaceFactory::WillDrawCallback());
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 { 445 {
445 SCOPED_TRACE("fourth frame, second unref"); 446 SCOPED_TRACE("fourth frame, second unref");
446 ResourceId expected_returned_ids[] = {12, 13}; 447 ResourceId expected_returned_ids[] = {12, 13};
447 int expected_returned_counts[] = {2, 2}; 448 int expected_returned_counts[] = {2, 2};
448 CheckReturnedResourcesMatchExpected( 449 CheckReturnedResourcesMatchExpected(
449 expected_returned_ids, expected_returned_counts, 450 expected_returned_ids, expected_returned_counts,
450 arraysize(expected_returned_counts), consumer_sync_token_); 451 arraysize(expected_returned_counts), consumer_sync_token_);
451 } 452 }
452 } 453 }
453 454
454 TEST_F(SurfaceFactoryTest, BlankNoIndexIncrement) {
455 LocalSurfaceId local_surface_id(6, kArbitraryToken);
456 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id);
457 factory_->SubmitCompositorFrame(local_surface_id, CompositorFrame(),
458 SurfaceFactory::DrawCallback(),
459 SurfaceFactory::WillDrawCallback());
460 Surface* surface = manager_.GetSurfaceForId(surface_id);
461 ASSERT_NE(nullptr, surface);
462 EXPECT_EQ(2, surface->frame_index());
463 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id);
464 }
465
466 void CreateSurfaceDrawCallback(SurfaceFactory* factory, 455 void CreateSurfaceDrawCallback(SurfaceFactory* factory,
467 uint32_t* execute_count) { 456 uint32_t* execute_count) {
468 LocalSurfaceId new_id(7, base::UnguessableToken::Create()); 457 LocalSurfaceId new_id(7, base::UnguessableToken::Create());
469 factory->SubmitCompositorFrame(new_id, CompositorFrame(), 458 factory->SubmitCompositorFrame(new_id, CompositorFrame(),
470 SurfaceFactory::DrawCallback(), 459 SurfaceFactory::DrawCallback(),
471 SurfaceFactory::WillDrawCallback()); 460 SurfaceFactory::WillDrawCallback());
472 factory->EvictSurface(); 461 factory->EvictSurface();
473 *execute_count += 1; 462 *execute_count += 1;
474 } 463 }
475 464
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 SurfaceFactory::DrawCallback(), 760 SurfaceFactory::DrawCallback(),
772 SurfaceFactory::WillDrawCallback()); 761 SurfaceFactory::WillDrawCallback());
773 SurfaceId expected_surface_id(factory_->frame_sink_id(), local_surface_id_); 762 SurfaceId expected_surface_id(factory_->frame_sink_id(), local_surface_id_);
774 EXPECT_EQ(expected_surface_id, last_surface_info_.id()); 763 EXPECT_EQ(expected_surface_id, last_surface_info_.id());
775 EXPECT_EQ(2.5f, last_surface_info_.device_scale_factor()); 764 EXPECT_EQ(2.5f, last_surface_info_.device_scale_factor());
776 EXPECT_EQ(gfx::Size(7, 8), last_surface_info_.size_in_pixels()); 765 EXPECT_EQ(gfx::Size(7, 8), last_surface_info_.size_in_pixels());
777 } 766 }
778 767
779 } // namespace 768 } // namespace
780 } // namespace cc 769 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator_unittest.cc ('k') | cc/surfaces/surface_hittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698