#include "chrome/browser/ui/user_education/low_usage_help_controller.h"
#include "base/callback_list.h"
#include "base/functional/bind.h"
#include "base/test/bind.h"
#include "base/time/time.h"
#include "build/branding_buildflags.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/user_education/browser_feature_promo_storage_service.h"
#include "chrome/browser/user_education/user_education_service.h"
#include "chrome/browser/user_education/user_education_service_factory.h"
#include "chrome/test/user_education/interactive_feature_promo_test.h"
#include "components/feature_engagement/test/mock_tracker.h"
#include "components/user_education/common/feature_promo_controller.h"
#include "components/user_education/common/feature_promo_data.h"
#include "components/user_education/common/feature_promo_session_manager.h"
#include "components/user_education/common/feature_promo_storage_service.h"
#include "components/user_education/views/help_bubble_view.h"
#include "content/public/test/browser_test.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/views/interaction/element_tracker_views.h"
class LowUsageHelpControllerBrowsertest : public InteractiveFeaturePromoTest { … };
DEFINE_CLASS_CUSTOM_ELEMENT_EVENT_TYPE(LowUsageHelpControllerBrowsertest,
kStartupSessionEvent);
IN_PROC_BROWSER_TEST_F(LowUsageHelpControllerBrowsertest,
NoPromoOnFreshProfile) { … }
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
IN_PROC_BROWSER_TEST_F(LowUsageHelpControllerBrowsertest, PromoOnNewSession) {
RunTestSequence(
Do([this]() {
GetUserEducationService()
.recent_session_observer()
->NotifyLowUsageSession();
}),
VerifyPromoShown());
}
IN_PROC_BROWSER_TEST_F(LowUsageHelpControllerBrowsertest, PRE_PromoAtStartup) {
auto& storage_service = static_cast<BrowserFeaturePromoStorageService&>(
GetUserEducationService().feature_promo_storage_service());
const auto now = base::Time::Now();
RecentSessionData recent_session_data;
recent_session_data.enabled_time = now - base::Days(120);
recent_session_data.recent_session_start_times = {now - base::Days(19)};
user_education::FeaturePromoSessionData session_data;
session_data.start_time = now - base::Days(1);
session_data.most_recent_active_time = now - base::Hours(23);
RunTestSequence(
WaitForStartupSession(),
Do([&storage_service, session_data, recent_session_data]() {
storage_service.SaveSessionData(session_data);
storage_service.SaveRecentSessionData(recent_session_data);
}));
}
IN_PROC_BROWSER_TEST_F(LowUsageHelpControllerBrowsertest, PromoAtStartup) {
RunTestSequence(
WaitForStartupSession(), VerifyPromoShown());
}
#endif