#include "components/metrics/structured/key_data_prefs_delegate.h"
#include <memory>
#include <string_view>
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "components/metrics/structured/histogram_util.h"
#include "components/metrics/structured/lib/histogram_util.h"
#include "components/metrics/structured/lib/key_data.h"
#include "components/metrics/structured/lib/key_util.h"
#include "components/metrics/structured/lib/proto/key.pb.h"
#include "components/metrics/structured/structured_metrics_validator.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/prefs/testing_pref_service.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace metrics::structured {
namespace {
constexpr char kTestPrefName[] = …;
constexpr char kKey[] = …;
constexpr uint64_t kProjectOneHash = …;
constexpr uint64_t kProjectTwoHash = …;
constexpr uint64_t kMetricOneHash = …;
constexpr uint64_t kMetricTwoHash = …;
constexpr char kUserId[] = …;
constexpr char kValueOne[] = …;
constexpr char kValueTwo[] = …;
constexpr char kValueOneHash[] = …;
constexpr char kValueTwoHash[] = …;
constexpr base::TimeDelta kKeyRotationPeriod = …;
std::string HashToHex(const uint64_t hash) { … }
}
class KeyDataPrefsDelegateTest : public testing::Test { … };
TEST_F(KeyDataPrefsDelegateTest, GeneratesKeysForProjects) { … }
TEST_F(KeyDataPrefsDelegateTest, ReuseExistingKeys) { … }
TEST_F(KeyDataPrefsDelegateTest, DifferentEventsDifferentHashes) { … }
TEST_F(KeyDataPrefsDelegateTest, DifferentMetricsDifferentHashes) { … }
TEST_F(KeyDataPrefsDelegateTest, DifferentValuesDifferentHashes) { … }
TEST_F(KeyDataPrefsDelegateTest, CheckUserIDs) { … }
TEST_F(KeyDataPrefsDelegateTest, CheckHashes) { … }
TEST_F(KeyDataPrefsDelegateTest, KeysRotated) { … }
TEST_F(KeyDataPrefsDelegateTest, KeysWithUpdatedRotations) { … }
TEST_F(KeyDataPrefsDelegateTest, Purge) { … }
}