#include "components/segmentation_platform/internal/segmentation_ukm_helper.h"
#include <cmath>
#include <optional>
#include <string_view>
#include "base/bit_cast.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "components/prefs/testing_pref_service.h"
#include "components/segmentation_platform/internal/constants.h"
#include "components/segmentation_platform/internal/selection/segmentation_result_prefs.h"
#include "components/segmentation_platform/public/config.h"
#include "components/segmentation_platform/public/features.h"
#include "components/segmentation_platform/public/local_state_helper.h"
#include "components/segmentation_platform/public/proto/prediction_result.pb.h"
#include "components/segmentation_platform/public/proto/segmentation_platform.pb.h"
#include "components/segmentation_platform/public/segmentation_platform_service.h"
#include "components/ukm/test_ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "testing/gtest/include/gtest/gtest.h"
Segmentation_ModelExecution;
namespace segmentation_platform {
namespace {
static const double kRoundingError = …;
float Int64ToFloat(int64_t encoded) { … }
void CompareEncodeDecodeDifference(float tensor) { … }
std::optional<proto::PredictionResult> GetPredictionResult(
std::optional<base::Time> prediction_time = std::nullopt) { … }
proto::SegmentInfo CreateTestSegmentInfo(proto::SegmentId segment_id,
bool upload_tensors) { … }
}
class SegmentationUkmHelperTest : public testing::Test { … };
TEST_F(SegmentationUkmHelperTest, TestExecutionResultReporting) { … }
TEST_F(SegmentationUkmHelperTest,
TestExecutionResultReportingwithZeroSampling) { … }
TEST_F(SegmentationUkmHelperTest, TestTrainingDataCollectionReporting) { … }
TEST_F(SegmentationUkmHelperTest, TestDefaultAllowedList) { … }
TEST_F(SegmentationUkmHelperTest, TestDisallowDefaultAllowedList) { … }
TEST_F(SegmentationUkmHelperTest, TestUploadTensorsAllowedFromMetadata) { … }
TEST_F(SegmentationUkmHelperTest, TestFloatEncoding) { … }
TEST_F(SegmentationUkmHelperTest, FloatEncodeDeocode) { … }
TEST_F(SegmentationUkmHelperTest, TooManyInputTensors) { … }
TEST_F(SegmentationUkmHelperTest, OutputsValidation) { … }
TEST_F(SegmentationUkmHelperTest, AllowedToUploadData) { … }
}