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

Unified Diff: cc/surfaces/surface_aggregator_unittest.cc

Issue 2835393003: Reject frames with invalid BeginFrameAck in CompositorFrameSinkSupport (Closed)
Patch Set: Fixed header Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: cc/surfaces/surface_aggregator_unittest.cc
diff --git a/cc/surfaces/surface_aggregator_unittest.cc b/cc/surfaces/surface_aggregator_unittest.cc
index cac6b14effb2b49dade5ed4900af679b1b166255..e02b73c06856656618fe32fa7e6f7b4c9752a336 100644
--- a/cc/surfaces/surface_aggregator_unittest.cc
+++ b/cc/surfaces/surface_aggregator_unittest.cc
@@ -22,6 +22,7 @@
#include "cc/surfaces/local_surface_id_allocator.h"
#include "cc/surfaces/surface.h"
#include "cc/surfaces/surface_manager.h"
+#include "cc/test/compositor_frame_helpers.h"
#include "cc/test/fake_compositor_frame_sink_support_client.h"
#include "cc/test/fake_resource_provider.h"
#include "cc/test/render_pass_test_utils.h"
@@ -57,14 +58,6 @@ gfx::Size SurfaceSize() {
return size;
}
-CompositorFrame MakeCompositorFrame() {
- CompositorFrame frame;
- frame.metadata.begin_frame_ack.source_id = BeginFrameArgs::kManualSourceId;
- frame.metadata.begin_frame_ack.sequence_number =
- BeginFrameArgs::kStartingFrameNumber;
- return frame;
-}
-
class SurfaceAggregatorTest : public testing::Test {
public:
explicit SurfaceAggregatorTest(bool use_damage_rect)
@@ -94,7 +87,8 @@ class SurfaceAggregatorTest : public testing::Test {
TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) {
LocalSurfaceId local_surface_id(7, base::UnguessableToken::Create());
SurfaceId one_id(kArbitraryRootFrameSinkId, local_surface_id);
- support_->SubmitCompositorFrame(local_surface_id, MakeCompositorFrame());
+ support_->SubmitCompositorFrame(local_surface_id,
+ test::MakeCompositorFrame());
CompositorFrame frame = aggregator_.Aggregate(one_id);
EXPECT_TRUE(frame.render_pass_list.empty());
@@ -154,7 +148,7 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
void SubmitPassListAsFrame(CompositorFrameSinkSupport* support,
const LocalSurfaceId& local_surface_id,
RenderPassList* pass_list) {
- CompositorFrame frame = MakeCompositorFrame();
+ CompositorFrame frame = test::MakeCompositorFrame();
pass_list->swap(frame.render_pass_list);
support->SubmitCompositorFrame(local_surface_id, std::move(frame));
@@ -172,7 +166,7 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
void QueuePassAsFrame(std::unique_ptr<RenderPass> pass,
const LocalSurfaceId& local_surface_id,
CompositorFrameSinkSupport* support) {
- CompositorFrame child_frame = MakeCompositorFrame();
+ CompositorFrame child_frame = test::MakeCompositorFrame();
child_frame.render_pass_list.push_back(std::move(pass));
support->SubmitCompositorFrame(local_surface_id, std::move(child_frame));
@@ -590,7 +584,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) {
test::Pass(root_quads, arraysize(root_quads), 1),
test::Pass(root_quads2, arraysize(root_quads2), 2)};
{
- CompositorFrame frame = MakeCompositorFrame();
+ CompositorFrame frame = test::MakeCompositorFrame();
AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
arraysize(root_passes));
frame.render_pass_list[0]->copy_requests.push_back(std::move(copy_request));
@@ -677,7 +671,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
test::Pass(parent_quads, arraysize(parent_quads))};
{
- CompositorFrame frame = MakeCompositorFrame();
+ CompositorFrame frame = test::MakeCompositorFrame();
AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes,
arraysize(parent_passes));
@@ -693,7 +687,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
{
- CompositorFrame frame = MakeCompositorFrame();
+ CompositorFrame frame = test::MakeCompositorFrame();
AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
arraysize(root_passes));
@@ -1124,7 +1118,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
grandchild_local_surface_id);
grandchild_support->SubmitCompositorFrame(grandchild_local_surface_id,
- MakeCompositorFrame());
+ test::MakeCompositorFrame());
std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create();
gfx::Rect output_rect(SurfaceSize());
gfx::Rect damage_rect(SurfaceSize());
@@ -1140,7 +1134,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
SurfaceId child_one_surface_id(child_one_support->frame_sink_id(),
child_one_local_surface_id);
child_one_support->SubmitCompositorFrame(child_one_local_surface_id,
- MakeCompositorFrame());
+ test::MakeCompositorFrame());
std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create();
child_one_pass->SetNew(pass_id, output_rect, damage_rect,
@@ -1162,7 +1156,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
SurfaceId child_two_surface_id(child_two_support->frame_sink_id(),
child_two_local_surface_id);
child_two_support->SubmitCompositorFrame(child_two_local_surface_id,
- MakeCompositorFrame());
+ test::MakeCompositorFrame());
std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create();
child_two_pass->SetNew(pass_id, output_rect, damage_rect,
@@ -1260,7 +1254,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
test::Pass(child_quads[1], arraysize(child_quads[1]),
child_pass_id[1])};
- CompositorFrame child_frame = MakeCompositorFrame();
+ CompositorFrame child_frame = test::MakeCompositorFrame();
AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
child_passes, arraysize(child_passes));
@@ -1292,7 +1286,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
test::Pass(middle_quads, arraysize(middle_quads)),
};
- CompositorFrame middle_frame = MakeCompositorFrame();
+ CompositorFrame middle_frame = test::MakeCompositorFrame();
AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()),
middle_passes, arraysize(middle_passes));
@@ -1316,7 +1310,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
test::Pass(secondary_quads, arraysize(secondary_quads)),
test::Pass(root_quads, arraysize(root_quads))};
- CompositorFrame root_frame = MakeCompositorFrame();
+ CompositorFrame root_frame = test::MakeCompositorFrame();
AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
arraysize(root_passes));
@@ -1420,7 +1414,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
test::Pass child_passes[] = {
test::Pass(child_quads, arraysize(child_quads), 1)};
- CompositorFrame child_frame = MakeCompositorFrame();
+ CompositorFrame child_frame = test::MakeCompositorFrame();
AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
child_passes, arraysize(child_passes));
@@ -1442,7 +1436,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
// Parent surface is only used to test if the transform is applied correctly
// to the child surface's damage.
- CompositorFrame parent_surface_frame = MakeCompositorFrame();
+ CompositorFrame parent_surface_frame = test::MakeCompositorFrame();
AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()),
parent_surface_passes, arraysize(parent_surface_passes));
@@ -1460,7 +1454,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
test::Pass(root_surface_quads, arraysize(root_surface_quads), 1),
test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)};
- CompositorFrame root_frame = MakeCompositorFrame();
+ CompositorFrame root_frame = test::MakeCompositorFrame();
AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
arraysize(root_passes));
@@ -1486,7 +1480,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize())));
{
- CompositorFrame child_frame = MakeCompositorFrame();
+ CompositorFrame child_frame = test::MakeCompositorFrame();
AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
child_passes, arraysize(child_passes));
@@ -1515,7 +1509,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
}
{
- CompositorFrame root_frame = MakeCompositorFrame();
+ CompositorFrame root_frame = test::MakeCompositorFrame();
AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()),
root_passes, arraysize(root_passes));
@@ -1529,7 +1523,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
}
{
- CompositorFrame root_frame = MakeCompositorFrame();
+ CompositorFrame root_frame = test::MakeCompositorFrame();
AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()),
root_passes, arraysize(root_passes));
@@ -1595,7 +1589,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
test::Pass root_passes[] = {
test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)};
- CompositorFrame root_frame = MakeCompositorFrame();
+ CompositorFrame root_frame = test::MakeCompositorFrame();
AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
arraysize(root_passes));
@@ -1628,7 +1622,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
test::Pass root_passes[] = {test::Pass(
root_render_pass_quads, arraysize(root_render_pass_quads), 2)};
- CompositorFrame root_frame = MakeCompositorFrame();
+ CompositorFrame root_frame = test::MakeCompositorFrame();
AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()),
root_passes, arraysize(root_passes));
@@ -1973,7 +1967,7 @@ void SubmitCompositorFrameWithResources(ResourceId* resource_ids,
SurfaceId child_id,
CompositorFrameSinkSupport* support,
SurfaceId surface_id) {
- CompositorFrame frame = MakeCompositorFrame();
+ CompositorFrame frame = test::MakeCompositorFrame();
std::unique_ptr<RenderPass> pass = RenderPass::Create();
pass->id = 1;
SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
@@ -2057,7 +2051,7 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) {
LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create());
SurfaceId surface_id(support->frame_sink_id(), local_surface_id);
- CompositorFrame frame = MakeCompositorFrame();
+ CompositorFrame frame = test::MakeCompositorFrame();
std::unique_ptr<RenderPass> pass = RenderPass::Create();
pass->id = 1;
TransferableResource resource;
@@ -2228,7 +2222,7 @@ TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) {
surface1_id, SurfaceDrawQuadType::PRIMARY, nullptr);
pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest());
- CompositorFrame frame = MakeCompositorFrame();
+ CompositorFrame frame = test::MakeCompositorFrame();
frame.render_pass_list.push_back(std::move(pass));
support2->SubmitCompositorFrame(local_frame2_id, std::move(frame));

Powered by Google App Engine
This is Rietveld 408576698