#include <optional>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/user_metrics.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "base/version.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "chrome/browser/policy/policy_test_utils.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile_impl.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/hats/hats_service_desktop.h"
#include "chrome/browser/ui/hats/hats_service_factory.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/metrics_services_manager/metrics_services_manager.h"
#include "components/policy/core/common/policy_pref_names.h"
#include "components/policy/policy_constants.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/test/browser_test.h"
#include "net/dns/mock_host_resolver.h"
namespace {
base::test::FeatureRefAndParams probability_zero{ … };
base::test::FeatureRefAndParams probability_one{ … };
class ScopedSetMetricsConsent { … };
class HatsServiceBrowserTestBase : public policy::PolicyTest { … };
class HatsServiceProbabilityZero : public HatsServiceBrowserTestBase { … };
class HatsServiceProbabilityOne : public HatsServiceBrowserTestBase { … };
}
IN_PROC_BROWSER_TEST_F(HatsServiceBrowserTestBase, BubbleNotShownOnDefault) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityZero, NoShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, NoShowConsentNotGiven) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, TriggerMismatchNoShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, AlwaysShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne,
ShowWhenFeedbackSurveyPolicyEnabled) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne,
NeverShowWhenFeedbackSurveyPolicyDisabled) { … }
IN_PROC_BROWSER_TEST_F(
HatsServiceProbabilityOne,
NeverShowWhenFeedbackSurveyPolicyEnabledWithoutMetricsConsent) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, AlsoShowsSettingsSurvey) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, SameMajorVersionNoShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, DifferentMajorVersionShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne,
SurveyStartedBeforeRequiredElapsedTimeNoShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne,
SurveyStartedBeforeElapsedTimeBetweenAnySurveys) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, ProfileTooYoungToShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, ProfileOldEnoughToShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, IncognitoModeDisabledNoShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, CheckedWithinADayNoShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, CheckedAfterADayToShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, SurveyAlreadyFullNoShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, LaunchDelayedSurvey) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne,
LaunchDelayedSurveyForWebContents) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, DisallowsEmptyWebContents) { … }
IN_PROC_BROWSER_TEST_F(
HatsServiceProbabilityOne,
AllowsMultipleDelayedSurveyRequestsDifferentWebContents) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne,
DisallowsSameDelayedSurveyForWebContentsRequests) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne,
ReleasesPendingTaskAfterFulfilling) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, VisibleWebContentsShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, InvisibleWebContentsNoShow) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne,
NavigatedWebContents_RequireSameOrigin) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne,
NavigatedWebContents_NoRequireSameOrigin) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne,
NavigatedWebContents_RequireSameDocument) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, SameOriginNavigation) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, SingleHatsNextDialog) { … }
IN_PROC_BROWSER_TEST_F(HatsServiceProbabilityOne, SurveyCheckTimeRecorded) { … }