chromium/components/viz/common/frame_sinks/begin_frame_source_unittest.cc

// Copyright 2011 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/viz/common/frame_sinks/begin_frame_source.h"

#include <stdint.h>

#include <memory>
#include <utility>

#include "base/memory/raw_ptr.h"
#include "base/test/test_mock_time_task_runner.h"
#include "components/viz/test/begin_frame_args_test.h"
#include "components/viz/test/begin_frame_source_test.h"
#include "components/viz/test/fake_delay_based_time_source.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

NiceMock;
_;

namespace viz {
namespace {

// Returns a fake TimeTicks based on the given microsecond offset.
base::TimeTicks TicksFromMicroseconds(int64_t micros) {}

// BeginFrameSource testing ----------------------------------------------------
TEST(BeginFrameSourceTest, SourceIdsAreUnique) {}

class TestTaskRunner : public base::TestMockTimeTaskRunner {};

// BackToBackBeginFrameSource testing
// ------------------------------------------
class BackToBackBeginFrameSourceTest : public ::testing::Test {};

const int64_t BackToBackBeginFrameSourceTest::kDeadline =;

const int64_t BackToBackBeginFrameSourceTest::kInterval =;

TEST_F(BackToBackBeginFrameSourceTest, AddObserverSendsBeginFrame) {}

TEST_F(BackToBackBeginFrameSourceTest,
       RemoveObserverThenDidFinishFrameProducesNoFrame) {}

TEST_F(BackToBackBeginFrameSourceTest,
       DidFinishFrameThenRemoveObserverProducesNoFrame) {}

TEST_F(BackToBackBeginFrameSourceTest,
       TogglingObserverThenDidFinishFrameProducesCorrectFrame) {}

TEST_F(BackToBackBeginFrameSourceTest,
       DidFinishFrameThenTogglingObserverProducesCorrectFrame) {}

TEST_F(BackToBackBeginFrameSourceTest, DidFinishFrameNoObserver) {}

TEST_F(BackToBackBeginFrameSourceTest, DidFinishFrameMultipleCallsIdempotent) {}

TEST_F(BackToBackBeginFrameSourceTest, DelayInPostedTaskProducesCorrectFrame) {}

TEST_F(BackToBackBeginFrameSourceTest, MultipleObserversSynchronized) {}

TEST_F(BackToBackBeginFrameSourceTest, MultipleObserversInterleaved) {}

TEST_F(BackToBackBeginFrameSourceTest, MultipleObserversAtOnce) {}

// There may not be any observers available when the OnGpuNoLongerBusy()
// function is invoked on the BackToBackBeginFrameSource. For e.g.
// consider the following sequence.
// 1. An observer is added to the source.
// 2. One BeginFrame request is generated by the timer.
// 3. The clock advances and then the DidFrameFinish() callback is invoked.
//    The timer is marked as active.
// 4. Any pending BeginFrame requests are generated and then the observer
//    unsubscribes.
// 5. If the OnGpuNoLongerBusy() notification is invoked after this step
//    before any new observer is added, a DCHECK about pending observers
//    being empty fires which crashes in debug mode and also in release
//    builds with DCHECK on.
//    With the suggested fix of checking in OnTimerTick() whether the timer
//    is active, this DCHECK should not fire.
TEST_F(BackToBackBeginFrameSourceTest, OnGpuNoLongerBusyWithNoObservers) {}

// DelayBasedBeginFrameSource testing
// ------------------------------------------
class DelayBasedBeginFrameSourceTest : public ::testing::Test {};

TEST_F(DelayBasedBeginFrameSourceTest,
       AddObserverCallsOnBeginFrameWithMissedTick) {}

TEST_F(DelayBasedBeginFrameSourceTest, AddObserverCallsCausesOnBeginFrame) {}

TEST_F(DelayBasedBeginFrameSourceTest, BasicOperation) {}

TEST_F(DelayBasedBeginFrameSourceTest, VSyncChanges) {}

TEST_F(DelayBasedBeginFrameSourceTest, VSyncChangeTimebaseBeforeLastTick) {}

TEST_F(DelayBasedBeginFrameSourceTest, VSyncChangeTimebaseAfterNextTick) {}

TEST_F(DelayBasedBeginFrameSourceTest, VSyncChangeTimebaseBetweenTicks) {}

TEST_F(DelayBasedBeginFrameSourceTest, VSyncSkipped) {}

TEST_F(DelayBasedBeginFrameSourceTest, MultipleObservers) {}

TEST_F(DelayBasedBeginFrameSourceTest, DoubleTick) {}

TEST_F(DelayBasedBeginFrameSourceTest, DoubleTickMissedFrame) {}

TEST_F(DelayBasedBeginFrameSourceTest, MultipleArgsInSameInterval) {}

TEST_F(DelayBasedBeginFrameSourceTest, ConsecutiveArgsDelayedByMultipleVsyncs) {}

TEST_F(DelayBasedBeginFrameSourceTest, WithVrrInterval) {}

// ExternalBeginFrameSource testing
// --------------------------------------------
class MockExternalBeginFrameSourceClient
    : public ExternalBeginFrameSourceClient {};

class ExternalBeginFrameSourceTest : public ::testing::Test {};

TEST_F(ExternalBeginFrameSourceTest, OnAnimateOnlyBeginFrameOptIn) {}

TEST_F(ExternalBeginFrameSourceTest, OnBeginFrameChecksBeginFrameContinuity) {}

TEST_F(ExternalBeginFrameSourceTest, GetMissedBeginFrameArgs) {}

// Tests that an observer which returns true from IsRoot is notified after
// observers which return false.
TEST_F(ExternalBeginFrameSourceTest, RootsNotifiedLast) {}

}  // namespace
}  // namespace viz