Commit 0b4a5fe5 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Create FakeInfobarDelegate.

This is a minimum InfoBarDelegate subclass to use for tests.

Bug: none
Change-Id: Iee4ea0d819ac436ea64b471a166c6399df3cebbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1959664
Auto-Submit: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723619}
parent 0dae0dbf
...@@ -37,10 +37,9 @@ source_set("unit_tests") { ...@@ -37,10 +37,9 @@ source_set("unit_tests") {
"//ios/chrome/browser/browser_state:test_support", "//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/infobars", "//ios/chrome/browser/infobars",
"//ios/chrome/browser/infobars:public", "//ios/chrome/browser/infobars:public",
"//ios/chrome/browser/infobars/test",
"//ios/chrome/browser/overlays", "//ios/chrome/browser/overlays",
"//ios/chrome/browser/overlays/test", "//ios/chrome/browser/overlays/test",
"//ios/chrome/browser/ui/infobars:test_support",
"//ios/chrome/browser/ui/infobars/test",
"//ios/chrome/test:test_support", "//ios/chrome/test:test_support",
"//ios/web/public/test/fakes", "//ios/web/public/test/fakes",
"//testing/gtest", "//testing/gtest",
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
#include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar.h"
#include "ios/chrome/browser/infobars/infobar_manager_impl.h" #include "ios/chrome/browser/infobars/infobar_manager_impl.h"
#include "ios/chrome/browser/infobars/test/fake_infobar_delegate.h"
#include "ios/chrome/browser/overlays/public/overlay_request.h" #include "ios/chrome/browser/overlays/public/overlay_request.h"
#include "ios/chrome/browser/overlays/public/overlay_request_queue.h" #include "ios/chrome/browser/overlays/public/overlay_request_queue.h"
#include "ios/chrome/browser/overlays/test/fake_overlay_user_data.h" #include "ios/chrome/browser/overlays/test/fake_overlay_user_data.h"
#import "ios/chrome/browser/ui/infobars/test_infobar_delegate.h"
#import "ios/web/public/test/fakes/test_navigation_manager.h" #import "ios/web/public/test/fakes/test_navigation_manager.h"
#import "ios/web/public/test/fakes/test_web_state.h" #import "ios/web/public/test/fakes/test_web_state.h"
#include "testing/platform_test.h" #include "testing/platform_test.h"
...@@ -31,10 +31,8 @@ class InfobarOverlayRequestCancelHandlerTest : public PlatformTest { ...@@ -31,10 +31,8 @@ class InfobarOverlayRequestCancelHandlerTest : public PlatformTest {
std::make_unique<web::TestNavigationManager>()); std::make_unique<web::TestNavigationManager>());
InfoBarManagerImpl::CreateForWebState(&web_state_); InfoBarManagerImpl::CreateForWebState(&web_state_);
// Create a test InfoBar and add it to the manager. // Create a test InfoBar and add it to the manager.
std::unique_ptr<InfoBarDelegate> delegate =
std::make_unique<TestInfoBarDelegate>(nil);
std::unique_ptr<InfoBar> infobar = std::unique_ptr<InfoBar> infobar =
std::make_unique<InfoBar>(std::move(delegate)); std::make_unique<InfoBar>(std::make_unique<FakeInfobarDelegate>());
infobar_ = infobar.get(); infobar_ = infobar.get();
manager()->AddInfoBar(std::move(infobar)); manager()->AddInfoBar(std::move(infobar));
// Create a fake OverlayRequest and add it to the infobar banner queue using // Create a fake OverlayRequest and add it to the infobar banner queue using
......
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
#include "components/infobars/core/infobar_delegate.h" #include "components/infobars/core/infobar_delegate.h"
#include "ios/chrome/browser/infobars/infobar_manager_impl.h" #include "ios/chrome/browser/infobars/infobar_manager_impl.h"
#import "ios/chrome/browser/infobars/overlays/infobar_banner_overlay_request_factory.h" #import "ios/chrome/browser/infobars/overlays/infobar_banner_overlay_request_factory.h"
#include "ios/chrome/browser/infobars/test/fake_infobar_delegate.h"
#include "ios/chrome/browser/overlays/public/overlay_request.h" #include "ios/chrome/browser/overlays/public/overlay_request.h"
#import "ios/chrome/browser/overlays/public/overlay_request_queue.h" #import "ios/chrome/browser/overlays/public/overlay_request_queue.h"
#include "ios/chrome/browser/overlays/test/fake_overlay_user_data.h" #include "ios/chrome/browser/overlays/test/fake_overlay_user_data.h"
#import "ios/chrome/browser/ui/infobars/test_infobar_delegate.h"
#import "ios/web/public/test/fakes/test_navigation_manager.h" #import "ios/web/public/test/fakes/test_navigation_manager.h"
#import "ios/web/public/test/fakes/test_web_state.h" #import "ios/web/public/test/fakes/test_web_state.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -28,9 +28,6 @@ using infobars::InfoBarDelegate; ...@@ -28,9 +28,6 @@ using infobars::InfoBarDelegate;
using infobars::InfoBarManager; using infobars::InfoBarManager;
namespace { namespace {
// Message for the fake InfoBar.
NSString* const kFakeInfoBarMessage = @"Fake Message";
// The pointer value stored in FakeOverlayRequestUserData used to configure // The pointer value stored in FakeOverlayRequestUserData used to configure
// banner OverlayRequests created for InfoBars using a fake InfoBarDelegate with // banner OverlayRequests created for InfoBars using a fake InfoBarDelegate with
// kFakeInfoBarMessage. // kFakeInfoBarMessage.
...@@ -82,10 +79,8 @@ class InfobarOverlayTabHelperTest : public PlatformTest { ...@@ -82,10 +79,8 @@ class InfobarOverlayTabHelperTest : public PlatformTest {
// Tests that adding an InfoBar to the manager creates a fake banner request. // Tests that adding an InfoBar to the manager creates a fake banner request.
TEST_F(InfobarOverlayTabHelperTest, AddInfoBar) { TEST_F(InfobarOverlayTabHelperTest, AddInfoBar) {
ASSERT_FALSE(front_request()); ASSERT_FALSE(front_request());
std::unique_ptr<InfoBarDelegate> delegate =
std::make_unique<TestInfoBarDelegate>(kFakeInfoBarMessage);
std::unique_ptr<InfoBar> infobar = std::unique_ptr<InfoBar> infobar =
std::make_unique<InfoBar>(std::move(delegate)); std::make_unique<InfoBar>(std::make_unique<FakeInfobarDelegate>());
manager()->AddInfoBar(std::move(infobar)); manager()->AddInfoBar(std::move(infobar));
ASSERT_TRUE(front_request()); ASSERT_TRUE(front_request());
} }
# Copyright 2019 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.
source_set("test") {
testonly = true
sources = [
"fake_infobar_delegate.cc",
"fake_infobar_delegate.h",
]
configs += [ "//build/config/compiler:enable_arc" ]
deps = [
"//base",
"//components/infobars/core",
]
}
// Copyright 2019 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.
#include "ios/chrome/browser/infobars/test/fake_infobar_delegate.h"
FakeInfobarDelegate::FakeInfobarDelegate() = default;
FakeInfobarDelegate::~FakeInfobarDelegate() = default;
infobars::InfoBarDelegate::InfoBarIdentifier
FakeInfobarDelegate::GetIdentifier() const {
return TEST_INFOBAR;
}
bool FakeInfobarDelegate::EqualsDelegate(
infobars::InfoBarDelegate* delegate) const {
return false;
}
// Copyright 2019 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_INFOBARS_TEST_FAKE_INFOBAR_DELEGATE_H_
#define IOS_CHROME_BROWSER_INFOBARS_TEST_FAKE_INFOBAR_DELEGATE_H_
#include "components/infobars/core/infobar_delegate.h"
// Fake version of InfoBarDelegate.
class FakeInfobarDelegate : public infobars::InfoBarDelegate {
public:
FakeInfobarDelegate();
~FakeInfobarDelegate() override;
// Returns InfoBarIdentifier::TEST_INFOBAR.
InfoBarIdentifier GetIdentifier() const override;
// Returns false by default.
bool EqualsDelegate(infobars::InfoBarDelegate* delegate) const override;
};
#endif // IOS_CHROME_BROWSER_INFOBARS_TEST_FAKE_INFOBAR_DELEGATE_H_
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