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

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 unit test 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"
11 #include "cc/surfaces/surface_id.h" 11 #include "cc/surfaces/surface_id.h"
12 #include "cc/test/begin_frame_args_test.h" 12 #include "cc/test/begin_frame_args_test.h"
13 #include "cc/test/fake_external_begin_frame_source.h" 13 #include "cc/test/fake_external_begin_frame_source.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using testing::ElementsAre;
17 using testing::UnorderedElementsAre; 18 using testing::UnorderedElementsAre;
18 using testing::IsEmpty; 19 using testing::IsEmpty;
19 using testing::SizeIs; 20 using testing::SizeIs;
20 21
21 namespace cc { 22 namespace cc {
22 namespace test { 23 namespace test {
23 namespace { 24 namespace {
24 25
25 constexpr FrameSinkId kParentFrameSink(2, 1); 26 constexpr FrameSinkId kParentFrameSink(2, 1);
26 constexpr FrameSinkId kChildFrameSink1(65563, 1); 27 constexpr FrameSinkId kChildFrameSink1(65563, 1);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return child_support2().current_surface_for_testing(); 73 return child_support2().current_surface_for_testing();
73 } 74 }
74 75
75 CompositorFrameSinkSupport& support(int index) { return *supports_[index]; } 76 CompositorFrameSinkSupport& support(int index) { return *supports_[index]; }
76 Surface* surface(int index) { 77 Surface* surface(int index) {
77 return support(index).current_surface_for_testing(); 78 return support(index).current_surface_for_testing();
78 } 79 }
79 80
80 SurfaceManager& surface_manager() { return surface_manager_; } 81 SurfaceManager& surface_manager() { return surface_manager_; }
81 82
83 // Returns all the references where |surface_id| is the parent.
84 const SurfaceManager::SurfaceIdSet& GetReferencesFrom(
vmpstr 2017/02/10 19:36:00 GetChildReferences?
Fady Samuel 2017/02/10 20:39:10 Done.
85 const SurfaceId& surface_id) {
86 return surface_manager().parent_to_child_refs_[surface_id];
87 }
88
89 // Returns all the temporary references for the given frame sink id.
90 std::vector<LocalSurfaceId> GetTempReferencesFor(
vmpstr 2017/02/10 19:36:00 GetTempReferences?
Fady Samuel 2017/02/10 20:39:10 Done.
91 const FrameSinkId& frame_sink_id) {
92 return surface_manager().temp_references_[frame_sink_id];
93 }
94
82 SurfaceDependencyTracker& dependency_tracker() { 95 SurfaceDependencyTracker& dependency_tracker() {
83 return *surface_manager_.dependency_tracker(); 96 return *surface_manager_.dependency_tracker();
84 } 97 }
85 98
86 FakeExternalBeginFrameSource* begin_frame_source() { 99 FakeExternalBeginFrameSource* begin_frame_source() {
87 return begin_frame_source_.get(); 100 return begin_frame_source_.get();
88 } 101 }
89 102
90 // testing::Test: 103 // testing::Test:
91 void SetUp() override { 104 void SetUp() override {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 EXPECT_TRUE(parent_surface()->HasPendingFrame()); 449 EXPECT_TRUE(parent_surface()->HasPendingFrame());
437 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), 450 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(),
438 UnorderedElementsAre(arbitrary_id)); 451 UnorderedElementsAre(arbitrary_id));
439 // Verify that the parent will add a reference to |arbitrary_id| and will not 452 // Verify that the parent will add a reference to |arbitrary_id| and will not
440 // remove a reference to |child_id|. 453 // remove a reference to |child_id|.
441 EXPECT_THAT(parent_reference_tracker().references_to_add(), 454 EXPECT_THAT(parent_reference_tracker().references_to_add(),
442 UnorderedElementsAre(parent_arbitrary_reference)); 455 UnorderedElementsAre(parent_arbitrary_reference));
443 EXPECT_THAT(parent_reference_tracker().references_to_remove(), IsEmpty()); 456 EXPECT_THAT(parent_reference_tracker().references_to_remove(), IsEmpty());
444 } 457 }
445 458
459 // This test verifies that a SurfaceReference from parent to child can be added
460 // prior to the child submitting a CompositorFrame. This test also verifies that
461 // when the child later submits a CompositorFrame,
462 TEST_F(CompositorFrameSinkSupportTest,
463 DisplayCompositorLockingReferenceAddedBeforeChildExists) {
464 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
465 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1);
466
467 // The parent submits a CompositorFrame that depends on |child_id| before the
468 // child submits a CompositorFrame.
469 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
470 MakeCompositorFrame({child_id}));
471
472 // Verify that the CompositorFrame is blocked on |child_id|.
473 EXPECT_FALSE(parent_surface()->HasActiveFrame());
474 EXPECT_TRUE(parent_surface()->HasPendingFrame());
475 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(),
476 UnorderedElementsAre(child_id));
vmpstr 2017/02/10 19:36:00 Does this mean there's just one element and it's c
kylechar 2017/02/10 19:51:27 I like EXPECT_THAT, so I'm kind of biased, but it
Fady Samuel 2017/02/10 20:39:10 I like EXPECT_THAT too. Learned it from Kyle's cod
477
478 // Verify that a SurfaceReference(parent_id, child_id) exists in the
479 // SurfaceManager.
480 EXPECT_THAT(GetReferencesFrom(parent_id), ElementsAre(child_id));
vmpstr 2017/02/10 19:36:00 same here
Fady Samuel 2017/02/10 20:39:10 Acknowledged.
481
482 child_support1().SubmitCompositorFrame(
483 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids()));
484
485 // Verify that the child CompositorFrame activates immediately.
486 EXPECT_TRUE(child_surface1()->HasActiveFrame());
487 EXPECT_FALSE(child_surface1()->HasPendingFrame());
488 EXPECT_THAT(child_surface1()->blocking_surfaces_for_testing(), IsEmpty());
489
490 // Verify that there is no temporary reference for the child and that
491 // the reference from the parent to the child still exists.
492 EXPECT_THAT(GetTempReferencesFor(child_id.frame_sink_id()), IsEmpty());
493 EXPECT_THAT(GetReferencesFrom(parent_id), ElementsAre(child_id));
494 }
495
446 } // namespace test 496 } // namespace test
447 } // namespace cc 497 } // 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