#include <memory>
#include "base/metrics/metrics_hashes.h"
#include "base/metrics/statistics_recorder.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/segmentation_platform/segmentation_platform_service_factory.h"
#include "chrome/browser/segmentation_platform/ukm_data_manager_test_utils.h"
#include "chrome/browser/segmentation_platform/ukm_database_client.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "chrome/test/base/platform_browser_test.h"
#include "components/optimization_guide/core/model_info.h"
#include "components/optimization_guide/core/test_model_info_builder.h"
#include "components/optimization_guide/proto/models.pb.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_observer.h"
#include "components/prefs/pref_service.h"
#include "components/segmentation_platform/embedder/default_model/database_api_clients.h"
#include "components/segmentation_platform/embedder/default_model/optimization_target_segmentation_dummy.h"
#include "components/segmentation_platform/internal/constants.h"
#include "components/segmentation_platform/internal/database/client_result_prefs.h"
#include "components/segmentation_platform/internal/database/ukm_database.h"
#include "components/segmentation_platform/internal/execution/mock_model_provider.h"
#include "components/segmentation_platform/internal/metadata/metadata_writer.h"
#include "components/segmentation_platform/internal/segmentation_platform_service_impl.h"
#include "components/segmentation_platform/internal/stats.h"
#include "components/segmentation_platform/internal/ukm_data_manager.h"
#include "components/segmentation_platform/public/constants.h"
#include "components/segmentation_platform/public/database_client.h"
#include "components/segmentation_platform/public/features.h"
#include "components/segmentation_platform/public/model_provider.h"
#include "components/segmentation_platform/public/proto/aggregation.pb.h"
#include "components/segmentation_platform/public/proto/model_metadata.pb.h"
#include "components/segmentation_platform/public/proto/segmentation_platform.pb.h"
#include "components/segmentation_platform/public/result.h"
#include "components/segmentation_platform/public/segmentation_platform_service.h"
#include "components/ukm/ukm_service.h"
#include "content/public/test/browser_test.h"
#include "services/metrics/public/cpp/ukm_builders.h"
namespace segmentation_platform {
RunOnceCallback;
_;
Invoke;
Return;
SaveArg;
constexpr SegmentId kSegmentId1 = …;
constexpr SegmentId kSegmentId2 = …;
constexpr SegmentId kSegmentId3 = …;
constexpr char kFeatureProcessingHistogram[] = …;
constexpr char kSqlFeatureQuery[] = …;
class SegmentationPlatformTest : public PlatformBrowserTest { … };
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_PRE_CachedClassificationModel …
#define MAYBE_CachedClassificationModel …
#else
#define MAYBE_PRE_CachedClassificationModel …
#define MAYBE_CachedClassificationModel …
#endif
IN_PROC_BROWSER_TEST_F(SegmentationPlatformTest,
MAYBE_PRE_CachedClassificationModel) { … }
IN_PROC_BROWSER_TEST_F(SegmentationPlatformTest,
MAYBE_CachedClassificationModel) { … }
IN_PROC_BROWSER_TEST_F(SegmentationPlatformTest, RunCachedModelsOnly) { … }
IN_PROC_BROWSER_TEST_F(SegmentationPlatformTest,
ReceiveModelUpdateFromOptimizationGuide) { … }
IN_PROC_BROWSER_TEST_F(SegmentationPlatformTest,
ReceiveNullModelUpdateFromOptimizationGuide) { … }
IN_PROC_BROWSER_TEST_F(SegmentationPlatformTest,
NullModelUpdateForUnknownModelShouldBeNoOp) { … }
class SegmentationPlatformUkmModelTest : public SegmentationPlatformTest { … };
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_ANDROID)
#define MAYBE_PRE_RunUkmBasedModel …
#define MAYBE_RunUkmBasedModel …
#else
#define MAYBE_PRE_RunUkmBasedModel …
#define MAYBE_RunUkmBasedModel …
#endif
IN_PROC_BROWSER_TEST_F(SegmentationPlatformUkmModelTest,
MAYBE_PRE_RunUkmBasedModel) { … }
IN_PROC_BROWSER_TEST_F(SegmentationPlatformUkmModelTest,
MAYBE_RunUkmBasedModel) { … }
IN_PROC_BROWSER_TEST_F(SegmentationPlatformUkmModelTest, DatabaseApi) { … }
IN_PROC_BROWSER_TEST_F(SegmentationPlatformUkmModelTest, SumGroupDatabaseApi) { … }
class SegmentationPlatformUkmDisabledTest : public SegmentationPlatformTest { … };
IN_PROC_BROWSER_TEST_F(SegmentationPlatformUkmDisabledTest, DatabaseApi) { … }
}