// Copyright 2018 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/browser/renderer_host/frame_token_message_queue.h" #include <vector> #include "base/functional/bind.h" #include "base/time/time.h" #include "testing/gtest/include/gtest/gtest.h" namespace content { namespace { // Test verision of FrameTokenMessageQueue::Client which tracks the number of // calls to client methods, and the associated input parameters. class TestFrameTokenMessageQueueClient : public FrameTokenMessageQueue::Client { … }; void TestFrameTokenMessageQueueClient::Reset() { … } void TestFrameTokenMessageQueueClient::OnInvalidFrameToken( uint32_t frame_token) { … } // Test class which provides FrameTokenCallback() to be used as a closure when // enqueueing non-IPC callbacks. This only tracks if the callback was called. class TestNonIPCMessageEnqueuer { … }; void TestNonIPCMessageEnqueuer::FrameTokenCallback( base::TimeTicks activation_time) { … } } // namespace class FrameTokenMessageQueueTest : public testing::Test { … }; FrameTokenMessageQueueTest::FrameTokenMessageQueueTest() { … } // Tests that if we only have a non-IPC callback enqueued that it is called once // the frame token arrive. TEST_F(FrameTokenMessageQueueTest, EnqueueOnlyNonIPC) { … } // Verifies that if there are multiple non-IPC messages enqueued that they are // all called. TEST_F(FrameTokenMessageQueueTest, MultipleNonIPCMessages) { … } // Tests that if a non-IPC callback is enqueued, after its frame token as been // received, that it is immediately processed. TEST_F(FrameTokenMessageQueueTest, EnqueuedAfterFrameTokenImmediatelyRuns) { … } // Test that if non-IPC callbacks are enqueued for different frame tokens, that // we only process the messages associated with the arriving token, and keep the // others enqueued. TEST_F(FrameTokenMessageQueueTest, DifferentFrameTokensEnqueuedNonIPC) { … } // Tests that if DidProcessFrame is called with an invalid token, that it is // rejected, and that no callbacks are processed. TEST_F(FrameTokenMessageQueueTest, InvalidDidProcessFrameTokenNotProcessed) { … } // Test that if DidProcessFrame is called with an earlier frame token, that it // is rejected, and that no callbacks are processed. TEST_F(FrameTokenMessageQueueTest, EarlierTokenForDidProcessFrameRejected) { … } // Tests that if we have already enqueued a callback for a frame token, that if // a request for an earlier frame token arrives, that it is still enqueued. Then // once the large frame token arrives, both are processed. TEST_F(FrameTokenMessageQueueTest, OutOfOrderFrameTokensEnqueue) { … } } // namespace content