// 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 <utility> #include <vector> #include "base/functional/bind.h" #include "base/memory/read_only_shared_memory_region.h" #include "base/test/task_environment.h" #include "base/time/time.h" #include "components/viz/common/surfaces/region_capture_bounds.h" #include "content/browser/devtools/devtools_video_consumer.h" #include "content/public/test/test_utils.h" #include "media/base/limits.h" #include "media/capture/mojom/video_capture_buffer.mojom.h" #include "media/capture/mojom/video_capture_types.mojom.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h" #include "testing/gmock/include/gmock/gmock.h" _; namespace content { namespace { // Capture parameters. constexpr gfx::Size kResolution = …; // Arbitrarily chosen. constexpr media::VideoPixelFormat kFormat = …; // Video buffer parameters. constexpr bool kNotPremapped = …; // A non-zero FrameSinkId to prevent validation errors when // DevToolsVideoConsumer::ChangeTarget(viz::FrameSinkId) is called // (which eventually fails in FrameSinkVideoCapturerStubDispatch::Accept). constexpr viz::FrameSinkId kInitialFrameSinkId = …; } // namespace // Mock for the FrameSinkVideoCapturer running in the VIZ process. class MockFrameSinkVideoCapturer : public viz::mojom::FrameSinkVideoCapturer { … }; // Represents the FrameSinkVideoConsumerFrameCallbacks instance in the VIZ // process. class MockFrameSinkVideoConsumerFrameCallbacks : public viz::mojom::FrameSinkVideoConsumerFrameCallbacks { … }; // Mock for the classes like TracingHandler that receive frames from // DevToolsVideoConsumer via the OnFrameCapturedCallback. class MockDevToolsVideoFrameReceiver { … }; class DevToolsVideoConsumerTest : public testing::Test { … }; // Tests that the OnFrameFromVideoConsumer callbacks is called when // OnFrameCaptured is passed a valid buffer with valid mapping. TEST_F(DevToolsVideoConsumerTest, CallbacksAreCalledWhenBufferValid) { … } // Tests that the OnFrameFromVideoConsumer callback is not called when // OnFrameCaptured is passed a buffer with less-than-expected size. TEST_F(DevToolsVideoConsumerTest, CallbackIsNotCalledWhenBufferIsTooSmall) { … } // Tests that starting capture calls |capturer_| functions, and capture can be // restarted. This test is important as it ensures that when restarting capture, // a FrameSinkVideoCapturerPtrInfo is bound to |capturer_| and it verifies that // resources used in the previous StartCapture aren't reused. TEST_F(DevToolsVideoConsumerTest, StartCaptureCallsSetFunctions) { … } // Tests that calling 'Set' functions in DevToolsVideoConsumer before // |capturer_| is initialized results in the passed values being cached. // When capture is later started (and |capturer_| initialized), these cached // values should be used and sent to the |capturer_|. TEST_F(DevToolsVideoConsumerTest, CapturerIsPassedCachedValues) { … } // Tests that DevToolsVideoConsumer::IsValidMinAndMaxFrameSize adheres to the // limits set by media::limits::kMaxDimension TEST_F(DevToolsVideoConsumerTest, IsValidMinAndMaxFrameSize) { … } } // namespace content