chromium/components/segmentation_platform/internal/segmentation_ukm_helper_unittest.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// Round errors allowed during conversion.
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) {}

}  // namespace

class SegmentationUkmHelperTest : public testing::Test {};

// Tests that basic execution results recording works properly.
TEST_F(SegmentationUkmHelperTest, TestExecutionResultReporting) {}

// Tests that execution results recording are disabled if sampling rate is 0.
TEST_F(SegmentationUkmHelperTest,
       TestExecutionResultReportingwithZeroSampling) {}

// Tests that the training data collection recording works properly.
TEST_F(SegmentationUkmHelperTest, TestTrainingDataCollectionReporting) {}

// Tests tensor uploading for default allowed list.
TEST_F(SegmentationUkmHelperTest, TestDefaultAllowedList) {}

// Tests that tensor uploading if default allowed list is disabled.
TEST_F(SegmentationUkmHelperTest, TestDisallowDefaultAllowedList) {}

// Tests that tensor uploading is enabled through metadata.
TEST_F(SegmentationUkmHelperTest, TestUploadTensorsAllowedFromMetadata) {}

// Tests that float encoding works properly.
TEST_F(SegmentationUkmHelperTest, TestFloatEncoding) {}

// Tests that floats encoded can be properly decoded later.
TEST_F(SegmentationUkmHelperTest, FloatEncodeDeocode) {}

// Tests that there are too many input tensors to record.
TEST_F(SegmentationUkmHelperTest, TooManyInputTensors) {}

// Tests output validation for |RecordTrainingData|.
TEST_F(SegmentationUkmHelperTest, OutputsValidation) {}

TEST_F(SegmentationUkmHelperTest, AllowedToUploadData) {}

}  // namespace segmentation_platform