[M108 Migration][VD] Avoid pending frame counter becoming negative
[platform/framework/web/chromium-efl.git] / cc / metrics / frame_info_unittest.cc
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.
4
5 #include "cc/metrics/frame_info.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace cc {
10 namespace {
11
12 using FrameFinalState = FrameInfo::FrameFinalState;
13 using MainThreadResponse = FrameInfo::MainThreadResponse;
14 using SmoothThread = FrameInfo::SmoothThread;
15
16 TEST(FrameInfoTest, WasMainUpdateDroppedForkedReporters) {
17   FrameInfo main, compositor;
18
19   main.smooth_thread = SmoothThread::kSmoothBoth;
20   compositor.smooth_thread = SmoothThread::kSmoothCompositor;
21
22   main.main_thread_response = MainThreadResponse::kIncluded;
23   compositor.main_thread_response = MainThreadResponse::kMissing;
24
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;
31
32   auto test = main;
33   test.MergeWith(compositor);
34   EXPECT_TRUE(test.WasSmoothMainUpdateDropped());
35   EXPECT_TRUE(test.WasSmoothCompositorUpdateDropped());
36
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;
41   test = main;
42   test.MergeWith(compositor);
43   EXPECT_TRUE(test.WasSmoothMainUpdateDropped());
44   EXPECT_FALSE(test.WasSmoothCompositorUpdateDropped());
45
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
48   // dropped.
49   compositor.final_state = FrameFinalState::kPresentedPartialNewMain;
50   test = main;
51   test.MergeWith(compositor);
52   EXPECT_FALSE(test.WasSmoothMainUpdateDropped());
53   EXPECT_FALSE(test.WasSmoothCompositorUpdateDropped());
54 }
55
56 }  // namespace
57 }  // namespace cc