chromium/third_party/blink/renderer/platform/graphics/gpu/webgpu_swap_buffer_provider_test.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/platform/graphics/gpu/webgpu_swap_buffer_provider.h"

#include <dawn/dawn_proc.h>
#include <dawn/wire/WireClient.h>
#include <dawn/wire/WireServer.h>

#include "base/memory/raw_ptr.h"
#include "base/test/task_environment.h"
#include "gpu/command_buffer/client/webgpu_interface_stub.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h"
#include "third_party/blink/public/platform/web_graphics_context_3d_provider.h"
#include "third_party/blink/renderer/platform/graphics/gpu/drawing_buffer_test_helpers.h"
#include "third_party/blink/renderer/platform/graphics/gpu/webgpu_cpp.h"
#include "third_party/blink/renderer/platform/graphics/gpu/webgpu_native_test_support.h"

_;
Invoke;
Return;

namespace blink {

namespace {

class MockWebGPUInterface : public gpu::webgpu::WebGPUInterfaceStub {};

class FakeProviderClient : public WebGPUSwapBufferProvider::Client {};

class WebGPUSwapBufferProviderForTests : public WebGPUSwapBufferProvider {};

class WireSerializer : public dawn::wire::CommandSerializer {};

}  // anonymous namespace

class WebGPUSwapBufferProviderTest : public testing::Test {};

TEST_F(WebGPUSwapBufferProviderTest,
       VerifyDestructionCompleteAfterAllResourceReleased) {}

TEST_F(WebGPUSwapBufferProviderTest, VerifyResizingProperlyAffectsResources) {}

TEST_F(WebGPUSwapBufferProviderTest, VerifyInsertAndWaitSyncTokenCorrectly) {}

// Ensures swap buffers will be recycled.
// Creates two swap buffers, destroys them, then creates them again.
TEST_F(WebGPUSwapBufferProviderTest, ReuseSwapBuffers) {}

// Ensures swap buffers will NOT be recycled if resized.
// Creates two swap buffers of a size, destroys them, then creates them again
// with a different size.
TEST_F(WebGPUSwapBufferProviderTest, ReuseSwapBufferResize) {}

// Regression test for crbug.com/1236418 where calling
// PrepareTransferableResource twice after the context is destroyed would hit a
// DCHECK.
TEST_F(WebGPUSwapBufferProviderTest,
       PrepareTransferableResourceTwiceAfterDestroy) {}

// Test that checks mailbox is dissociated when Neuter() is called.
TEST_F(WebGPUSwapBufferProviderTest, VerifyMailboxDissociationOnNeuter) {}

// Test that checks mailbox is not dissociated twice when both
// PrepareTransferableResource() and Neuter() are called.
TEST_F(WebGPUSwapBufferProviderTest, VerifyNoDoubleMailboxDissociation) {}

TEST_F(WebGPUSwapBufferProviderTest, ReserveTextureDescriptorForReflection) {}

// Ensures that requests for zero size textures (width == 0 or height == 0) do
// not attempt to reserve a texture.
TEST_F(WebGPUSwapBufferProviderTest, VerifyZeroSizeRejects) {}

// Verifies that GetLastWebGPUMailboxTexture() returns empty information if no
// swapbuffer has been created.
TEST_F(WebGPUSwapBufferProviderTest,
       GetLastWebGPUMailboxTextureReturnsEmptyWithoutSwapBuffer) {}

// Verifies that GetLastWebGPUMailboxTexture() returns a correctly-configured
// texture if a swapbuffer has been created.
TEST_F(WebGPUSwapBufferProviderTest,
       GetLastWebGPUMailboxTextureReturnsValidTextureWithSwapBuffer) {}

// Verifies that GetNewTexture() passes client-specified internal usages to
// AssociateMailbox() and additionally adds RenderAttachment as an internal
// usage when associating the mailbox to ensure that lazy clearing is supported.
TEST_F(WebGPUSwapBufferProviderTest,
       GetNewTexturePassesClientSpecifiedInternalUsagePlusRenderAttachment) {}

// Verifies that GetLastMailboxTexture() passes client-specified internal usages
// to AssociateMailbox() and doesn't additionally add RenderAttachment (since
// it does not instruct the decoder to do lazy clearing on this texture).
TEST_F(WebGPUSwapBufferProviderTest,
       GetLastMailboxTexturePassesClientSpecifiedInternalUsage) {}

}  // namespace blink