// 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. #ifndef CHROME_TEST_USER_EDUCATION_INTERACTIVE_FEATURE_PROMO_TEST_H_ #define CHROME_TEST_USER_EDUCATION_INTERACTIVE_FEATURE_PROMO_TEST_H_ #include "base/feature_list.h" #include "base/functional/callback_forward.h" #include "base/functional/callback_helpers.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/interaction/interactive_browser_test.h" #include "chrome/test/user_education/interactive_feature_promo_test_common.h" #include "chrome/test/user_education/interactive_feature_promo_test_internal.h" #include "components/user_education/common/feature_promo_result.h" #include "components/user_education/common/feature_promo_specification.h" // API class that provides both base browser Kombucha functionality and // additional logic for testing User Education experiences. // // Using this test class: // - Enables a select list of IPH to be shown during the test or uses a mock // `FeatureEngagementTracker` to sidestep that system entirely. // - Disables window activity checking for the browser, making tests more // stable in environments where the browser window might lose activation. // - Sets up the current session state so that the browser reports as either // idle, inside the "grace period", or outside the "grace period", affecting // whether and which kinds of IPH can be shown. // - Optionally grants control over the clock used by User Education for finer // control over session state. // // This API is relatively safe for use in `browser_tests` (in addition to // `interactive_ui_tests`) subject to the same limitations as // `InteractiveBrowserTest*`. Window activation and mouse input are not // reliable, and bringing up a dialog or menu that is dismissed on loss of focus // can cause a test to flake in `browser_tests`. // // Prefer to use InteractiveFeaturePromoTest[T] as the base class for your tests // instead of directly using this class. class InteractiveFeaturePromoTestApi : public InteractiveBrowserTestApi, public InteractiveFeaturePromoTestCommon { … }; // Template for adding `InteractiveFeaturePromoTestApi` to any existing test // class; the class must derive from `InProcessBrowserTest`. Use only if you // already have a separate class that you must derive from, otherwise prefer to // use `InteractiveFeaturePromoTest` directly. template <typename T> requires std::derived_from<T, InProcessBrowserTest> class InteractiveFeaturePromoTestT : public T, public InteractiveFeaturePromoTestApi { … }; InteractiveFeaturePromoTest; #endif // CHROME_TEST_USER_EDUCATION_INTERACTIVE_FEATURE_PROMO_TEST_H_