Commit 8e045915 authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Split FeaturePromoController into interface and implementation

This enables mocking in tests. It also is a step towards exposing the
interface in chrome/browser/ui.

Bug: 1106523
Change-Id: If909e252e982857975aacf348a90d9ef0269dee4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343321Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796939}
parent bd17f198
......@@ -3486,6 +3486,8 @@ static_library("ui") {
"views/in_product_help/feature_promo_colors.h",
"views/in_product_help/feature_promo_controller.cc",
"views/in_product_help/feature_promo_controller.h",
"views/in_product_help/feature_promo_controller_views.cc",
"views/in_product_help/feature_promo_controller_views.h",
"views/in_product_help/global_media_controls_promo_controller.cc",
"views/in_product_help/global_media_controls_promo_controller.h",
"views/in_product_help/reopen_tab_promo_controller.cc",
......
......@@ -103,7 +103,7 @@
#include "chrome/browser/ui/views/fullscreen_control/fullscreen_control_host.h"
#include "chrome/browser/ui/views/global_media_controls/media_toolbar_button_view.h"
#include "chrome/browser/ui/views/hats/hats_bubble_view.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_controller.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_controller_views.h"
#include "chrome/browser/ui/views/infobars/infobar_container_view.h"
#include "chrome/browser/ui/views/location_bar/intent_picker_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
......@@ -546,7 +546,7 @@ BrowserView::BrowserView(std::unique_ptr<Browser> browser)
std::make_unique<TabStripRegionView>(std::move(tabstrip)));
feature_promo_controller_ =
std::make_unique<FeaturePromoController>(browser_->profile());
std::make_unique<FeaturePromoControllerViews>(browser_->profile());
// Must be destroyed before the tab strip and |feature_promo_controller_|.
tab_groups_iph_controller_ = std::make_unique<TabGroupsIPHController>(
......
......@@ -60,7 +60,7 @@ class Browser;
class ContentsLayoutManager;
class DownloadShelfView;
class ExclusiveAccessBubbleViews;
class FeaturePromoController;
class FeaturePromoControllerViews;
class FullscreenControlHost;
class InfoBarContainerView;
class LocationBarView;
......@@ -294,7 +294,7 @@ class BrowserView : public BrowserWindow,
return tab_groups_iph_controller_.get();
}
FeaturePromoController* feature_promo_controller() {
FeaturePromoControllerViews* feature_promo_controller() {
return feature_promo_controller_.get();
}
......@@ -903,7 +903,7 @@ class BrowserView : public BrowserWindow,
std::unique_ptr<AccessibilityFocusHighlight> accessibility_focus_highlight_;
std::unique_ptr<TabGroupsIPHController> tab_groups_iph_controller_;
std::unique_ptr<FeaturePromoController> feature_promo_controller_;
std::unique_ptr<FeaturePromoControllerViews> feature_promo_controller_;
mutable base::WeakPtrFactory<BrowserView> weak_ptr_factory_{this};
......
......@@ -41,7 +41,7 @@
#include "chrome/browser/ui/views/in_product_help/feature_promo_bubble_params.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_bubble_view.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_colors.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_controller.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_controller_views.h"
#include "chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_button.h"
#include "chrome/browser/ui/views/toolbar/webui_tab_counter_button.h"
......@@ -343,7 +343,7 @@ class WebUITabStripContainerView::DragToOpenHandler : public ui::EventHandler {
class WebUITabStripContainerView::IPHController : public TabStripModelObserver {
public:
explicit IPHController(Browser* browser,
FeaturePromoController* promo_controller)
FeaturePromoControllerViews* promo_controller)
: browser_(browser),
promo_controller_(promo_controller),
iph_tracker_(feature_engagement::TrackerFactory::GetForBrowserContext(
......@@ -404,7 +404,7 @@ class WebUITabStripContainerView::IPHController : public TabStripModelObserver {
private:
Browser* const browser_;
FeaturePromoController* const promo_controller_;
FeaturePromoControllerViews* const promo_controller_;
feature_engagement::Tracker* const iph_tracker_;
views::ViewTracker anchor_;
};
......
......@@ -4,118 +4,6 @@
#include "chrome/browser/ui/views/in_product_help/feature_promo_controller.h"
#include <utility>
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/views/chrome_view_class_properties.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_bubble_params.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_bubble_view.h"
#include "components/feature_engagement/public/tracker.h"
FeaturePromoController::FeaturePromoController(Profile* profile)
: tracker_(
feature_engagement::TrackerFactory::GetForBrowserContext(profile)) {
DCHECK(tracker_);
}
FeaturePromoController::~FeaturePromoController() {
if (!promo_bubble_) {
DCHECK_EQ(current_iph_feature_, nullptr);
return;
}
DCHECK(current_iph_feature_);
promo_bubble_->GetWidget()->Close();
}
bool FeaturePromoController::MaybeShowPromo(const base::Feature& iph_feature,
FeaturePromoBubbleParams params) {
if (!tracker_->ShouldTriggerHelpUI(iph_feature))
return false;
// If the tracker says we should trigger, but we have a promo
// currently showing, there is a bug somewhere in here.
DCHECK(!current_iph_feature_);
params.anchor_view->SetProperty(kHasInProductHelpPromoKey, true);
anchor_view_tracker_.SetView(params.anchor_view);
current_iph_feature_ = &iph_feature;
promo_bubble_ = FeaturePromoBubbleView::Create(std::move(params));
widget_observer_.Add(promo_bubble_->GetWidget());
return true;
}
bool FeaturePromoController::BubbleIsShowing(
const base::Feature& iph_feature) const {
return promo_bubble_ && current_iph_feature_ == &iph_feature;
}
void FeaturePromoController::CloseBubble(const base::Feature& iph_feature) {
DCHECK_EQ(&iph_feature, current_iph_feature_);
DCHECK(promo_bubble_);
promo_bubble_->GetWidget()->Close();
}
void FeaturePromoController::UpdateBubbleForAnchorBoundsChange() {
if (!promo_bubble_)
return;
promo_bubble_->OnAnchorBoundsChanged();
}
FeaturePromoController::PromoHandle
FeaturePromoController::CloseBubbleAndContinuePromo(
const base::Feature& iph_feature) {
DCHECK_EQ(&iph_feature, current_iph_feature_);
DCHECK(promo_bubble_);
widget_observer_.Remove(promo_bubble_->GetWidget());
promo_bubble_->GetWidget()->Close();
promo_bubble_ = nullptr;
if (anchor_view_tracker_.view())
anchor_view_tracker_.view()->SetProperty(kHasInProductHelpPromoKey, false);
return PromoHandle(weak_ptr_factory_.GetWeakPtr());
}
void FeaturePromoController::OnWidgetClosing(views::Widget* widget) {
DCHECK(promo_bubble_);
DCHECK_EQ(widget, promo_bubble_->GetWidget());
HandleBubbleClosed();
}
void FeaturePromoController::OnWidgetDestroying(views::Widget* widget) {
DCHECK(promo_bubble_);
DCHECK_EQ(widget, promo_bubble_->GetWidget());
HandleBubbleClosed();
}
void FeaturePromoController::FinishContinuedPromo() {
DCHECK(current_iph_feature_);
DCHECK(!promo_bubble_);
tracker_->Dismissed(*current_iph_feature_);
current_iph_feature_ = nullptr;
}
void FeaturePromoController::HandleBubbleClosed() {
DCHECK(current_iph_feature_);
tracker_->Dismissed(*current_iph_feature_);
widget_observer_.Remove(promo_bubble_->GetWidget());
current_iph_feature_ = nullptr;
promo_bubble_ = nullptr;
if (anchor_view_tracker_.view())
anchor_view_tracker_.view()->SetProperty(kHasInProductHelpPromoKey, false);
}
FeaturePromoController::PromoHandle::PromoHandle(
base::WeakPtr<FeaturePromoController> controller)
: controller_(std::move(controller)) {}
......
......@@ -6,59 +6,45 @@
#define CHROME_BROWSER_UI_VIEWS_IN_PRODUCT_HELP_FEATURE_PROMO_CONTROLLER_H_
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "ui/views/view_tracker.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
class FeaturePromoBubbleView;
struct FeaturePromoBubbleParams;
class Profile;
namespace base {
struct Feature;
}
namespace feature_engagement {
class Tracker;
}
// Manages display of in-product help promos. All IPH displays in Top
// Chrome should go through here.
class FeaturePromoController : public views::WidgetObserver {
class FeaturePromoController {
public:
explicit FeaturePromoController(Profile* profile);
~FeaturePromoController() override;
FeaturePromoController() = default;
virtual ~FeaturePromoController() = default;
// Starts the promo if possible. Returns whether it started.
// |iph_feature| must be an IPH feature defined in
// components/feature_engagement/public/feature_list.cc. Note that
// this is different than the feature that the IPH is for.
bool MaybeShowPromo(const base::Feature& iph_feature,
FeaturePromoBubbleParams params);
virtual bool MaybeShowPromo(const base::Feature& iph_feature,
FeaturePromoBubbleParams params) = 0;
// Returns whether a bubble is showing for the given IPH. Note that if
// this is false, a promo might still be in progress; for example, a
// promo may have continued into a menu in which case the bubble is no
// longer showing.
bool BubbleIsShowing(const base::Feature& iph_feature) const;
virtual bool BubbleIsShowing(const base::Feature& iph_feature) const = 0;
// Close the bubble for |iph_feature| and end the promo. If no promo
// is showing for |iph_feature|, or the promo has continued past the
// bubble, calling this is an error.
void CloseBubble(const base::Feature& iph_feature);
virtual void CloseBubble(const base::Feature& iph_feature) = 0;
class PromoHandle;
// Like CloseBubble() but does not end the promo yet. The caller takes
// ownership of the promo (e.g. to show a highlight in a menu or on a
// button). The returned PromoHandle represents this ownership.
PromoHandle CloseBubbleAndContinuePromo(const base::Feature& iph_feature);
// Repositions the bubble (if showing) relative to the anchor view.
// This should be called whenever the anchor view is potentially
// moved. It is safe to call this if a bubble is not showing.
void UpdateBubbleForAnchorBoundsChange();
virtual PromoHandle CloseBubbleAndContinuePromo(
const base::Feature& iph_feature) = 0;
// When a caller wants to take ownership of the promo after a bubble
// is closed, this handle is given. It must be dropped in a timely
......@@ -77,39 +63,9 @@ class FeaturePromoController : public views::WidgetObserver {
base::WeakPtr<FeaturePromoController> controller_;
};
// views::WidgetObserver:
void OnWidgetClosing(views::Widget* widget) override;
void OnWidgetDestroying(views::Widget* widget) override;
FeaturePromoBubbleView* promo_bubble_for_testing() { return promo_bubble_; }
const FeaturePromoBubbleView* promo_bubble_for_testing() const {
return promo_bubble_;
}
private:
protected:
// Called when PromoHandle is destroyed to finish the promo.
void FinishContinuedPromo();
void HandleBubbleClosed();
// IPH backend that is notified of user events and decides whether to
// trigger IPH.
feature_engagement::Tracker* const tracker_;
// Non-null as long as a promo is showing. Corresponds to an IPH
// feature registered with |tracker_|.
const base::Feature* current_iph_feature_ = nullptr;
// The bubble currently showing, if any.
FeaturePromoBubbleView* promo_bubble_ = nullptr;
// Stores the bubble anchor view so we can set/unset a highlight on
// it.
views::ViewTracker anchor_view_tracker_;
ScopedObserver<views::Widget, views::WidgetObserver> widget_observer_{this};
base::WeakPtrFactory<FeaturePromoController> weak_ptr_factory_{this};
virtual void FinishContinuedPromo() = 0;
};
#endif // CHROME_BROWSER_UI_VIEWS_IN_PRODUCT_HELP_FEATURE_PROMO_CONTROLLER_H_
// 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.
#include "chrome/browser/ui/views/in_product_help/feature_promo_controller_views.h"
#include <utility>
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/views/chrome_view_class_properties.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_bubble_params.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_bubble_view.h"
#include "components/feature_engagement/public/tracker.h"
FeaturePromoControllerViews::FeaturePromoControllerViews(Profile* profile)
: tracker_(
feature_engagement::TrackerFactory::GetForBrowserContext(profile)) {
DCHECK(tracker_);
}
FeaturePromoControllerViews::~FeaturePromoControllerViews() {
if (!promo_bubble_) {
DCHECK_EQ(current_iph_feature_, nullptr);
return;
}
DCHECK(current_iph_feature_);
promo_bubble_->GetWidget()->Close();
}
bool FeaturePromoControllerViews::MaybeShowPromo(
const base::Feature& iph_feature,
FeaturePromoBubbleParams params) {
if (!tracker_->ShouldTriggerHelpUI(iph_feature))
return false;
// If the tracker says we should trigger, but we have a promo
// currently showing, there is a bug somewhere in here.
DCHECK(!current_iph_feature_);
params.anchor_view->SetProperty(kHasInProductHelpPromoKey, true);
anchor_view_tracker_.SetView(params.anchor_view);
current_iph_feature_ = &iph_feature;
promo_bubble_ = FeaturePromoBubbleView::Create(std::move(params));
widget_observer_.Add(promo_bubble_->GetWidget());
return true;
}
bool FeaturePromoControllerViews::BubbleIsShowing(
const base::Feature& iph_feature) const {
return promo_bubble_ && current_iph_feature_ == &iph_feature;
}
void FeaturePromoControllerViews::CloseBubble(
const base::Feature& iph_feature) {
DCHECK_EQ(&iph_feature, current_iph_feature_);
DCHECK(promo_bubble_);
promo_bubble_->GetWidget()->Close();
}
void FeaturePromoControllerViews::UpdateBubbleForAnchorBoundsChange() {
if (!promo_bubble_)
return;
promo_bubble_->OnAnchorBoundsChanged();
}
FeaturePromoController::PromoHandle
FeaturePromoControllerViews::CloseBubbleAndContinuePromo(
const base::Feature& iph_feature) {
DCHECK_EQ(&iph_feature, current_iph_feature_);
DCHECK(promo_bubble_);
widget_observer_.Remove(promo_bubble_->GetWidget());
promo_bubble_->GetWidget()->Close();
promo_bubble_ = nullptr;
if (anchor_view_tracker_.view())
anchor_view_tracker_.view()->SetProperty(kHasInProductHelpPromoKey, false);
return PromoHandle(weak_ptr_factory_.GetWeakPtr());
}
void FeaturePromoControllerViews::OnWidgetClosing(views::Widget* widget) {
DCHECK(promo_bubble_);
DCHECK_EQ(widget, promo_bubble_->GetWidget());
HandleBubbleClosed();
}
void FeaturePromoControllerViews::OnWidgetDestroying(views::Widget* widget) {
DCHECK(promo_bubble_);
DCHECK_EQ(widget, promo_bubble_->GetWidget());
HandleBubbleClosed();
}
void FeaturePromoControllerViews::FinishContinuedPromo() {
DCHECK(current_iph_feature_);
DCHECK(!promo_bubble_);
tracker_->Dismissed(*current_iph_feature_);
current_iph_feature_ = nullptr;
}
void FeaturePromoControllerViews::HandleBubbleClosed() {
DCHECK(current_iph_feature_);
tracker_->Dismissed(*current_iph_feature_);
widget_observer_.Remove(promo_bubble_->GetWidget());
current_iph_feature_ = nullptr;
promo_bubble_ = nullptr;
if (anchor_view_tracker_.view())
anchor_view_tracker_.view()->SetProperty(kHasInProductHelpPromoKey, false);
}
// 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 CHROME_BROWSER_UI_VIEWS_IN_PRODUCT_HELP_FEATURE_PROMO_CONTROLLER_VIEWS_H_
#define CHROME_BROWSER_UI_VIEWS_IN_PRODUCT_HELP_FEATURE_PROMO_CONTROLLER_VIEWS_H_
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_controller.h"
#include "ui/views/view_tracker.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
class FeaturePromoBubbleView;
struct FeaturePromoBubbleParams;
class Profile;
namespace base {
struct Feature;
}
namespace feature_engagement {
class Tracker;
}
// Views implementation of FeaturePromoController.
class FeaturePromoControllerViews : public FeaturePromoController,
public views::WidgetObserver {
public:
explicit FeaturePromoControllerViews(Profile* profile);
~FeaturePromoControllerViews() override;
// Repositions the bubble (if showing) relative to the anchor view.
// This should be called whenever the anchor view is potentially
// moved. It is safe to call this if a bubble is not showing.
void UpdateBubbleForAnchorBoundsChange();
// FeaturePromoController:
bool MaybeShowPromo(const base::Feature& iph_feature,
FeaturePromoBubbleParams params) override;
bool BubbleIsShowing(const base::Feature& iph_feature) const override;
void CloseBubble(const base::Feature& iph_feature) override;
PromoHandle CloseBubbleAndContinuePromo(
const base::Feature& iph_feature) override;
// views::WidgetObserver:
void OnWidgetClosing(views::Widget* widget) override;
void OnWidgetDestroying(views::Widget* widget) override;
FeaturePromoBubbleView* promo_bubble_for_testing() { return promo_bubble_; }
const FeaturePromoBubbleView* promo_bubble_for_testing() const {
return promo_bubble_;
}
private:
// Called when PromoHandle is destroyed to finish the promo.
void FinishContinuedPromo() override;
void HandleBubbleClosed();
// IPH backend that is notified of user events and decides whether to
// trigger IPH.
feature_engagement::Tracker* const tracker_;
// Non-null as long as a promo is showing. Corresponds to an IPH
// feature registered with |tracker_|.
const base::Feature* current_iph_feature_ = nullptr;
// The bubble currently showing, if any.
FeaturePromoBubbleView* promo_bubble_ = nullptr;
// Stores the bubble anchor view so we can set/unset a highlight on
// it.
views::ViewTracker anchor_view_tracker_;
ScopedObserver<views::Widget, views::WidgetObserver> widget_observer_{this};
base::WeakPtrFactory<FeaturePromoController> weak_ptr_factory_{this};
};
#endif // CHROME_BROWSER_UI_VIEWS_IN_PRODUCT_HELP_FEATURE_PROMO_CONTROLLER_VIEWS_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/in_product_help/feature_promo_controller.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_controller_views.h"
#include "base/bind.h"
#include "base/feature_list.h"
......@@ -34,7 +34,7 @@ base::Feature kTestIPHFeature{"TestIPHFeature",
base::FEATURE_ENABLED_BY_DEFAULT};
} // namespace
class FeaturePromoControllerTest : public TestWithBrowserView {
class FeaturePromoControllerViewsTest : public TestWithBrowserView {
public:
void SetUp() override {
TestWithBrowserView::SetUp();
......@@ -51,7 +51,7 @@ class FeaturePromoControllerTest : public TestWithBrowserView {
TestWithBrowserView::GetTestingFactories();
factories.emplace_back(
feature_engagement::TrackerFactory::GetInstance(),
base::BindRepeating(FeaturePromoControllerTest::MakeTestTracker));
base::BindRepeating(FeaturePromoControllerViewsTest::MakeTestTracker));
return factories;
}
......@@ -68,7 +68,7 @@ class FeaturePromoControllerTest : public TestWithBrowserView {
return params;
}
FeaturePromoController* controller_;
FeaturePromoControllerViews* controller_;
NiceMock<feature_engagement::test::MockTracker>* mock_tracker_;
private:
......@@ -87,7 +87,7 @@ class FeaturePromoControllerTest : public TestWithBrowserView {
}
};
TEST_F(FeaturePromoControllerTest, AsksBackendToShowPromo) {
TEST_F(FeaturePromoControllerViewsTest, AsksBackendToShowPromo) {
EXPECT_CALL(*mock_tracker_, ShouldTriggerHelpUI(Ref(kTestIPHFeature)))
.Times(1)
.WillOnce(Return(false));
......@@ -97,7 +97,7 @@ TEST_F(FeaturePromoControllerTest, AsksBackendToShowPromo) {
EXPECT_FALSE(controller_->promo_bubble_for_testing());
}
TEST_F(FeaturePromoControllerTest, ShowsBubble) {
TEST_F(FeaturePromoControllerViewsTest, ShowsBubble) {
EXPECT_CALL(*mock_tracker_, ShouldTriggerHelpUI(Ref(kTestIPHFeature)))
.Times(1)
.WillOnce(Return(true));
......@@ -107,7 +107,7 @@ TEST_F(FeaturePromoControllerTest, ShowsBubble) {
EXPECT_TRUE(controller_->promo_bubble_for_testing());
}
TEST_F(FeaturePromoControllerTest, PromoEndsWhenRequested) {
TEST_F(FeaturePromoControllerViewsTest, PromoEndsWhenRequested) {
EXPECT_CALL(*mock_tracker_, ShouldTriggerHelpUI(Ref(kTestIPHFeature)))
.Times(1)
.WillOnce(Return(true));
......@@ -132,7 +132,7 @@ TEST_F(FeaturePromoControllerTest, PromoEndsWhenRequested) {
widget_observer.Wait();
}
TEST_F(FeaturePromoControllerTest, PromoEndsOnBubbleClosure) {
TEST_F(FeaturePromoControllerViewsTest, PromoEndsOnBubbleClosure) {
EXPECT_CALL(*mock_tracker_, ShouldTriggerHelpUI(Ref(kTestIPHFeature)))
.Times(1)
.WillOnce(Return(true));
......@@ -156,7 +156,7 @@ TEST_F(FeaturePromoControllerTest, PromoEndsOnBubbleClosure) {
EXPECT_FALSE(controller_->promo_bubble_for_testing());
}
TEST_F(FeaturePromoControllerTest, ContinuedPromoDefersBackendDismissed) {
TEST_F(FeaturePromoControllerViewsTest, ContinuedPromoDefersBackendDismissed) {
EXPECT_CALL(*mock_tracker_, ShouldTriggerHelpUI(Ref(kTestIPHFeature)))
.Times(1)
.WillOnce(Return(true));
......@@ -189,7 +189,8 @@ TEST_F(FeaturePromoControllerTest, ContinuedPromoDefersBackendDismissed) {
promo_handle.reset();
}
TEST_F(FeaturePromoControllerTest, PropertySetOnAnchorViewWhileBubbleOpen) {
TEST_F(FeaturePromoControllerViewsTest,
PropertySetOnAnchorViewWhileBubbleOpen) {
EXPECT_CALL(*mock_tracker_, ShouldTriggerHelpUI(Ref(kTestIPHFeature)))
.Times(1)
.WillOnce(Return(true));
......
// 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.
#include "chrome/browser/ui/views/in_product_help/mock_feature_promo_controller.h"
MockFeaturePromoController::MockFeaturePromoController() = default;
MockFeaturePromoController::~MockFeaturePromoController() = 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.
#ifndef CHROME_BROWSER_UI_VIEWS_IN_PRODUCT_HELP_MOCK_FEATURE_PROMO_CONTROLLER_H_
#define CHROME_BROWSER_UI_VIEWS_IN_PRODUCT_HELP_MOCK_FEATURE_PROMO_CONTROLLER_H_
#include "base/feature_list.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_bubble_params.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_controller.h"
#include "testing/gmock/include/gmock/gmock.h"
class MockFeaturePromoController : public FeaturePromoController {
public:
MockFeaturePromoController();
~MockFeaturePromoController() override;
// FeaturePromoController:
MOCK_METHOD(bool,
MaybeShowPromo,
(const base::Feature&, FeaturePromoBubbleParams),
(override));
MOCK_METHOD(bool, BubbleIsShowing, (const base::Feature&), (const, override));
MOCK_METHOD(void, CloseBubble, (const base::Feature&), (override));
MOCK_METHOD(PromoHandle,
CloseBubbleAndContinuePromo,
(const base::Feature&),
(override));
MOCK_METHOD(void, FinishContinuedPromo, (), (override));
};
#endif // CHROME_BROWSER_UI_VIEWS_IN_PRODUCT_HELP_MOCK_FEATURE_PROMO_CONTROLLER_H_
......@@ -36,7 +36,7 @@ class TabGroupsIPHController : public TabStripModelObserver {
// |browser| is the browser window that this instance will track and
// will show IPH in if needed. |promo_controller| is the window's
// FeaturePromoController, used to start promos. |get_tab_view| should
// FeaturePromoControllerViews, used to start promos. |get_tab_view| should
// get an appropriate tab to anchor the bubble in |browser|.
TabGroupsIPHController(Browser* browser,
FeaturePromoController* promo_controller,
......
......@@ -10,7 +10,7 @@
#include "base/bind.h"
#include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_controller.h"
#include "chrome/browser/ui/views/in_product_help/feature_promo_controller_views.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/views/chrome_test_widget.h"
......@@ -57,7 +57,7 @@ class TabGroupsIPHControllerTest : public BrowserWithTestWindowTest {
.WillRepeatedly(Return(false));
promo_controller_ =
std::make_unique<FeaturePromoController>(browser()->profile());
std::make_unique<FeaturePromoControllerViews>(browser()->profile());
iph_controller_ = std::make_unique<TabGroupsIPHController>(
browser(), promo_controller_.get(),
......
......@@ -359,6 +359,8 @@ static_library("test_support") {
"../browser/autofill/autofill_uitest_util.h",
"../browser/ui/views/desktop_capture/desktop_media_picker_views_test_api.cc",
"../browser/ui/views/desktop_capture/desktop_media_picker_views_test_api.h",
"../browser/ui/views/in_product_help/mock_feature_promo_controller.cc",
"../browser/ui/views/in_product_help/mock_feature_promo_controller.h",
"../browser/ui/views/media_router/app_menu_test_api.h",
"../browser/ui/views/media_router/app_menu_test_api_views.cc",
"../browser/ui/views/web_apps/web_app_frame_toolbar_test_mixin.cc",
......@@ -5557,7 +5559,7 @@ test("unit_tests") {
"../browser/ui/views/global_media_controls/media_notification_list_view_unittest.cc",
"../browser/ui/views/global_media_controls/overlay_media_notification_view_unittest.cc",
"../browser/ui/views/hover_button_unittest.cc",
"../browser/ui/views/in_product_help/feature_promo_controller_unittest.cc",
"../browser/ui/views/in_product_help/feature_promo_controller_views_unittest.cc",
"../browser/ui/views/infobars/infobar_view_unittest.cc",
"../browser/ui/views/intent_picker_bubble_view_unittest.cc",
"../browser/ui/views/layout/interpolating_layout_manager_unittest.cc",
......
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