#include "components/user_annotations/user_annotations_service.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "chrome/browser/optimization_guide/browser_test_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/user_annotations/user_annotations_service_factory.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/optimization_guide/proto/features/common_quality_data.pb.h"
#include "components/user_annotations/user_annotations_features.h"
#include "components/user_annotations/user_annotations_types.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/login/test/device_state_mixin.h"
#include "chrome/browser/ash/login/test/guest_session_mixin.h"
#include "chrome/test/base/mixin_based_in_process_browser_test.h"
#endif
namespace user_annotations {
class UserAnnotationsServiceDisabledBrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(UserAnnotationsServiceDisabledBrowserTest,
ServiceNotCreatedWhenFeatureDisabled) { … }
class UserAnnotationsServiceKioskModeBrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(UserAnnotationsServiceKioskModeBrowserTest,
DisabledInKioskMode) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
class UserAnnotationsServiceEphemeralProfileBrowserTest
: public MixinBasedInProcessBrowserTest {
public:
UserAnnotationsServiceEphemeralProfileBrowserTest() {
scoped_feature_list_.InitAndEnableFeature(kUserAnnotations);
}
private:
ash::GuestSessionMixin guest_session_{&mixin_host_};
base::test::ScopedFeatureList scoped_feature_list_;
};
IN_PROC_BROWSER_TEST_F(UserAnnotationsServiceEphemeralProfileBrowserTest,
EphemeralProfileDoesNotInstantiateService) {
EXPECT_EQ(nullptr,
UserAnnotationsServiceFactory::GetForProfile(browser()->profile()));
}
#endif
class UserAnnotationsServiceBrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(UserAnnotationsServiceBrowserTest, ServiceFactoryWorks) { … }
IN_PROC_BROWSER_TEST_F(UserAnnotationsServiceBrowserTest,
ServiceNotCreatedForIncognito) { … }
IN_PROC_BROWSER_TEST_F(UserAnnotationsServiceBrowserTest, FormSubmissionFlow) { … }
class UserAnnotationsServiceExplicitAllowlistBrowserTest
: public UserAnnotationsServiceBrowserTest { … };
IN_PROC_BROWSER_TEST_F(UserAnnotationsServiceExplicitAllowlistBrowserTest,
NotOnAllowlist) { … }
IN_PROC_BROWSER_TEST_F(UserAnnotationsServiceExplicitAllowlistBrowserTest,
OnAllowlist) { … }
}