chromium/components/viz/client/client_resource_provider_unittest.cc

// Copyright 2017 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/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/viz/client/client_resource_provider.h"

#include <algorithm>
#include <memory>
#include <utility>

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_feature_list.h"
#include "components/viz/common/features.h"
#include "components/viz/common/resources/release_callback.h"
#include "components/viz/common/resources/returned_resource.h"
#include "components/viz/test/test_context_provider.h"
#include "components/viz/test/viz_test_suite.h"
#include "gpu/command_buffer/client/client_shared_image.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

_;
Each;

namespace viz {
namespace {

// Mocks ResourceFlushCallback
class MockFlushCallback {};

class ClientResourceProviderTest : public testing::TestWithParam<bool> {};

INSTANTIATE_TEST_SUITE_P();

class MockReleaseCallback {};

TEST_P(ClientResourceProviderTest, TransferableResourceReleased) {}

TEST_P(ClientResourceProviderTest, TransferableResourceSendToParent) {}

TEST_P(ClientResourceProviderTest, TransferableResourceSendTwoToParent) {}

TEST_P(ClientResourceProviderTest, TransferableResourceSendToParentTwoTimes) {}

TEST_P(ClientResourceProviderTest,
       TransferableResourceLostOnShutdownIfExported) {}

TEST_P(ClientResourceProviderTest, TransferableResourceSendToParentManyUnsent) {}

TEST_P(ClientResourceProviderTest, TransferableResourceRemovedAfterReturn) {}

TEST_P(ClientResourceProviderTest, TransferableResourceExportedTwice) {}

TEST_P(ClientResourceProviderTest, TransferableResourceReturnedTwiceAtOnce) {}

TEST_P(ClientResourceProviderTest, TransferableResourceLostOnReturn) {}

TEST_P(ClientResourceProviderTest, TransferableResourceLostOnFirstReturn) {}

TEST_P(ClientResourceProviderTest, ReturnedSyncTokensArePassedToClient) {}

TEST_P(ClientResourceProviderTest, LostResourcesAreReturnedLost) {}

TEST_P(ClientResourceProviderTest, ShutdownLosesExportedResources) {}

TEST_P(ClientResourceProviderTest, ReleaseExportedResources) {}

TEST_P(ClientResourceProviderTest, ReleaseExportedResourcesThenRemove) {}

TEST_P(ClientResourceProviderTest, ReleaseMultipleResources) {}

TEST_P(ClientResourceProviderTest, ReleaseMultipleResourcesBeforeReturn) {}

TEST_P(ClientResourceProviderTest, ReturnDuplicateResourceBeforeRemove) {}

TEST_P(ClientResourceProviderTest, ReturnDuplicateResourceAfterRemove) {}

// Tests that resources which are locked, are released after eviction has
// occurred, once they are also returned.
TEST_P(ClientResourceProviderTest, EvictionUnlocksResources) {}

// Tests that when resources are returned in the middle of an eviction process,
// that we release any locked resources once the eviction has completed.
TEST_P(ClientResourceProviderTest,
       LockedReturnedResourcesReleasedDuringEviction) {}

// Tests that when a Client has removed a resource, which has not yet been
// returned, that we do not notify the Client of eviction.
TEST_P(ClientResourceProviderTest, RemovedEvictedResourcesDoNotNotifyClient) {}

// Tests that when we provide Main thread callbacks, that they are ran after
// the resources have returned. Also confirming that we Flush resources once
// callbacks are processed.
TEST_P(ClientResourceProviderTest, EvictionNotifiesMainAndFlushes) {}

// Tests that when we are using
// `ClientResourceProvider::ScopedBatchResourcesRelease` that callbacks are not
// immediately ran when we remove resources. Confirming that they are ran once
// the scope is exited.
TEST_P(ClientResourceProviderTest, BatchedCallbacksDoNotFireImmediately) {}

// Ensures that while batching callbacks, that `ClientResourceProvider` being
// destroyed before the `ClientResourceProvider::ScopedBatchResourcesRelease`
// ensures the callbacks are ran.
TEST_P(ClientResourceProviderTest,
       BatchedCallbacksFireUponProviderDestruction) {}

}  // namespace
}  // namespace viz