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

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

Issue 2685393003: Surfaces: Allow parent to refer to child surfaces that don't exist yet. (Closed)
Patch Set: Added a TODO to cleanup tests so that they don't create empty sets Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/surfaces/surface_manager.h » ('j') | cc/surfaces/surface_manager.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/compositor_frame_sink_support.h" 5 #include "cc/surfaces/compositor_frame_sink_support.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/surfaces/compositor_frame_sink_support_client.h" 9 #include "cc/surfaces/compositor_frame_sink_support_client.h"
10 #include "cc/surfaces/frame_sink_id.h" 10 #include "cc/surfaces/frame_sink_id.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return child_support2().current_surface_for_testing(); 72 return child_support2().current_surface_for_testing();
73 } 73 }
74 74
75 CompositorFrameSinkSupport& support(int index) { return *supports_[index]; } 75 CompositorFrameSinkSupport& support(int index) { return *supports_[index]; }
76 Surface* surface(int index) { 76 Surface* surface(int index) {
77 return support(index).current_surface_for_testing(); 77 return support(index).current_surface_for_testing();
78 } 78 }
79 79
80 SurfaceManager& surface_manager() { return surface_manager_; } 80 SurfaceManager& surface_manager() { return surface_manager_; }
81 81
82 // Returns all the references where |surface_id| is the parent.
83 const SurfaceManager::SurfaceIdSet& GetChildReferences(
84 const SurfaceId& surface_id) {
85 return surface_manager().parent_to_child_refs_[surface_id];
86 }
87
88 // Returns all the temporary references for the given frame sink id.
89 std::vector<LocalSurfaceId> GetTempReferences(
90 const FrameSinkId& frame_sink_id) {
91 return surface_manager().temp_references_[frame_sink_id];
92 }
93
82 SurfaceDependencyTracker& dependency_tracker() { 94 SurfaceDependencyTracker& dependency_tracker() {
83 return *surface_manager_.dependency_tracker(); 95 return *surface_manager_.dependency_tracker();
84 } 96 }
85 97
86 FakeExternalBeginFrameSource* begin_frame_source() { 98 FakeExternalBeginFrameSource* begin_frame_source() {
87 return begin_frame_source_.get(); 99 return begin_frame_source_.get();
88 } 100 }
89 101
90 // testing::Test: 102 // testing::Test:
91 void SetUp() override { 103 void SetUp() override {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 EXPECT_TRUE(parent_surface()->HasPendingFrame()); 448 EXPECT_TRUE(parent_surface()->HasPendingFrame());
437 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), 449 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(),
438 UnorderedElementsAre(arbitrary_id)); 450 UnorderedElementsAre(arbitrary_id));
439 // Verify that the parent will add a reference to |arbitrary_id| and will not 451 // Verify that the parent will add a reference to |arbitrary_id| and will not
440 // remove a reference to |child_id|. 452 // remove a reference to |child_id|.
441 EXPECT_THAT(parent_reference_tracker().references_to_add(), 453 EXPECT_THAT(parent_reference_tracker().references_to_add(),
442 UnorderedElementsAre(parent_arbitrary_reference)); 454 UnorderedElementsAre(parent_arbitrary_reference));
443 EXPECT_THAT(parent_reference_tracker().references_to_remove(), IsEmpty()); 455 EXPECT_THAT(parent_reference_tracker().references_to_remove(), IsEmpty());
444 } 456 }
445 457
458 // This test verifies that a SurfaceReference from parent to child can be added
459 // prior to the child submitting a CompositorFrame. This test also verifies that
460 // when the child later submits a CompositorFrame,
461 TEST_F(CompositorFrameSinkSupportTest,
462 DisplayCompositorLockingReferenceAddedBeforeChildExists) {
463 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
464 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1);
465
466 // The parent submits a CompositorFrame that depends on |child_id| before the
467 // child submits a CompositorFrame.
468 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
469 MakeCompositorFrame({child_id}));
470
471 // Verify that the CompositorFrame is blocked on |child_id|.
472 EXPECT_FALSE(parent_surface()->HasActiveFrame());
473 EXPECT_TRUE(parent_surface()->HasPendingFrame());
474 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(),
475 UnorderedElementsAre(child_id));
476
477 // Verify that a SurfaceReference(parent_id, child_id) exists in the
478 // SurfaceManager.
479 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id));
480
481 child_support1().SubmitCompositorFrame(
482 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids()));
483
484 // Verify that the child CompositorFrame activates immediately.
485 EXPECT_TRUE(child_surface1()->HasActiveFrame());
486 EXPECT_FALSE(child_surface1()->HasPendingFrame());
487 EXPECT_THAT(child_surface1()->blocking_surfaces_for_testing(), IsEmpty());
488
489 // Verify that there is no temporary reference for the child and that
490 // the reference from the parent to the child still exists.
491 EXPECT_THAT(GetTempReferences(child_id.frame_sink_id()), IsEmpty());
492 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id));
493 }
494
446 } // namespace test 495 } // namespace test
447 } // namespace cc 496 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/surface_manager.h » ('j') | cc/surfaces/surface_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698