| Index: cc/surfaces/surface_aggregator_unittest.cc
 | 
| diff --git a/cc/surfaces/surface_aggregator_unittest.cc b/cc/surfaces/surface_aggregator_unittest.cc
 | 
| index bee479c0b26ab7f04272824f92dc6abb8c567717..63aba465dd31358a5084db2494be9dc4cc8b8552 100644
 | 
| --- a/cc/surfaces/surface_aggregator_unittest.cc
 | 
| +++ b/cc/surfaces/surface_aggregator_unittest.cc
 | 
| @@ -43,20 +43,47 @@ gfx::Size SurfaceSize() {
 | 
|  class EmptySurfaceFactoryClient : public SurfaceFactoryClient {
 | 
|   public:
 | 
|    void ReturnResources(const ReturnedResourceArray& resources) override {}
 | 
| +
 | 
|    void WillDrawSurface(SurfaceId id, const gfx::Rect& damage_rect) override {
 | 
|      last_surface_id_ = id;
 | 
|      last_damage_rect_ = damage_rect;
 | 
|    }
 | 
|  
 | 
| +  void SetBeginFrameSource(SurfaceId surface_id,
 | 
| +                           BeginFrameSource* begin_frame_source) override {}
 | 
| +
 | 
|    gfx::Rect last_damage_rect_;
 | 
|    SurfaceId last_surface_id_;
 | 
|  };
 | 
|  
 | 
| +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) {}
 | 
|  
 | 
| @@ -64,14 +91,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);
 | 
|  }
 | 
|  
 | 
| @@ -88,6 +121,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 {
 | 
| @@ -158,6 +192,7 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
 | 
|  
 | 
|   protected:
 | 
|    SurfaceId root_surface_id_;
 | 
| +  Surface* root_surface_;
 | 
|    SurfaceIdAllocator allocator_;
 | 
|    SurfaceIdAllocator child_allocator_;
 | 
|  };
 | 
| @@ -172,7 +207,10 @@ 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_));
 | 
|  
 | 
|    // Check that WillDrawSurface was called.
 | 
|    EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_);
 | 
| @@ -182,6 +220,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) {
 | 
|  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)};
 | 
| @@ -196,9 +236,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));
 | 
| +
 | 
|    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);
 | 
|  
 | 
| @@ -232,7 +278,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
 | 
| @@ -242,6 +291,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[] = {
 | 
| @@ -257,6 +308,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)};
 | 
| @@ -266,12 +320,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[] = {
 | 
| @@ -291,9 +350,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);
 | 
|  
 | 
| @@ -330,6 +395,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[] = {
 | 
| @@ -370,9 +437,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);
 | 
|  
 | 
| @@ -420,6 +493,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)};
 | 
| @@ -448,9 +523,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);
 | 
|  
 | 
| @@ -570,8 +651,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
 | 
| @@ -579,6 +663,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)};
 | 
| @@ -591,8 +678,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);
 | 
|  }
 | 
|  
 | 
| @@ -609,14 +700,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),
 | 
| @@ -648,8 +743,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);
 | 
|  }
 | 
|  
 | 
| @@ -658,6 +757,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)},
 | 
| @@ -680,9 +781,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);
 | 
|  
 | 
| @@ -780,6 +888,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());
 | 
| @@ -792,6 +902,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(
 | 
| @@ -810,6 +922,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(
 | 
| @@ -843,9 +957,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);
 | 
|  
 | 
| @@ -891,8 +1015,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)},
 | 
| @@ -932,8 +1058,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[] = {
 | 
| @@ -996,9 +1124,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);
 | 
|  
 | 
| @@ -1102,6 +1238,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());
 | 
|  
 | 
| @@ -1128,6 +1265,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());
 | 
|  
 | 
| @@ -1163,9 +1301,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);
 | 
|  
 | 
| @@ -1200,9 +1346,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);
 | 
|  
 | 
| @@ -1262,9 +1416,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);
 | 
|  
 | 
| @@ -1283,9 +1445,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);
 | 
|  
 | 
| @@ -1302,10 +1472,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);
 | 
|  
 | 
| @@ -1334,6 +1512,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).
 | 
| @@ -1379,9 +1558,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);
 | 
|  
 | 
| @@ -1414,9 +1599,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);
 | 
|  
 | 
| @@ -1469,9 +1660,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);
 | 
|  
 | 
| @@ -1493,9 +1690,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);
 | 
|  
 | 
| @@ -1524,8 +1727,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:
 | 
| @@ -1535,6 +1739,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 {
 | 
| @@ -1550,6 +1755,9 @@ class ResourceTrackingSurfaceFactoryClient : public SurfaceFactoryClient {
 | 
|      return returned_resources_;
 | 
|    }
 | 
|  
 | 
| +  void SetBeginFrameSource(SurfaceId surface_id,
 | 
| +                           BeginFrameSource* begin_frame_source) override {}
 | 
| +
 | 
|   private:
 | 
|    ReturnedResourceArray returned_resources_;
 | 
|  
 | 
| @@ -1609,21 +1817,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) {
 | 
| @@ -1639,6 +1856,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();
 | 
| @@ -1655,9 +1873,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());
 | 
|  
 | 
| @@ -1672,29 +1894,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) {
 | 
| @@ -1703,8 +1940,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
 | 
| @@ -1714,10 +1951,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(),
 | 
| @@ -1733,9 +1973,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());
 | 
| @@ -1745,8 +1993,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());
 | 
| 
 |