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

Unified Diff: cc/surfaces/surface_aggregator_unittest.cc

Issue 1304063014: cc: Plumbing for BeginFrameSource based on Surfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More use-after-free. Attempt to fix mojo. Created 5 years, 3 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 b2476d9df57081d916758de740b4559a9dff9321..4de275f08a1b8c033eb2923eb6db9bfa0666ec09 100644
--- a/cc/surfaces/surface_aggregator_unittest.cc
+++ b/cc/surfaces/surface_aggregator_unittest.cc
@@ -43,13 +43,37 @@ gfx::Size SurfaceSize() {
class EmptySurfaceFactoryClient : public SurfaceFactoryClient {
public:
void ReturnResources(const ReturnedResourceArray& resources) override {}
+ void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {}
+};
+
+class FakeSurfaceAggregatorClient : public SurfaceAggregatorClient {
+ public:
+ void AddSurface(Surface* surface) override {
+ EXPECT_FALSE(HasSurface(surface));
+ surfaces_.insert(surface);
+ }
+
+ void RemoveSurface(Surface* surface) override {
+ EXPECT_TRUE(HasSurface(surface));
+ surfaces_.erase(surface);
+ }
+
+ bool HasSurface(Surface* surface) const {
+ return surfaces_.count(surface) != 0;
+ }
+
+ private:
+ std::set<Surface*> surfaces_;
};
class SurfaceAggregatorTest : public testing::Test {
public:
explicit SurfaceAggregatorTest(bool use_damage_rect)
: factory_(&manager_, &empty_client_),
- aggregator_(&manager_, NULL, use_damage_rect) {}
+ aggregator_(&surface_aggregator_client_,
+ &manager_,
+ NULL,
+ use_damage_rect) {}
SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {}
@@ -57,14 +81,20 @@ class SurfaceAggregatorTest : public testing::Test {
SurfaceManager manager_;
EmptySurfaceFactoryClient empty_client_;
SurfaceFactory factory_;
+ FakeSurfaceAggregatorClient surface_aggregator_client_;
SurfaceAggregator aggregator_;
};
TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) {
SurfaceId one_id(7);
factory_.Create(one_id);
+ Surface* surface = manager_.GetSurfaceForId(one_id);
+
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface));
scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one_id);
EXPECT_FALSE(frame);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface));
+
factory_.Destroy(one_id);
}
@@ -81,6 +111,7 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
SurfaceAggregatorTest::SetUp();
root_surface_id_ = allocator_.GenerateId();
factory_.Create(root_surface_id_);
+ root_surface_ = manager_.GetSurfaceForId(root_surface_id_);
}
void TearDown() override {
@@ -151,6 +182,7 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
protected:
SurfaceId root_surface_id_;
+ Surface* root_surface_;
SurfaceIdAllocator allocator_;
SurfaceIdAllocator child_allocator_;
};
@@ -165,12 +197,17 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) {
SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_);
SurfaceId ids[] = {root_surface_id_};
+
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
}
TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) {
SurfaceId embedded_surface_id = allocator_.GenerateId();
factory_.Create(embedded_surface_id);
+ Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface));
test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
test::Quad::SolidColorQuad(SK_ColorBLUE)};
@@ -185,9 +222,15 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) {
SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface));
mithro-old 2015/10/01 03:00:24 Thanks for adding these! I wonder if would be a g
brianderson 2015/10/07 20:54:48 Might do it as a followup patch since I can't thin
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -221,7 +264,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) {
SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_);
SurfaceId ids[] = {root_surface_id_};
+
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
}
// This tests very simple embedding. root_surface has a frame containing a few
@@ -231,6 +277,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) {
TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) {
SurfaceId embedded_surface_id = allocator_.GenerateId();
factory_.Create(embedded_surface_id);
+ Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface));
test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
test::Pass embedded_passes[] = {
@@ -246,6 +294,9 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) {
SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface));
+
test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
test::Quad::SolidColorQuad(SK_ColorGREEN),
test::Quad::SolidColorQuad(SK_ColorBLACK)};
@@ -255,12 +306,17 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) {
AggregateAndVerify(
expected_passes, arraysize(expected_passes), ids, arraysize(ids));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface));
+
factory_.Destroy(embedded_surface_id);
}
TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) {
SurfaceId embedded_surface_id = allocator_.GenerateId();
factory_.Create(embedded_surface_id);
+ Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface));
test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
test::Pass embedded_passes[] = {
@@ -280,9 +336,15 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) {
SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -319,6 +381,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) {
TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) {
SurfaceId embedded_surface_id = allocator_.GenerateId();
factory_.Create(embedded_surface_id);
+ Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface));
test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
test::Pass embedded_passes[] = {
@@ -359,9 +423,15 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) {
SurfaceFactory::DrawCallback());
}
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -409,6 +479,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) {
TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) {
SurfaceId embedded_surface_id = child_allocator_.GenerateId();
factory_.Create(embedded_surface_id);
+ Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface));
RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2),
RenderPassId(1, 3)};
@@ -437,9 +509,15 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) {
SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -559,8 +637,11 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) {
test::Pass expected_passes[] = {
test::Pass(expected_quads, arraysize(expected_quads))};
SurfaceId ids[] = {root_surface_id_, InvalidSurfaceId()};
+
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
AggregateAndVerify(
expected_passes, arraysize(expected_passes), ids, arraysize(ids));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
}
// Tests a reference to a valid surface with no submitted frame. This quad
@@ -568,6 +649,9 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) {
TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) {
SurfaceId surface_with_no_frame_id = allocator_.GenerateId();
factory_.Create(surface_with_no_frame_id);
+ Surface* surface_with_no_frame =
+ manager_.GetSurfaceForId(surface_with_no_frame_id);
+
test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f),
test::Quad::SolidColorQuad(SK_ColorBLUE)};
@@ -580,8 +664,12 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) {
test::Pass expected_passes[] = {
test::Pass(expected_quads, arraysize(expected_quads))};
SurfaceId ids[] = {root_surface_id_, surface_with_no_frame_id};
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface_with_no_frame));
AggregateAndVerify(
expected_passes, arraysize(expected_passes), ids, arraysize(ids));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface_with_no_frame));
factory_.Destroy(surface_with_no_frame_id);
}
@@ -598,14 +686,18 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) {
test::Pass expected_passes[] = {
test::Pass(expected_quads, arraysize(expected_quads))};
SurfaceId ids[] = {root_surface_id_};
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
AggregateAndVerify(
expected_passes, arraysize(expected_passes), ids, arraysize(ids));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
}
// Tests a more complex cycle with one intermediate surface.
TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) {
SurfaceId child_surface_id = allocator_.GenerateId();
factory_.Create(child_surface_id);
+ Surface* child_surface = manager_.GetSurfaceForId(child_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface));
test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE),
test::Quad::SurfaceQuad(child_surface_id, 1.f),
@@ -637,8 +729,12 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) {
test::Pass expected_passes[] = {
test::Pass(expected_quads, arraysize(expected_quads))};
SurfaceId ids[] = {root_surface_id_, child_surface_id};
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface));
AggregateAndVerify(
expected_passes, arraysize(expected_passes), ids, arraysize(ids));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
factory_.Destroy(child_surface_id);
}
@@ -647,6 +743,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) {
TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) {
SurfaceId child_surface_id = allocator_.GenerateId();
factory_.Create(child_surface_id);
+ Surface* child_surface = manager_.GetSurfaceForId(child_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface));
RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)};
test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)},
@@ -669,9 +767,16 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) {
SubmitCompositorFrame(parent_passes, arraysize(parent_passes),
root_surface_id_);
+
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -769,6 +874,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
RenderPassId pass_id(1, 1);
SurfaceId grandchild_surface_id = allocator_.GenerateId();
factory_.Create(grandchild_surface_id);
+ Surface* grandchild_surface = manager_.GetSurfaceForId(grandchild_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(grandchild_surface));
scoped_ptr<RenderPass> grandchild_pass = RenderPass::Create();
gfx::Rect output_rect(SurfaceSize());
gfx::Rect damage_rect(SurfaceSize());
@@ -781,6 +888,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
SurfaceId child_one_surface_id = allocator_.GenerateId();
factory_.Create(child_one_surface_id);
+ Surface* child_one_surface = manager_.GetSurfaceForId(child_one_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_one_surface));
scoped_ptr<RenderPass> child_one_pass = RenderPass::Create();
child_one_pass->SetNew(
@@ -799,6 +908,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
SurfaceId child_two_surface_id = allocator_.GenerateId();
factory_.Create(child_two_surface_id);
+ Surface* child_two_surface = manager_.GetSurfaceForId(child_two_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_two_surface));
scoped_ptr<RenderPass> child_two_pass = RenderPass::Create();
child_two_pass->SetNew(
@@ -832,9 +943,19 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
QueuePassAsFrame(root_pass.Pass(), root_surface_id_);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(grandchild_surface));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_one_surface));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_two_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(grandchild_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_one_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_two_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -880,8 +1001,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
// Innermost child surface.
SurfaceId child_surface_id = allocator_.GenerateId();
+ factory_.Create(child_surface_id);
+ Surface* child_surface = manager_.GetSurfaceForId(child_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface));
{
- factory_.Create(child_surface_id);
RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)};
test::Quad child_quads[][1] = {
{test::Quad::SolidColorQuad(SK_ColorGREEN)},
@@ -921,8 +1044,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
// Middle child surface.
SurfaceId middle_surface_id = allocator_.GenerateId();
+ factory_.Create(middle_surface_id);
+ Surface* middle_surface = manager_.GetSurfaceForId(middle_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(middle_surface));
{
- factory_.Create(middle_surface_id);
test::Quad middle_quads[] = {
test::Quad::SurfaceQuad(child_surface_id, 1.f)};
test::Pass middle_passes[] = {
@@ -985,9 +1110,17 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
factory_.SubmitCompositorFrame(root_surface_id_, root_frame.Pass(),
SurfaceFactory::DrawCallback());
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(middle_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(middle_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -1091,6 +1224,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
SurfaceId child_surface_id = allocator_.GenerateId();
factory_.Create(child_surface_id);
+ Surface* child_surface = manager_.GetSurfaceForId(child_surface_id);
factory_.SubmitCompositorFrame(child_surface_id, child_frame.Pass(),
SurfaceFactory::DrawCallback());
@@ -1117,6 +1251,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
SurfaceId parent_surface_id = allocator_.GenerateId();
factory_.Create(parent_surface_id);
+ Surface* parent_surface = manager_.GetSurfaceForId(parent_surface_id);
factory_.SubmitCompositorFrame(parent_surface_id, parent_surface_frame.Pass(),
SurfaceFactory::DrawCallback());
@@ -1152,9 +1287,17 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
factory_.SubmitCompositorFrame(root_surface_id_, root_frame.Pass(),
SurfaceFactory::DrawCallback());
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(parent_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -1189,9 +1332,17 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
factory_.SubmitCompositorFrame(child_surface_id, child_frame.Pass(),
SurfaceFactory::DrawCallback());
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -1251,9 +1402,17 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
factory_.SubmitCompositorFrame(root_surface_id_, root_frame.Pass(),
SurfaceFactory::DrawCallback());
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -1272,9 +1431,17 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
// No Surface changed, so no damage should be given.
{
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -1291,10 +1458,18 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
// SetFullDamageRectForSurface should cause the entire output to be
// marked as damaged.
{
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface));
+
aggregator_.SetFullDamageForSurface(root_surface_id_);
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -1323,6 +1498,7 @@ class SurfaceAggregatorPartialSwapTest
TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
SurfaceId child_surface_id = allocator_.GenerateId();
factory_.Create(child_surface_id);
+ Surface* child_surface = manager_.GetSurfaceForId(child_surface_id);
// The child surface has two quads, one with a visible rect of 13,13 4x4 and
// the other other with a visible rect of 10,10 2x2 (relative to root target
// space).
@@ -1368,9 +1544,15 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
SubmitPassListAsFrame(root_surface_id_, &root_pass_list);
}
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -1403,9 +1585,15 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
}
{
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -1458,9 +1646,15 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
}
{
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -1482,9 +1676,15 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
}
{
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_id_);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
@@ -1513,8 +1713,9 @@ class SurfaceAggregatorWithResourcesTest : public testing::Test {
resource_provider_ = FakeResourceProvider::Create(
output_surface_.get(), shared_bitmap_manager_.get());
- aggregator_.reset(
- new SurfaceAggregator(&manager_, resource_provider_.get(), false));
+ aggregator_.reset(new SurfaceAggregator(&surface_aggregator_client_,
+ &manager_, resource_provider_.get(),
+ false));
}
protected:
@@ -1524,6 +1725,7 @@ class SurfaceAggregatorWithResourcesTest : public testing::Test {
scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
scoped_ptr<ResourceProvider> resource_provider_;
scoped_ptr<SurfaceAggregator> aggregator_;
+ FakeSurfaceAggregatorClient surface_aggregator_client_;
};
class ResourceTrackingSurfaceFactoryClient : public SurfaceFactoryClient {
@@ -1539,6 +1741,8 @@ class ResourceTrackingSurfaceFactoryClient : public SurfaceFactoryClient {
return returned_resources_;
}
+ void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {}
+
private:
ReturnedResourceArray returned_resources_;
@@ -1598,21 +1802,30 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) {
SurfaceFactory factory(&manager_, &client);
SurfaceId surface_id(7u);
factory.Create(surface_id);
+ Surface* surface = manager_.GetSurfaceForId(surface_id);
ResourceId ids[] = {11, 12, 13};
SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
&factory, surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface));
+
scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface));
+
// Nothing should be available to be returned yet.
EXPECT_TRUE(client.returned_resources().empty());
SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory,
surface_id);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface));
+
frame = aggregator_->Aggregate(surface_id);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface));
+
ASSERT_EQ(3u, client.returned_resources().size());
ResourceId returned_ids[3];
for (size_t i = 0; i < 3; ++i) {
@@ -1628,6 +1841,7 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) {
SurfaceFactory factory(&manager_, &client);
SurfaceId surface_id(7u);
factory.Create(surface_id);
+ Surface* surface = manager_.GetSurfaceForId(surface_id);
scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
scoped_ptr<RenderPass> pass = RenderPass::Create();
@@ -1644,9 +1858,13 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) {
factory.SubmitCompositorFrame(surface_id, frame.Pass(),
SurfaceFactory::DrawCallback());
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface));
+
scoped_ptr<CompositorFrame> returned_frame =
aggregator_->Aggregate(surface_id);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface));
+
// Nothing should be available to be returned yet.
EXPECT_TRUE(client.returned_resources().empty());
@@ -1661,29 +1879,44 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) {
TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) {
ResourceTrackingSurfaceFactoryClient client;
SurfaceFactory factory(&manager_, &client);
- SurfaceId surface_id(7u);
- factory.Create(surface_id);
- SurfaceId surface_id2(8u);
- factory.Create(surface_id2);
+ SurfaceId surface1_id(7u);
+ factory.Create(surface1_id);
+ Surface* surface1 = manager_.GetSurfaceForId(surface1_id);
+
+ SurfaceId surface2_id(8u);
+ factory.Create(surface2_id);
+ Surface* surface2 = manager_.GetSurfaceForId(surface2_id);
ResourceId ids[] = {11, 12, 13};
SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
- &factory, surface_id);
+ &factory, surface1_id);
ResourceId ids2[] = {14, 15, 16};
SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(),
- &factory, surface_id2);
+ &factory, surface2_id);
- scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface1));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface2));
+
+ scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface1_id);
+
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface1));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface2));
SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory,
- surface_id);
+ surface1_id);
// Nothing should be available to be returned yet.
EXPECT_TRUE(client.returned_resources().empty());
- frame = aggregator_->Aggregate(surface_id2);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface1));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface2));
+
+ frame = aggregator_->Aggregate(surface2_id);
- // surface_id wasn't referenced, so its resources should be returned.
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface1));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface2));
+
+ // surface1_id wasn't referenced, so its resources should be returned.
ASSERT_EQ(3u, client.returned_resources().size());
ResourceId returned_ids[3];
for (size_t i = 0; i < 3; ++i) {
@@ -1692,8 +1925,8 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) {
EXPECT_THAT(returned_ids,
testing::WhenSorted(testing::ElementsAreArray(ids)));
EXPECT_EQ(3u, resource_provider_->num_resources());
- factory.Destroy(surface_id);
- factory.Destroy(surface_id2);
+ factory.Destroy(surface1_id);
+ factory.Destroy(surface2_id);
}
// Ensure that aggregator completely ignores Surfaces that reference invalid
@@ -1703,10 +1936,13 @@ TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) {
SurfaceFactory factory(&manager_, &client);
SurfaceId root_surface_id(7u);
factory.Create(root_surface_id);
+ Surface* root_surface = manager_.GetSurfaceForId(root_surface_id);
SurfaceId middle_surface_id(8u);
factory.Create(middle_surface_id);
+ Surface* middle_surface = manager_.GetSurfaceForId(middle_surface_id);
SurfaceId child_surface_id(9u);
factory.Create(child_surface_id);
+ Surface* child_surface = manager_.GetSurfaceForId(child_surface_id);
ResourceId ids[] = {14, 15, 16};
SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
@@ -1722,9 +1958,17 @@ TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) {
middle_surface_id, &factory,
root_surface_id);
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(middle_surface));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface));
+
scoped_ptr<CompositorFrame> frame;
frame = aggregator_->Aggregate(root_surface_id);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(middle_surface));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface));
+
RenderPassList* pass_list = &frame->delegated_frame_data->render_pass_list;
ASSERT_EQ(1u, pass_list->size());
EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size());
@@ -1734,8 +1978,16 @@ TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) {
child_surface_id, &factory,
middle_surface_id);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(middle_surface));
+ EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface));
+
frame = aggregator_->Aggregate(root_surface_id);
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(middle_surface));
+ EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface));
+
pass_list = &frame->delegated_frame_data->render_pass_list;
ASSERT_EQ(1u, pass_list->size());
EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size());

Powered by Google App Engine
This is Rietveld 408576698