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

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

Issue 2914023002: Remove LatencyInfo::sequence_number. (May break metrics).
Patch Set: Fix Windows. Created 3 years, 6 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
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 "base/containers/flat_set.h" 5 #include "base/containers/flat_set.h"
6 #include "cc/surfaces/compositor_frame_sink_support.h" 6 #include "cc/surfaces/compositor_frame_sink_support.h"
7 #include "cc/surfaces/surface_id.h" 7 #include "cc/surfaces/surface_id.h"
8 #include "cc/surfaces/surface_manager.h" 8 #include "cc/surfaces/surface_manager.h"
9 #include "cc/test/begin_frame_args_test.h" 9 #include "cc/test/begin_frame_args_test.h"
10 #include "cc/test/compositor_frame_helpers.h" 10 #include "cc/test/compositor_frame_helpers.h"
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 742
743 // Checks whether the latency info are moved to the new surface from the old 743 // Checks whether the latency info are moved to the new surface from the old
744 // one when LocalSurfaceId changes. No frame has unresolved dependencies. 744 // one when LocalSurfaceId changes. No frame has unresolved dependencies.
745 TEST_F(SurfaceSynchronizationTest, 745 TEST_F(SurfaceSynchronizationTest,
746 LatencyInfoCarriedOverOnResize_NoUnresolvedDependencies) { 746 LatencyInfoCarriedOverOnResize_NoUnresolvedDependencies) {
747 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); 747 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
748 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); 748 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2);
749 const ui::LatencyComponentType latency_type1 = 749 const ui::LatencyComponentType latency_type1 =
750 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; 750 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT;
751 const int64_t latency_id1 = 234; 751 const int64_t latency_id1 = 234;
752 const int64_t latency_sequence_number1 = 5645432;
753 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; 752 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT;
754 const int64_t latency_id2 = 31434351; 753 const int64_t latency_id2 = 31434351;
755 const int64_t latency_sequence_number2 = 663788;
756 754
757 // Submit a frame with latency info 755 // Submit a frame with latency info
758 ui::LatencyInfo info; 756 ui::LatencyInfo info;
759 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); 757 info.AddLatencyNumber(latency_type1, latency_id1);
760 758
761 CompositorFrame frame = MakeCompositorFrame(); 759 CompositorFrame frame = MakeCompositorFrame();
762 frame.metadata.latency_info.push_back(info); 760 frame.metadata.latency_info.push_back(info);
763 761
764 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 762 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
765 std::move(frame)); 763 std::move(frame));
766 764
767 // Verify that the old surface has an active frame and no pending frame. 765 // Verify that the old surface has an active frame and no pending frame.
768 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); 766 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1);
769 ASSERT_NE(nullptr, old_surface); 767 ASSERT_NE(nullptr, old_surface);
770 EXPECT_TRUE(old_surface->HasActiveFrame()); 768 EXPECT_TRUE(old_surface->HasActiveFrame());
771 EXPECT_FALSE(old_surface->HasPendingFrame()); 769 EXPECT_FALSE(old_surface->HasPendingFrame());
772 770
773 // Submit another frame with some other latency info and a different 771 // Submit another frame with some other latency info and a different
774 // LocalSurfaceId. 772 // LocalSurfaceId.
775 ui::LatencyInfo info2; 773 ui::LatencyInfo info2;
776 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); 774 info2.AddLatencyNumber(latency_type2, latency_id2);
777 775
778 CompositorFrame frame2 = MakeCompositorFrame(); 776 CompositorFrame frame2 = MakeCompositorFrame();
779 frame2.metadata.latency_info.push_back(info2); 777 frame2.metadata.latency_info.push_back(info2);
780 778
781 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), 779 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(),
782 std::move(frame2)); 780 std::move(frame2));
783 781
784 // Verify that the new surface has an active frame and no pending frames. 782 // Verify that the new surface has an active frame and no pending frames.
785 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); 783 Surface* surface = surface_manager().GetSurfaceForId(parent_id2);
786 ASSERT_NE(nullptr, surface); 784 ASSERT_NE(nullptr, surface);
787 EXPECT_TRUE(surface->HasActiveFrame()); 785 EXPECT_TRUE(surface->HasActiveFrame());
788 EXPECT_FALSE(surface->HasPendingFrame()); 786 EXPECT_FALSE(surface->HasPendingFrame());
789 787
790 // Verify that the new surface has both latency info elements. 788 // Verify that the new surface has both latency info elements.
791 std::vector<ui::LatencyInfo> info_list; 789 std::vector<ui::LatencyInfo> info_list;
792 surface->TakeLatencyInfo(&info_list); 790 surface->TakeLatencyInfo(&info_list);
793 EXPECT_EQ(2u, info_list.size()); 791 EXPECT_EQ(2u, info_list.size());
794 792
795 ui::LatencyInfo aggregated_latency_info = info_list[0]; 793 ui::LatencyInfo aggregated_latency_info = info_list[0];
796 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); 794 aggregated_latency_info.AddNewLatencyFrom(info_list[1]);
797 795
798 // Two components are the original ones, and the third one is 796 // Two components are the original ones, and the third one is
799 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame 797 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame
800 // submit. 798 // submit.
801 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size()); 799 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size());
802 800
803 ui::LatencyInfo::LatencyComponent comp1; 801 ui::LatencyInfo::LatencyComponent comp1;
804 EXPECT_TRUE( 802 EXPECT_TRUE(
805 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); 803 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1));
806 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number);
807 EXPECT_TRUE( 804 EXPECT_TRUE(
808 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); 805 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr));
809 EXPECT_TRUE(aggregated_latency_info.FindLatency( 806 EXPECT_TRUE(aggregated_latency_info.FindLatency(
810 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); 807 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr));
811 } 808 }
812 809
813 // Checks whether the latency info are moved to the new surface from the old 810 // Checks whether the latency info are moved to the new surface from the old
814 // one when LocalSurfaceId changes. Old surface has unresolved dependencies. 811 // one when LocalSurfaceId changes. Old surface has unresolved dependencies.
815 TEST_F(SurfaceSynchronizationTest, 812 TEST_F(SurfaceSynchronizationTest,
816 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) { 813 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) {
817 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); 814 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
818 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); 815 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2);
819 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); 816 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1);
820 817
821 const ui::LatencyComponentType latency_type1 = 818 const ui::LatencyComponentType latency_type1 =
822 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; 819 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT;
823 const int64_t latency_id1 = 234; 820 const int64_t latency_id1 = 234;
824 const int64_t latency_sequence_number1 = 5645432;
825 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; 821 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT;
826 const int64_t latency_id2 = 31434351; 822 const int64_t latency_id2 = 31434351;
827 const int64_t latency_sequence_number2 = 663788;
828 823
829 // Submit a frame with no unresolved dependecy. 824 // Submit a frame with no unresolved dependecy.
830 ui::LatencyInfo info; 825 ui::LatencyInfo info;
831 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); 826 info.AddLatencyNumber(latency_type1, latency_id1);
832 827
833 CompositorFrame frame = MakeCompositorFrame(); 828 CompositorFrame frame = MakeCompositorFrame();
834 frame.metadata.latency_info.push_back(info); 829 frame.metadata.latency_info.push_back(info);
835 830
836 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 831 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
837 std::move(frame)); 832 std::move(frame));
838 833
839 // Submit a frame with unresolved dependencies. 834 // Submit a frame with unresolved dependencies.
840 ui::LatencyInfo info2; 835 ui::LatencyInfo info2;
841 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); 836 info2.AddLatencyNumber(latency_type2, latency_id2);
842 837
843 CompositorFrame frame2 = MakeCompositorFrame({child_id}, empty_surface_ids(), 838 CompositorFrame frame2 = MakeCompositorFrame({child_id}, empty_surface_ids(),
844 TransferableResourceArray()); 839 TransferableResourceArray());
845 frame2.metadata.latency_info.push_back(info2); 840 frame2.metadata.latency_info.push_back(info2);
846 841
847 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 842 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
848 std::move(frame2)); 843 std::move(frame2));
849 844
850 // Verify that the old surface has both an active and a pending frame. 845 // Verify that the old surface has both an active and a pending frame.
851 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); 846 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1);
(...skipping 21 matching lines...) Expand all
873 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); 868 aggregated_latency_info.AddNewLatencyFrom(info_list[1]);
874 869
875 // Two components are the original ones, and the third one is 870 // Two components are the original ones, and the third one is
876 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame 871 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame
877 // submit. 872 // submit.
878 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size()); 873 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size());
879 874
880 ui::LatencyInfo::LatencyComponent comp1; 875 ui::LatencyInfo::LatencyComponent comp1;
881 EXPECT_TRUE( 876 EXPECT_TRUE(
882 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); 877 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1));
883 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number);
884 EXPECT_TRUE( 878 EXPECT_TRUE(
885 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); 879 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr));
886 EXPECT_TRUE(aggregated_latency_info.FindLatency( 880 EXPECT_TRUE(aggregated_latency_info.FindLatency(
887 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); 881 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr));
888 } 882 }
889 883
890 // Checks whether the latency info are moved to the new surface from the old 884 // Checks whether the latency info are moved to the new surface from the old
891 // one when LocalSurfaceId changes. The new surface has unresolved dependencies. 885 // one when LocalSurfaceId changes. The new surface has unresolved dependencies.
892 TEST_F(SurfaceSynchronizationTest, 886 TEST_F(SurfaceSynchronizationTest,
893 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) { 887 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) {
894 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); 888 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
895 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); 889 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2);
896 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); 890 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1);
897 891
898 const ui::LatencyComponentType latency_type1 = 892 const ui::LatencyComponentType latency_type1 =
899 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; 893 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT;
900 const int64_t latency_id1 = 234; 894 const int64_t latency_id1 = 234;
901 const int64_t latency_sequence_number1 = 5645432;
902 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; 895 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT;
903 const int64_t latency_id2 = 31434351; 896 const int64_t latency_id2 = 31434351;
904 const int64_t latency_sequence_number2 = 663788;
905 897
906 // Submit a frame with no unresolved dependencies. 898 // Submit a frame with no unresolved dependencies.
907 ui::LatencyInfo info; 899 ui::LatencyInfo info;
908 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); 900 info.AddLatencyNumber(latency_type1, latency_id1);
909 901
910 CompositorFrame frame = MakeCompositorFrame(); 902 CompositorFrame frame = MakeCompositorFrame();
911 frame.metadata.latency_info.push_back(info); 903 frame.metadata.latency_info.push_back(info);
912 904
913 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 905 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
914 std::move(frame)); 906 std::move(frame));
915 907
916 // Verify that the old surface has an active frame only. 908 // Verify that the old surface has an active frame only.
917 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); 909 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1);
918 ASSERT_NE(nullptr, old_surface); 910 ASSERT_NE(nullptr, old_surface);
919 EXPECT_TRUE(old_surface->HasActiveFrame()); 911 EXPECT_TRUE(old_surface->HasActiveFrame());
920 EXPECT_FALSE(old_surface->HasPendingFrame()); 912 EXPECT_FALSE(old_surface->HasPendingFrame());
921 913
922 // Submit a frame with a new local surface id and with unresolved 914 // Submit a frame with a new local surface id and with unresolved
923 // dependencies. 915 // dependencies.
924 ui::LatencyInfo info2; 916 ui::LatencyInfo info2;
925 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); 917 info2.AddLatencyNumber(latency_type2, latency_id2);
926 918
927 CompositorFrame frame2 = MakeCompositorFrame({child_id}, empty_surface_ids(), 919 CompositorFrame frame2 = MakeCompositorFrame({child_id}, empty_surface_ids(),
928 TransferableResourceArray()); 920 TransferableResourceArray());
929 frame2.metadata.latency_info.push_back(info2); 921 frame2.metadata.latency_info.push_back(info2);
930 922
931 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), 923 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(),
932 std::move(frame2)); 924 std::move(frame2));
933 925
934 // Verify that the new surface has a pending frame and no active frame. 926 // Verify that the new surface has a pending frame and no active frame.
935 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); 927 Surface* surface = surface_manager().GetSurfaceForId(parent_id2);
(...skipping 17 matching lines...) Expand all
953 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); 945 aggregated_latency_info.AddNewLatencyFrom(info_list[1]);
954 946
955 // Two components are the original ones, and the third one is 947 // Two components are the original ones, and the third one is
956 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame 948 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame
957 // submit. 949 // submit.
958 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size()); 950 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size());
959 951
960 ui::LatencyInfo::LatencyComponent comp1; 952 ui::LatencyInfo::LatencyComponent comp1;
961 EXPECT_TRUE( 953 EXPECT_TRUE(
962 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); 954 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1));
963 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number);
964 EXPECT_TRUE( 955 EXPECT_TRUE(
965 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); 956 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr));
966 EXPECT_TRUE(aggregated_latency_info.FindLatency( 957 EXPECT_TRUE(aggregated_latency_info.FindLatency(
967 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); 958 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr));
968 } 959 }
969 960
970 // Checks that resources and ack are sent together if possible. 961 // Checks that resources and ack are sent together if possible.
971 TEST_F(SurfaceSynchronizationTest, ReturnResourcesWithAck) { 962 TEST_F(SurfaceSynchronizationTest, ReturnResourcesWithAck) {
972 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 963 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
973 TransferableResource resource; 964 TransferableResource resource;
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 DidReceiveCompositorFrameAck(Eq(returned_resources2))); 1333 DidReceiveCompositorFrameAck(Eq(returned_resources2)));
1343 child_support1().SubmitCompositorFrame( 1334 child_support1().SubmitCompositorFrame(
1344 child_id1.local_surface_id(), 1335 child_id1.local_surface_id(),
1345 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), 1336 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(),
1346 {resource2})); 1337 {resource2}));
1347 testing::Mock::VerifyAndClearExpectations(&support_client_); 1338 testing::Mock::VerifyAndClearExpectations(&support_client_);
1348 } 1339 }
1349 1340
1350 } // namespace test 1341 } // namespace test
1351 } // namespace cc 1342 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698