1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/metrics/frame_info.h"
7 #include "testing/gtest/include/gtest/gtest.h"
12 using FrameFinalState = FrameInfo::FrameFinalState;
13 using MainThreadResponse = FrameInfo::MainThreadResponse;
14 using SmoothThread = FrameInfo::SmoothThread;
16 TEST(FrameInfoTest, WasMainUpdateDroppedForkedReporters) {
17 FrameInfo main, compositor;
19 main.smooth_thread = SmoothThread::kSmoothBoth;
20 compositor.smooth_thread = SmoothThread::kSmoothCompositor;
22 main.main_thread_response = MainThreadResponse::kIncluded;
23 compositor.main_thread_response = MainThreadResponse::kMissing;
25 // For a 'forked' frame: the compositor-update is dropped, and the main-thread
26 // update was presented. For this frame, both the compositor-thread and the
27 // main-thread update are considered dropped (because the compositor-thread
28 // did not update any new main-thread).
29 main.final_state = FrameFinalState::kPresentedAll;
30 compositor.final_state = FrameFinalState::kDropped;
33 test.MergeWith(compositor);
34 EXPECT_TRUE(test.WasSmoothMainUpdateDropped());
35 EXPECT_TRUE(test.WasSmoothCompositorUpdateDropped());
37 // Even if the compositor-thread update is presented, the overall main-thread
38 // update is dropped if the compositor-update is not accompanied by new
39 // main-thread update (from earlier frames).
40 compositor.final_state = FrameFinalState::kPresentedPartialOldMain;
42 test.MergeWith(compositor);
43 EXPECT_TRUE(test.WasSmoothMainUpdateDropped());
44 EXPECT_FALSE(test.WasSmoothCompositorUpdateDropped());
46 // If the compositor-thread is accompanied by new main-thread update (even if
47 // from earlier frames), then the main-thread is update is considered not
49 compositor.final_state = FrameFinalState::kPresentedPartialNewMain;
51 test.MergeWith(compositor);
52 EXPECT_FALSE(test.WasSmoothMainUpdateDropped());
53 EXPECT_FALSE(test.WasSmoothCompositorUpdateDropped());