// Copyright 2023 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/promos/promos_utils.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_feature_list.h" #include "build/branding_buildflags.h" #include "chrome/browser/promos/promos_pref_names.h" #include "chrome/browser/promos/promos_types.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/scoped_testing_local_state.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "components/prefs/testing_pref_service.h" #include "components/segmentation_platform/embedder/default_model/device_switcher_model.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h" namespace promos_utils { // TODO(crbug.com/339262105): Clean up the old password promo methods after the // generic promo launch. class IOSPromoOnDesktopTest : public ::testing::Test { … }; // Tests RecordIOSDesktopPromoUserInteractionHistogram for all promo types. // Tests that RecordIOSDesktopPromoUserInteractionHistogram records the proper // histogram for first impression and action dismissed for the password promo // type. TEST_F( IOSPromoOnDesktopTest, RecordIOSDesktopPromoUserInteractionHistogramTestFirstImpressionDismissedForPasswordPromo) { … } // Tests that RecordIOSDesktopPromoUserInteractionHistogram records the proper // histogram for first impression and no thanks clicked action for the password // promo type. TEST_F( IOSPromoOnDesktopTest, RecordIOSDesktopPromoUserInteractionHistogramTestFirstImpressionNoThanksClickedForPasswordPromo) { … } // Tests that RecordIOSDesktopPromoUserInteractionHistogram records the proper // histogram for second impression and action dismissed for the password promo // type. TEST_F( IOSPromoOnDesktopTest, RecordIOSDesktopPromoUserInteractionHistogramTestSecondImpressionDismissedForPasswordPromo) { … } // Tests that RecordIOSDesktopPromoUserInteractionHistogram records the proper // histogram for second impression and no thanks clicked action for the password // promo type. TEST_F( IOSPromoOnDesktopTest, RecordIOSDesktopPromoUserInteractionHistogramTestSecondImpressionNoThanksClickedForPasswordPromo) { … } // Tests that RecordIOSDesktopPromoUserInteractionHistogram records the proper // histogram for third impression and action dismissed for the password promo // type. TEST_F( IOSPromoOnDesktopTest, RecordIOSDesktopPromoUserInteractionHistogramTestThirdImpressionDismissedForPasswordPromo) { … } // Tests that RecordIOSDesktopPromoUserInteractionHistogram records the proper // histogram for third impression and no thanks clicked action for the // password promo type. TEST_F( IOSPromoOnDesktopTest, RecordIOSDesktopPromoUserInteractionHistogramTestThirdImpressionNoThanksClickedForPasswordPromo) { … } // Tests that RecordIOSDesktopPromoUserInteractionHistogram records the proper // histogram for first impression and action dismissed for the address promo // type. TEST_F( IOSPromoOnDesktopTest, RecordIOSDesktopPromoUserInteractionHistogramTestFirstImpressionDismissedForAddressPromo) { … } // Tests that RecordIOSDesktopPromoUserInteractionHistogram records the proper // histogram for first impression and no thanks clicked action for the address // promo type. TEST_F( IOSPromoOnDesktopTest, RecordIOSDesktopPromoUserInteractionHistogramTestFirstImpressionNoThanksClickedForAddressPromo) { … } // Tests that RecordIOSDesktopPromoUserInteractionHistogram records the proper // histogram for second impression and action dismissed for the address promo // type. TEST_F( IOSPromoOnDesktopTest, RecordIOSDesktopPromoUserInteractionHistogramTestSecondImpressionDismissedForAddressPromo) { … } // Tests that RecordIOSDesktopPromoUserInteractionHistogram records the proper // histogram for second impression and no thanks clicked action for the // address promo type. TEST_F( IOSPromoOnDesktopTest, RecordIOSDesktopPromoUserInteractionHistogramTestSecondImpressionNoThanksClickedForAddressPromo) { … } // Tests that RecordIOSDesktopPromoUserInteractionHistogram records the proper // histogram for third impression and action dismissed for the address promo // type. TEST_F( IOSPromoOnDesktopTest, RecordIOSDesktopPromoUserInteractionHistogramTestThirdImpressionDismissedForAddressPromo) { … } // Tests that RecordIOSDesktopPromoUserInteractionHistogram records the proper // histogram for third impression and no thanks clicked action for the // address promo type. TEST_F( IOSPromoOnDesktopTest, RecordIOSDesktopPromoUserInteractionHistogramTestThirdImpressionNoThanksClickedForAddressPromo) { … } // Tests ShouldShowIOSDesktopPromo with all promo types. // Tests that ShouldShowIOSDesktopPromo returns true when no promo has yet been // shown for the given password promo type. TEST_F(IOSPromoOnDesktopTest, ShouldShowIOSDesktopPromoTestTrueForPasswordPromo) { … } // Tests that ShouldShowIOSDesktopPromo returns false when the promotions are // disabled. TEST_F(IOSPromoOnDesktopTest, ShouldShowIOSDesktopPromoTestFalsePromotionsDisabled) { … } // Tests that ShouldShowIOSDesktopPromo returns false when the user has already // seen 3 promos for the given password promo type. TEST_F(IOSPromoOnDesktopTest, ShouldShowIOSDesktopPromoTestFalseTooManyImpressionsForPasswordPromo) { … } // Tests that ShouldShowIOSDesktopPromo returns false when the last seen // impression is too recent for the given password promo type. TEST_F( IOSPromoOnDesktopTest, ShouldShowIOSDesktopPromoTestFalseLastImpressionTooRecentForPasswordPromo) { … } // Tests that ShouldShowIOSDesktopPromo returns false when the user has // opted-out from the given password promo type. TEST_F(IOSPromoOnDesktopTest, ShouldShowIOSDesktopPromoTestFalseUserOptedOutForPasswordPromo) { … } // Tests that ShouldShowIOSDesktopPromo returns true when no promo has yet been // shown for the given address promo type. TEST_F(IOSPromoOnDesktopTest, ShouldShowIOSDesktopPromoTestTrueForAddressPromo) { … } // Tests that ShouldShowIOSDesktopPromo returns false when the user has already // seen 3 promos for the given address promo type. TEST_F(IOSPromoOnDesktopTest, ShouldShowIOSDesktopPromoTestFalseTooManyImpressionsForAddressPromo) { … } // Tests that ShouldShowIOSDesktopPromo returns false when the last seen // impression is too recent for the given address promo type. TEST_F( IOSPromoOnDesktopTest, ShouldShowIOSDesktopPromoTestFalseLastImpressionTooRecentForAddressPromo) { … } // Tests that ShouldShowIOSDesktopPromo returns false when the user has // opted-out from the given address promo type. TEST_F(IOSPromoOnDesktopTest, ShouldShowIOSDesktopPromoTestFalseUserOptedOutForAddressPromo) { … } // Tests that IOSDesktopPromoShown sets the correct prefs and records the // correct histogram for the first impression for the given password promo // type. TEST_F(IOSPromoOnDesktopTest, IOSDesktopPromoShownTestFirstImpressionForPasswordPromo) { … } // Tests that IOSDesktopPromoShown sets the correct prefs and records the // correct histogram for the second impression for the given password promo // type. TEST_F(IOSPromoOnDesktopTest, IOSDesktopPromoShownTestSecondImpressionForPasswordPromo) { … } // Tests that IOSDesktopPromoShown sets the correct prefs and records the // correct histogram for the third impression for the given password promo // type. TEST_F(IOSPromoOnDesktopTest, IOSDesktopPromoShownTestThirdImpressionForPasswordPromo) { … } // Tests that IOSDesktopPromoShown sets the correct prefs and records the // correct histogram for the first impression for the given address promo // type. TEST_F(IOSPromoOnDesktopTest, IOSDesktopPromoShownTestFirstImpressionForAddressPromo) { … } // Tests that IOSDesktopPromoShown sets the correct prefs and records the // correct histogram for the second impression for the given address promo // type. TEST_F(IOSPromoOnDesktopTest, IOSDesktopPromoShownTestSecondImpressionForAddressPromo) { … } // Tests that IOSDesktopPromoShown sets the correct prefs and records the // correct histogram for the third impression for the given address promo // type. TEST_F(IOSPromoOnDesktopTest, IOSDesktopPromoShownTestThirdImpressionForAddressPromo) { … } // TODO(crbug.com/339262105): Clean up the old password promo methods after the // generic promo launch. // Tests that RecordIOSPasswordPromoUserInteractionHistogram records the proper // histogram for first impression and action dismissed. TEST_F( IOSPromoOnDesktopTest, RecordIOSPasswordPromoUserInteractionHistogramTestFirstImpressionDismissed) { … } // TODO(crbug.com/339262105): Clean up the old password promo methods after the // generic promo launch. // Tests that RecordIOSPasswordPromoUserInteractionHistogram records the proper // histogram for first impression and action explicitly closed. TEST_F( IOSPromoOnDesktopTest, RecordIOSPasswordPromoUserInteractionHistogramTestFirstImpressionClosed) { … } // TODO(crbug.com/339262105): Clean up the old password promo methods after the // generic promo launch. // Tests that RecordIOSPasswordPromoUserInteractionHistogram records the proper // histogram for second impression and action dismissed. TEST_F( IOSPromoOnDesktopTest, RecordIOSPasswordPromoUserInteractionHistogramTestSecondImpressionDismissed) { … } // TODO(crbug.com/339262105): Clean up the old password promo methods after the // generic promo launch. // Tests that RecordIOSPasswordPromoUserInteractionHistogram records the proper // histogram for second impression and action explicitly closed. TEST_F( IOSPromoOnDesktopTest, RecordIOSPasswordPromoUserInteractionHistogramTestSecondImpressionClosed) { … } // TODO(crbug.com/339262105): Clean up the old password promo methods after the // generic promo launch. // Tests that ShouldShowIOSPasswordPromo returns true when no promo has yet been // shown. TEST_F(IOSPromoOnDesktopTest, ShouldShowIOSPasswordPromoTestTrue) { … } // TODO(crbug.com/339262105): Clean up the old password promo methods after the // generic promo launch. // Tests that ShouldShowIOSPasswordPromo returns false when the user has already // seen 2 promos. TEST_F(IOSPromoOnDesktopTest, ShouldShowIOSPasswordPromoTestFalseTooManyImpressions) { … } // TODO(crbug.com/339262105): Clean up the old password promo methods after the // generic promo launch. // Tests that ShouldShowIOSPasswordPromo returns false when the last seen // impression is too recent. TEST_F(IOSPromoOnDesktopTest, ShouldShowIOSPasswordPromoTestFalseLastImpressionTooRecent) { … } // TODO(crbug.com/339262105): Clean up the old password promo methods after the // generic promo launch. // Tests that ShouldShowIOSPasswordPromo returns false when the user has // opted-out from the promo. TEST_F(IOSPromoOnDesktopTest, ShouldShowIOSPasswordPromoTestFalseUserOptedOut) { … } // Tests that UserNotClassifiedAsMobileDeviceSwitcher returns true when the // result is successful and the mobile labels are not present in the // classification labels. TEST_F(IOSPromoOnDesktopTest, UserNotClassifiedAsMobileDeviceSwitcherTestTrue) { … } // Tests that UserNotClassifiedAsMobileDeviceSwitcher returns false when the // result has an error. TEST_F(IOSPromoOnDesktopTest, UserNotClassifiedAsMobileDeviceSwitcherTestFalseError) { … } // Tests that UserNotClassifiedAsMobileDeviceSwitcher returns false when a // mobile label is present in the classification results. TEST_F(IOSPromoOnDesktopTest, UserNotClassifiedAsMobileDeviceSwitcherTestFalseMobileLabelPresent) { … } // Tests that RegisterProfilePrefs registers the prefs to their default values // correctly. TEST_F(IOSPromoOnDesktopTest, RegisterProfilePrefsTest) { … } // TODO(crbug.com/339262105): Clean up the old password promo methods after the // generic promo launch. // Tests that iOSPasswordPromoShown sets the correct prefs and records the // correct histogram for the first impression. TEST_F(IOSPromoOnDesktopTest, iOSPasswordPromoShownTestFirstImpression) { … } // TODO(crbug.com/339262105): Clean up the old password promo methods after the // generic promo launch. // Tests that iOSPasswordPromoShown sets the correct prefs and records the // correct histogram for the second impression. TEST_F(IOSPromoOnDesktopTest, iOSPasswordPromoShownTestSecondImpression) { … } } // namespace promos_utils