chromium/content/browser/renderer_host/commit_deferring_condition_runner_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/renderer_host/commit_deferring_condition_runner.h"

#include "content/public/browser/commit_deferring_condition.h"
#include "content/public/test/mock_navigation_handle.h"
#include "content/public/test/test_renderer_host.h"
#include "content/test/mock_commit_deferring_condition.h"

namespace content {

class CommitDeferringConditionRunnerTest
    : public RenderViewHostTestHarness,
      public CommitDeferringConditionRunner::Delegate {};

// CommitDeferringCondition always need a NavigationHandle. Since we don't have
// a navigation here, this class is just used to provide it with a
// MockNavigationHandle.
class MockHandleConditionWrapper : public MockNavigationHandle,
                                   public MockCommitDeferringConditionWrapper {};

// Check that the runner notifies the delegate synchronously when there are no
// conditions registered.
TEST_F(CommitDeferringConditionRunnerTest, NoRegisteredConditions) {}

// Test that when a condition defers asynchronously, the delegate isn't
// notified until the condition signals completion.
TEST_F(CommitDeferringConditionRunnerTest, BasicAsync) {}

// Test that if a condition is already satisfied when ProcessChecks is
// called, the delegate is notified synchronously.
TEST_F(CommitDeferringConditionRunnerTest, BasicSync) {}

// Test that if a condition indicating the cancellation of the commit,
// the delegate is not notified.
TEST_F(CommitDeferringConditionRunnerTest, BasicCancelled) {}

// Test with multiple conditions, some of which are completed synchronously and
// some asynchronously. The final condition is asynchronous and should notify
// the delegate on resumption.
TEST_F(CommitDeferringConditionRunnerTest, MultipleConditionsLastAsync) {}

// Test with multiple conditions, some of which are completed synchronously and
// some asynchronously. The final condition is synchronous and should notify
// the delegate synchronously from resuming the last asynchronous condition.
TEST_F(CommitDeferringConditionRunnerTest, MultipleConditionsLastSync) {}

// Test with multiple conditions, with one indicating that the commit is
// cancelled invoked in the middle.
TEST_F(CommitDeferringConditionRunnerTest, MultipleConditionsWithCancelled) {}

}  // namespace content