chromium/content/browser/compute_pressure/pressure_service_for_frame_unittest.cc

// Copyright 2021 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/compute_pressure/pressure_service_for_frame.h"

#include <vector>

#include "base/barrier_closure.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ref.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "base/time/time.h"
#include "base/unguessable_token.h"
#include "content/browser/compute_pressure/pressure_client_impl.h"
#include "content/browser/compute_pressure/web_contents_pressure_manager_proxy.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/public/test/navigation_simulator.h"
#include "content/test/test_render_frame_host.h"
#include "content/test/test_render_view_host.h"
#include "content/test/test_web_contents.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "services/device/public/cpp/test/scoped_pressure_manager_overrider.h"
#include "services/device/public/mojom/pressure_manager.mojom.h"
#include "services/device/public/mojom/pressure_update.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/permissions_policy/permissions_policy.h"
#include "third_party/blink/public/common/permissions_policy/permissions_policy_declaration.h"
#include "third_party/blink/public/mojom/compute_pressure/web_pressure_manager.mojom.h"
#include "url/gurl.h"

namespace content {

PressureManagerAddClientError;
PressureSource;
PressureState;
PressureUpdate;

namespace {

// Test double for PressureClient that records all updates.
class FakePressureClient : public device::mojom::PressureClient {};

}  // namespace

class PressureServiceForFrameTest : public RenderViewHostImplTestHarness {};

TEST_F(PressureServiceForFrameTest, AddClient) {}

TEST_F(PressureServiceForFrameTest, WebContentPressureManagerProxyTest) {}

TEST_F(PressureServiceForFrameTest, AddClientNotSupported) {}

TEST_F(PressureServiceForFrameTest, AddClientTwice) {}

TEST_F(PressureServiceForFrameTest, DisconnectFromBlink) {}

TEST_F(PressureServiceForFrameTest, InsecureOrigin) {}

TEST_F(PressureServiceForFrameTest, PermissionsPolicyBlock) {}

// Allows callers to run a custom callback before running
// FakePressureManager::AddClient().
class InterceptingFakePressureManager : public device::FakePressureManager {};

// Test for https://crbug.com/1355662: destroying PressureServiceForFrameTest
// between calling PressureServiceForFrame::AddClient() and its
// |manager_remote_| invoking the callback it receives does not crash.
TEST_F(PressureServiceForFrameTest, DestructionOrderWithOngoingCallback) {}

class PressureServiceForFrameFencedFrameTest
    : public PressureServiceForFrameTest {};

TEST_F(PressureServiceForFrameFencedFrameTest, AccessFromFencedFrame) {}

}  // namespace content