Commit 111e5642 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Create OverlayBrowserAgentBase

OverlayBrowserAgentBase is a superclass for BrowserAgents that use
callbacks installed onto OverlayResponses to make model-layer updates
for user interaction events that occur on overlay UI.

This will be used to handle the shared model layer interaction for
infobar overlays, as the same model will need to be updated for banner,
detail sheet, and modal overlays.  Previously, this was done in
InfobarCoordinator, which remained started and in memory for the
duration of the InfoBar's lifetime.  With OverlayPresenter, however,
the coordinator that handles the UI is only in memory from the first
time an OverlayRequest is presented until its final dismissal either
by user interaction or by cancellation.

Bug: 1030357
Change-Id: I6ceeb1e29523df8d96966ba2800a1562eadd2ee8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1986461
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729544}
parent 4f3ca7c4
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
source_set("overlays") { source_set("overlays") {
public = [ public = [
"public/overlay_browser_agent_base.h",
"public/overlay_callback_manager.h", "public/overlay_callback_manager.h",
"public/overlay_dismissal_callback.h", "public/overlay_dismissal_callback.h",
"public/overlay_dispatch_callback.h", "public/overlay_dispatch_callback.h",
...@@ -28,6 +29,7 @@ source_set("overlays") { ...@@ -28,6 +29,7 @@ source_set("overlays") {
sources = [ sources = [
"default_overlay_request_cancel_handler.h", "default_overlay_request_cancel_handler.h",
"default_overlay_request_cancel_handler.mm", "default_overlay_request_cancel_handler.mm",
"overlay_browser_agent_base.mm",
"overlay_callback_manager_impl.cc", "overlay_callback_manager_impl.cc",
"overlay_callback_manager_impl.h", "overlay_callback_manager_impl.h",
"overlay_dispatch_callback.cc", "overlay_dispatch_callback.cc",
...@@ -63,6 +65,7 @@ source_set("unit_tests") { ...@@ -63,6 +65,7 @@ source_set("unit_tests") {
testonly = true testonly = true
sources = [ sources = [
"default_overlay_request_cancel_handler_unittest.mm", "default_overlay_request_cancel_handler_unittest.mm",
"overlay_browser_agent_base_unittest.mm",
"overlay_callback_manager_impl_unittest.cc", "overlay_callback_manager_impl_unittest.cc",
"overlay_dispatch_callback_unittest.cc", "overlay_dispatch_callback_unittest.cc",
"overlay_presenter_impl_unittest.mm", "overlay_presenter_impl_unittest.mm",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/overlays/public/overlay_browser_agent_base.h"
#include "base/logging.h"
#import "ios/chrome/browser/main/browser.h"
#include "ios/chrome/browser/overlays/public/overlay_request.h"
#include "ios/chrome/browser/overlays/public/overlay_request_callback_installer.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#pragma mark - OverlayBrowserAgentBase
OverlayBrowserAgentBase::OverlayBrowserAgentBase(Browser* browser)
: installation_driver_(browser, this) {}
OverlayBrowserAgentBase::~OverlayBrowserAgentBase() = default;
#pragma mark - Protected
void OverlayBrowserAgentBase::AddInstaller(
std::unique_ptr<OverlayRequestCallbackInstaller> installer,
OverlayModality modality) {
DCHECK(installer);
CallbackInstallerStorage& storage = installer_storages_[modality];
storage.installers.push_back(std::move(installer));
// Reset the storage's request support to nullptr. This will cause the
// aggregate support for all callback installers added for |modality| to be
// regenerated the next time GetRequestSupport() is called.
storage.request_support = nullptr;
// Notify the installation driver if this is the first installer added for
// |modality|.
if (storage.installers.size() == 1U)
installation_driver_.StartInstallingCallbacks(modality);
}
#pragma mark Private
const OverlayRequestSupport* OverlayBrowserAgentBase::GetRequestSupport(
OverlayModality modality) {
CallbackInstallerStorage& storage = installer_storages_[modality];
if (!storage.request_support) {
const std::vector<std::unique_ptr<OverlayRequestCallbackInstaller>>&
installers = storage.installers;
std::vector<const OverlayRequestSupport*> supports(installers.size());
for (size_t index = 0; index < installers.size(); ++index) {
DCHECK(installers[index]->GetRequestSupport());
supports[index] = installers[index]->GetRequestSupport();
}
storage.request_support = std::make_unique<OverlayRequestSupport>(supports);
}
return storage.request_support.get();
}
void OverlayBrowserAgentBase::InstallOverlayRequestCallbacks(
OverlayRequest* request,
OverlayModality modality) {
for (auto& installer : installer_storages_[modality].installers) {
installer->InstallCallbacks(request);
}
}
#pragma mark - OverlayBrowserAgentBase::InstallationDriver
OverlayBrowserAgentBase::CallbackInstallationDriver::CallbackInstallationDriver(
Browser* browser,
OverlayBrowserAgentBase* browser_agent)
: browser_(browser), browser_agent_(browser_agent), scoped_observer_(this) {
DCHECK(browser_agent_);
DCHECK(browser_);
}
OverlayBrowserAgentBase::CallbackInstallationDriver::
~CallbackInstallationDriver() = default;
void OverlayBrowserAgentBase::CallbackInstallationDriver::
StartInstallingCallbacks(OverlayModality modality) {
OverlayPresenter* presenter =
OverlayPresenter::FromBrowser(browser_, modality);
if (!scoped_observer_.IsObserving(presenter))
scoped_observer_.Add(presenter);
}
const OverlayRequestSupport*
OverlayBrowserAgentBase::CallbackInstallationDriver::GetRequestSupport(
OverlayPresenter* presenter) const {
return browser_agent_->GetRequestSupport(presenter->GetModality());
}
void OverlayBrowserAgentBase::CallbackInstallationDriver::WillShowOverlay(
OverlayPresenter* presenter,
OverlayRequest* request) {
browser_agent_->InstallOverlayRequestCallbacks(request,
presenter->GetModality());
}
void OverlayBrowserAgentBase::CallbackInstallationDriver::
OverlayPresenterDestroyed(OverlayPresenter* presenter) {
scoped_observer_.Remove(presenter);
}
#pragma mark - OverlayBrowserAgentBase::CallbackInstallerStorage
OverlayBrowserAgentBase::CallbackInstallerStorage::CallbackInstallerStorage() =
default;
OverlayBrowserAgentBase::CallbackInstallerStorage::~CallbackInstallerStorage() =
default;
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/overlays/public/overlay_browser_agent_base.h"
#import "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
#import "ios/chrome/browser/main/browser_user_data.h"
#import "ios/chrome/browser/main/test_browser.h"
#include "ios/chrome/browser/overlays/public/overlay_callback_manager.h"
#include "ios/chrome/browser/overlays/public/overlay_request.h"
#include "ios/chrome/browser/overlays/public/overlay_request_callback_installer.h"
#import "ios/chrome/browser/overlays/public/overlay_request_queue.h"
#include "ios/chrome/browser/overlays/public/overlay_response.h"
#include "ios/chrome/browser/overlays/test/fake_overlay_presentation_context.h"
#include "ios/chrome/browser/overlays/test/fake_overlay_request_callback_installer.h"
#include "ios/chrome/browser/overlays/test/overlay_test_macros.h"
#import "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
#import "ios/chrome/browser/web_state_list/web_state_opener.h"
#import "ios/web/public/test/fakes/test_web_state.h"
#include "ios/web/public/test/web_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/platform_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// The modality to use in tests.
const OverlayModality kModality = OverlayModality::kWebContentArea;
// Request configs used in tests.
DEFINE_TEST_OVERLAY_REQUEST_CONFIG(SupportedConfig);
DEFINE_TEST_OVERLAY_REQUEST_CONFIG(UnsupportedConfig);
DEFINE_TEST_OVERLAY_RESPONSE_INFO(DispatchInfo);
// Fake version of OverlayBrowserAgentBase used for tests.
class FakeOverlayBrowserAgent
: public OverlayBrowserAgentBase,
public BrowserUserData<FakeOverlayBrowserAgent> {
public:
// The mock callback receiver used by the FakeOverlayRequestCallbackInstaller
// whose callback installation is driven by the OverlayBrowserAgentBase
// superclass.
MockOverlayRequestCallbackReceiver& mock_callback_receiver() {
return mock_callback_receiver_;
}
private:
friend class BrowserUserData<FakeOverlayBrowserAgent>;
BROWSER_USER_DATA_KEY_DECL();
FakeOverlayBrowserAgent(Browser* browser) : OverlayBrowserAgentBase(browser) {
// Add a fake callback installer for kModality that supports requests
// configured with SupportedConfig and dispatched responses with
// DispatchInfo.
std::unique_ptr<FakeOverlayRequestCallbackInstaller> installer =
std::make_unique<FakeOverlayRequestCallbackInstaller>(
&mock_callback_receiver_);
installer->SetRequestSupport(SupportedConfig::RequestSupport());
installer->StartInstallingDispatchCallbacksWithSupport(
DispatchInfo::ResponseSupport());
AddInstaller(std::move(installer), kModality);
}
testing::StrictMock<MockOverlayRequestCallbackReceiver>
mock_callback_receiver_;
};
BROWSER_USER_DATA_KEY_IMPL(FakeOverlayBrowserAgent)
} // namespace
// Test fixture for OverlayBrowserAgentBase.
class OverlayBrowserAgentBaseTest : public PlatformTest {
public:
OverlayBrowserAgentBaseTest() : web_state_list_(&web_state_list_delegate_) {
// Create the Browser and set up the browser agent.
TestChromeBrowserState::Builder builder;
browser_state_ = builder.Build();
browser_ =
std::make_unique<TestBrowser>(browser_state_.get(), &web_state_list_);
FakeOverlayBrowserAgent::CreateForBrowser(browser_.get());
// Set up the infobar OverlayPresenter.
OverlayPresenter::FromBrowser(browser_.get(), kModality)
->SetPresentationContext(&presentation_context_);
// Add and active a WebState over which to present overlays.
web_state_list_.InsertWebState(0, std::make_unique<web::TestWebState>(),
WebStateList::INSERT_ACTIVATE,
WebStateOpener());
web_state_ = web_state_list_.GetActiveWebState();
}
~OverlayBrowserAgentBaseTest() override {
OverlayPresenter::FromBrowser(browser_.get(), kModality)
->SetPresentationContext(nullptr);
}
// Returns the mock callback receiver for the browser agent.
MockOverlayRequestCallbackReceiver& mock_callback_receiver() {
return FakeOverlayBrowserAgent::FromBrowser(browser_.get())
->mock_callback_receiver();
}
// Returns |web_state_|'s request queue.
OverlayRequestQueue* queue() {
return OverlayRequestQueue::FromWebState(web_state_, kModality);
}
// Cancels all requests in |web_state_|'s queue.
void CancelRequests() { queue()->CancelAllRequests(); }
protected:
web::WebTaskEnvironment task_environment_;
std::unique_ptr<ios::ChromeBrowserState> browser_state_;
FakeWebStateListDelegate web_state_list_delegate_;
WebStateList web_state_list_;
web::WebState* web_state_ = nullptr;
std::unique_ptr<Browser> browser_;
FakeOverlayPresentationContext presentation_context_;
};
// Tests that callbacks are successfully set up for supported requests.
TEST_F(OverlayBrowserAgentBaseTest, SupportedRequestCallbackSetup) {
// Add a supported request to the queue so that its presentation is simulated
// in the fake presentation context, triggering the BrowserAgent to install
// its callbacks on the request.
std::unique_ptr<OverlayRequest> added_request =
OverlayRequest::CreateWithConfig<SupportedConfig>();
OverlayRequest* request = added_request.get();
queue()->AddRequest(std::move(added_request));
// Dispatch a response through this presented request, expecting the dispatch
// callback to be executed on the mock receiver.
std::unique_ptr<OverlayResponse> response =
OverlayResponse::CreateWithInfo<DispatchInfo>();
EXPECT_CALL(mock_callback_receiver(),
DispatchCallback(request, DispatchInfo::ResponseSupport(),
response.get()));
request->GetCallbackManager()->DispatchResponse(std::move(response));
// Cancel the request, expecting the completion callback to be executed on the
// mock receiver.
EXPECT_CALL(mock_callback_receiver(), CompletionCallback(request, nullptr));
CancelRequests();
}
// Tests that callbacks are not executed for supported requests.
TEST_F(OverlayBrowserAgentBaseTest, UnsupportedRequestCallbackSetup) {
// Add an unsupported request to the queue so that its presentation is
// simulated in the fake presentation context. Since the added request is
// unsupported, no callbacks should have been installed.
std::unique_ptr<OverlayRequest> added_request =
OverlayRequest::CreateWithConfig<UnsupportedConfig>();
OverlayRequest* request = added_request.get();
queue()->AddRequest(std::move(added_request));
// Dispatch a response through this presented request without expecting the
// dispatch callback to be executed on the mock receiver.
std::unique_ptr<OverlayResponse> response =
OverlayResponse::CreateWithInfo<DispatchInfo>();
request->GetCallbackManager()->DispatchResponse(std::move(response));
// Cancel the request without expecting the completion callback to be executed
// on the mock receiver.
CancelRequests();
}
...@@ -48,6 +48,7 @@ class OverlayPresenterImpl : public BrowserObserver, ...@@ -48,6 +48,7 @@ class OverlayPresenterImpl : public BrowserObserver,
}; };
// OverlayPresenter: // OverlayPresenter:
OverlayModality GetModality() const override;
void SetPresentationContext( void SetPresentationContext(
OverlayPresentationContext* presentation_context) override; OverlayPresentationContext* presentation_context) override;
void AddObserver(OverlayPresenterObserver* observer) override; void AddObserver(OverlayPresenterObserver* observer) override;
......
...@@ -77,6 +77,10 @@ OverlayPresenterImpl::~OverlayPresenterImpl() { ...@@ -77,6 +77,10 @@ OverlayPresenterImpl::~OverlayPresenterImpl() {
#pragma mark OverlayPresenter #pragma mark OverlayPresenter
OverlayModality OverlayPresenterImpl::GetModality() const {
return modality_;
}
void OverlayPresenterImpl::SetPresentationContext( void OverlayPresenterImpl::SetPresentationContext(
OverlayPresentationContext* presentation_context) { OverlayPresentationContext* presentation_context) {
// When the presentation context is reset, the presenter will begin showing // When the presentation context is reset, the presenter will begin showing
......
...@@ -18,20 +18,6 @@ DEFINE_TEST_OVERLAY_REQUEST_CONFIG(SupportedConfig); ...@@ -18,20 +18,6 @@ DEFINE_TEST_OVERLAY_REQUEST_CONFIG(SupportedConfig);
DEFINE_TEST_OVERLAY_REQUEST_CONFIG(UnsupportedConfig); DEFINE_TEST_OVERLAY_REQUEST_CONFIG(UnsupportedConfig);
DEFINE_TEST_OVERLAY_RESPONSE_INFO(DispatchInfo); DEFINE_TEST_OVERLAY_RESPONSE_INFO(DispatchInfo);
DEFINE_TEST_OVERLAY_RESPONSE_INFO(CompletionInfo); DEFINE_TEST_OVERLAY_RESPONSE_INFO(CompletionInfo);
// Mock callback receiver.
class MockCallbackReceiver : public FakeOverlayRequestCallbackReceiver {
public:
MockCallbackReceiver() = default;
~MockCallbackReceiver() = default;
MOCK_METHOD2(CompletionCallback,
void(OverlayRequest* request, OverlayResponse* response));
MOCK_METHOD3(DispatchCallback,
void(OverlayRequest* request,
const OverlayResponseSupport* response_support,
OverlayResponse* response));
};
} // namespace } // namespace
// Test fixture for OverlayRequestCallbackInstaller. // Test fixture for OverlayRequestCallbackInstaller.
...@@ -60,7 +46,7 @@ class OverlayRequestCallbackInstallerTest : public PlatformTest { ...@@ -60,7 +46,7 @@ class OverlayRequestCallbackInstallerTest : public PlatformTest {
} }
protected: protected:
testing::StrictMock<MockCallbackReceiver> mock_receiver_; testing::StrictMock<MockOverlayRequestCallbackReceiver> mock_receiver_;
FakeOverlayRequestCallbackInstaller installer_; FakeOverlayRequestCallbackInstaller installer_;
}; };
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_OVERLAYS_PUBLIC_OVERLAY_BROWSER_AGENT_BASE_H_
#define IOS_CHROME_BROWSER_OVERLAYS_PUBLIC_OVERLAY_BROWSER_AGENT_BASE_H_
#include <memory>
#include <vector>
#include "base/scoped_observer.h"
#include "ios/chrome/browser/overlays/public/overlay_presenter.h"
#include "ios/chrome/browser/overlays/public/overlay_presenter_observer.h"
#include "ios/chrome/browser/overlays/public/overlay_request_callback_installer.h"
#include "ios/chrome/browser/overlays/public/overlay_request_support.h"
// Browser agent class, intended to be subclassed, that installs callbacks for
// OverlayRequests in order to make model-layer updates for interaction with
// overlay UI. Used to combine model-layer logic between OverlayRequests with
// shared functionality but different OverlayRequestConfigs (e.g. an action
// sheet and alert overlay that both update the same model object). Subclasses
// should also specialize the BrowserUserData template so each subclass has its
// own unique key.
class OverlayBrowserAgentBase {
public:
virtual ~OverlayBrowserAgentBase();
protected:
// Constructor to be called by subclasses.
explicit OverlayBrowserAgentBase(Browser* browser);
// Called by subclasses in order to install callbacks using |installer| on
// supported OverlayRequests at |modality|. |installer| must be non-null.
void AddInstaller(std::unique_ptr<OverlayRequestCallbackInstaller> installer,
OverlayModality modality);
// Returns the aggregate request support for all callback installers added
// for |modality|.
const OverlayRequestSupport* GetRequestSupport(OverlayModality modality);
private:
// Installs the callbacks for |request| using the installers added via
// AddInstaller() for |modality|.
void InstallOverlayRequestCallbacks(OverlayRequest* request,
OverlayModality modality);
// Helper object that drives the installation of callbacks for each
// OverlayRequest upon the first presentation of its overlay UI.
class CallbackInstallationDriver : public OverlayPresenterObserver {
public:
// Constructor for an installation driver for OverlayRequests presented via
// |browser|'s OverlayPresenters.
CallbackInstallationDriver(Browser* browser,
OverlayBrowserAgentBase* browser_agent);
~CallbackInstallationDriver() override;
// Starts driving the BrowserAgent's installation of callbacks for requests
// whose UI is presented from |modality|'s presenter.
void StartInstallingCallbacks(OverlayModality modality);
private:
// OverlayPresenterObserver:
const OverlayRequestSupport* GetRequestSupport(
OverlayPresenter* presenter) const override;
void WillShowOverlay(OverlayPresenter* presenter,
OverlayRequest* request) override;
void OverlayPresenterDestroyed(OverlayPresenter* presenter) override;
Browser* browser_ = nullptr;
OverlayBrowserAgentBase* browser_agent_ = nullptr;
ScopedObserver<OverlayPresenter, OverlayPresenterObserver> scoped_observer_;
};
// Storage struct used to store OverlayRequestCallbackInstallers and their
// aggregated support for each OverlayModality.
struct CallbackInstallerStorage {
CallbackInstallerStorage();
~CallbackInstallerStorage();
// The callback installers
std::vector<std::unique_ptr<OverlayRequestCallbackInstaller>> installers;
// The aggregate support for all added installers.
std::unique_ptr<OverlayRequestSupport> request_support;
};
// Map containing the list of OverlayRequestCallbackInstallers for each
// OverlayModality.
std::map<OverlayModality, CallbackInstallerStorage> installer_storages_;
// The callback installation driver.
CallbackInstallationDriver installation_driver_;
};
#endif // IOS_CHROME_BROWSER_OVERLAYS_PUBLIC_OVERLAY_BROWSER_AGENT_BASE_H_
...@@ -24,6 +24,9 @@ class OverlayPresenter { ...@@ -24,6 +24,9 @@ class OverlayPresenter {
static OverlayPresenter* FromBrowser(Browser* browser, static OverlayPresenter* FromBrowser(Browser* browser,
OverlayModality modality); OverlayModality modality);
// Returns the presenter's modality.
virtual OverlayModality GetModality() const = 0;
// Sets the presentation context in which to show overlay UI. Upon being set, // Sets the presentation context in which to show overlay UI. Upon being set,
// the presenter will attempt to begin presenting overlay UI for the active // the presenter will attempt to begin presenting overlay UI for the active
// WebState in its Browser. // WebState in its Browser.
......
...@@ -24,12 +24,12 @@ class OverlayRequestCallbackInstaller { ...@@ -24,12 +24,12 @@ class OverlayRequestCallbackInstaller {
// supported request if called more than once. |request| must be non-null. // supported request if called more than once. |request| must be non-null.
void InstallCallbacks(OverlayRequest* request); void InstallCallbacks(OverlayRequest* request);
protected:
// Returns the request support for this installer. InstallCallbacksInternal() // Returns the request support for this installer. InstallCallbacksInternal()
// will only be called for supported requests. By default, all requests are // will only be called for supported requests. By default, all requests are
// supported. // supported.
virtual const OverlayRequestSupport* GetRequestSupport() const; virtual const OverlayRequestSupport* GetRequestSupport() const;
protected:
// Called from InstallCallbacks() if |request| is supported by // Called from InstallCallbacks() if |request| is supported by
// GetRequestSupport(). Subclasses should override to supply callbacks for a // GetRequestSupport(). Subclasses should override to supply callbacks for a
// specific kind of request. Does nothing by default. // specific kind of request. Does nothing by default.
......
...@@ -19,6 +19,7 @@ source_set("test") { ...@@ -19,6 +19,7 @@ source_set("test") {
deps = [ deps = [
"//base", "//base",
"//ios/chrome/browser/overlays", "//ios/chrome/browser/overlays",
"//testing/gmock",
"//testing/gtest", "//testing/gtest",
] ]
} }
...@@ -12,6 +12,16 @@ ...@@ -12,6 +12,16 @@
#include "ios/chrome/browser/overlays/public/overlay_request_support.h" #include "ios/chrome/browser/overlays/public/overlay_request_support.h"
#include "ios/chrome/browser/overlays/public/overlay_response_support.h" #include "ios/chrome/browser/overlays/public/overlay_response_support.h"
#pragma mark - MockOverlayRequestCallbackReceiver
MockOverlayRequestCallbackReceiver::MockOverlayRequestCallbackReceiver() =
default;
MockOverlayRequestCallbackReceiver::~MockOverlayRequestCallbackReceiver() =
default;
#pragma mark - FakeOverlayRequestCallbackInstaller
FakeOverlayRequestCallbackInstaller::FakeOverlayRequestCallbackInstaller( FakeOverlayRequestCallbackInstaller::FakeOverlayRequestCallbackInstaller(
FakeOverlayRequestCallbackReceiver* receiver) FakeOverlayRequestCallbackReceiver* receiver)
: receiver_(receiver), request_support_(OverlayRequestSupport::All()) { : receiver_(receiver), request_support_(OverlayRequestSupport::All()) {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <set> #include <set>
#include "ios/chrome/browser/overlays/public/overlay_request_callback_installer.h" #include "ios/chrome/browser/overlays/public/overlay_request_callback_installer.h"
#include "testing/gmock/include/gmock/gmock.h"
class OverlayResponseSupport; class OverlayResponseSupport;
...@@ -26,6 +27,21 @@ class FakeOverlayRequestCallbackReceiver { ...@@ -26,6 +27,21 @@ class FakeOverlayRequestCallbackReceiver {
OverlayResponse* response) = 0; OverlayResponse* response) = 0;
}; };
// Mock version of the fake callback receiver receiver.
class MockOverlayRequestCallbackReceiver
: public FakeOverlayRequestCallbackReceiver {
public:
MockOverlayRequestCallbackReceiver();
~MockOverlayRequestCallbackReceiver();
MOCK_METHOD2(CompletionCallback,
void(OverlayRequest* request, OverlayResponse* response));
MOCK_METHOD3(DispatchCallback,
void(OverlayRequest* request,
const OverlayResponseSupport* response_support,
OverlayResponse* response));
};
// OverlayRequestCallbackInstaller subclass used for testing. Sets up callbacks // OverlayRequestCallbackInstaller subclass used for testing. Sets up callbacks
// that execute on a mocked receiver that is exposed for testing. // that execute on a mocked receiver that is exposed for testing.
class FakeOverlayRequestCallbackInstaller class FakeOverlayRequestCallbackInstaller
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment