#include "components/metrics/structured/lib/key_data_file_delegate.h"
#include <memory>
#include <string>
#include <utility>
#include "base/containers/flat_set.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/strcat.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 "base/values.h"
#include "components/metrics/structured/lib/histogram_util.h"
#include "components/metrics/structured/lib/proto/key.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace metrics::structured {
namespace {
constexpr char kKey[] = …;
constexpr uint64_t kProjectOneHash = …16881314472396226433);
constexpr uint64_t kProjectTwoHash = …5876808001962504629);
constexpr uint64_t kMetricOneHash = …637929385654885975);
constexpr uint64_t kMetricTwoHash = …14083999144141567134);
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 KeyDataFileDelegateTest : public testing::Test { … };
TEST_F(KeyDataFileDelegateTest, GeneratesKeysForProjects) { … }
TEST_F(KeyDataFileDelegateTest, GeneratesDistinctKeys) { … }
TEST_F(KeyDataFileDelegateTest, ReuseExistingKeys) { … }
TEST_F(KeyDataFileDelegateTest, DifferentEventsDifferentHashes) { … }
TEST_F(KeyDataFileDelegateTest, DifferentMetricsDifferentHashes) { … }
TEST_F(KeyDataFileDelegateTest, DifferentValuesDifferentHashes) { … }
TEST_F(KeyDataFileDelegateTest, CheckUserIDs) { … }
TEST_F(KeyDataFileDelegateTest, CheckHashes) { … }
TEST_F(KeyDataFileDelegateTest, KeysRotated) { … }
TEST_F(KeyDataFileDelegateTest, KeysWithUpdatedRotations) { … }
}