// 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. #ifndef CONTENT_TEST_MOCK_COMMIT_DEFERRING_CONDITION_H_ #define CONTENT_TEST_MOCK_COMMIT_DEFERRING_CONDITION_H_ #include "base/functional/callback.h" #include "content/browser/renderer_host/commit_deferring_condition_runner.h" #include "content/public/browser/commit_deferring_condition.h" #include "content/public/browser/web_contents_observer.h" #include "url/gurl.h" namespace content { class MockCommitDeferringCondition; // Since a CommitDeferringCondition is owned by the delegate, test code must // transfer ownership of the condition to the delegate. This makes it // cumbersome to interact and inspect with the condition from test code. This // wrapper creates and holds a weak pointer to the condition as well as some // extra book keeping to make testing it more convenient. Since // CommitDeferringConditions can be registered and run at different phases of a // navigation, adding a condition at the right time can be subtle. Use // MockCommitDeferringConditionInstaller rather than trying to manually add a // condition to a NavigationRequest. class MockCommitDeferringConditionWrapper { … }; // This class will create and insert a MockCommitDeferringCondition into the // next starting navigation. By default, the mock condition will be installed // to run after real conditions. The installer can only be used for a single // navigation. class MockCommitDeferringConditionInstaller { … }; } // namespace content #endif // CONTENT_TEST_MOCK_COMMIT_DEFERRING_CONDITION_H_