1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
// Copyright 2024 The Chromium Authors
// 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/promos/ios_promo_bubble.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/promos/promos_pref_names.h"
#include "chrome/browser/promos/promos_types.h"
#include "chrome/browser/ui/actions/chrome_action_id.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/page_action/page_action_icon_type.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/toolbar_button_provider.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "components/feature_engagement/public/feature_constants.h"
#include "content/public/test/browser_test.h"
class IOSPasswordPromoBubbleTest : public DialogBrowserTest {
public:
IOSPasswordPromoBubbleTest() = default;
IOSPasswordPromoBubbleTest(const IOSPasswordPromoBubbleTest&) = delete;
IOSPasswordPromoBubbleTest& operator=(const IOSPasswordPromoBubbleTest&) =
delete;
// DialogBrowserTest
void ShowUi(const std::string& name) override {
ToolbarButtonProvider* button_provider =
BrowserView::GetBrowserViewForBrowser(browser())
->toolbar_button_provider();
// Test for iOS Promo Bubble for Desktop Passwords promo.
IOSPromoBubble::ShowPromoBubble(
button_provider->GetAnchorView(kActionShowPasswordsBubbleOrPage),
button_provider->GetPageActionIconView(
PageActionIconType::kManagePasswords),
browser()->profile(), IOSPromoType::kPassword);
}
};
class IOSAddressPromoBubbleTest : public DialogBrowserTest {
public:
IOSAddressPromoBubbleTest() = default;
IOSAddressPromoBubbleTest(const IOSAddressPromoBubbleTest&) = delete;
IOSAddressPromoBubbleTest& operator=(const IOSAddressPromoBubbleTest&) =
delete;
// DialogBrowserTest
void ShowUi(const std::string& name) override {
ToolbarButtonProvider* button_provider =
BrowserView::GetBrowserViewForBrowser(browser())
->toolbar_button_provider();
// Test for iOS Promo Bubble for Desktop Address promo.
IOSPromoBubble::ShowPromoBubble(
button_provider->GetAnchorView(kActionShowAddressesBubbleOrPage),
button_provider->GetPageActionIconView(
PageActionIconType::kAutofillAddress),
browser()->profile(), IOSPromoType::kAddress);
}
};
class IOSPaymentPromoBubbleTest : public DialogBrowserTest {
public:
IOSPaymentPromoBubbleTest() = default;
IOSPaymentPromoBubbleTest(const IOSPaymentPromoBubbleTest&) = delete;
IOSPaymentPromoBubbleTest& operator=(const IOSPaymentPromoBubbleTest&) =
delete;
// DialogBrowserTest
void ShowUi(const std::string& name) override {
ToolbarButtonProvider* button_provider =
BrowserView::GetBrowserViewForBrowser(browser())
->toolbar_button_provider();
// Test for iOS Promo Bubble for Desktop Payment promo.
IOSPromoBubble::ShowPromoBubble(
button_provider->GetAnchorView(kActionShowPaymentsBubbleOrPage),
button_provider->GetPageActionIconView(PageActionIconType::kSaveCard),
browser()->profile(), IOSPromoType::kPayment);
}
};
IN_PROC_BROWSER_TEST_F(IOSPasswordPromoBubbleTest, InvokeUi_default) {
ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(IOSAddressPromoBubbleTest, InvokeUi_default) {
if (IsPageActionMigrated(PageActionIconType::kAutofillAddress)) {
GTEST_SKIP()
<< "This test should be merged with InvokeUi_with_no_page_action after "
"page action migration (See: https://crbug.com/424188577).\n";
}
ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(IOSAddressPromoBubbleTest,
InvokeUi_with_no_page_action) {
if (!IsPageActionMigrated(PageActionIconType::kAutofillAddress)) {
GTEST_SKIP()
<< "This test should be merged with InvokeUi_default after "
"page action migration (See: https://crbug.com/424188577).\n";
}
ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(IOSPaymentPromoBubbleTest, InvokeUi_default) {
ShowAndVerifyUi();
}
|