#include "components/origin_trials/browser/leveldb_persistence_provider.h"
#include <map>
#include <memory>
#include "base/containers/span.h"
#include "base/memory/raw_ptr.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "base/time/clock.h"
#include "components/leveldb_proto/public/proto_database.h"
#include "components/leveldb_proto/public/proto_database_provider.h"
#include "components/leveldb_proto/testing/fake_db.h"
#include "components/origin_trials/common/persisted_trial_token.h"
#include "components/origin_trials/proto/db_trial_token.pb.h"
#include "components/origin_trials/proto/proto_util.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/origin_trials/scoped_test_origin_trial_policy.h"
#include "third_party/blink/public/common/origin_trials/trial_token.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace origin_trials {
namespace {
const char kExampleComOrigin[] = …;
const char kSecondaryExampleComOrigin[] = …;
const char kTrialName[] = …;
const char kTrialSignature[] = …;
const char kTrialSignatureAlternate[] = …;
const char kExampleComDomain[] = …;
const char kGoogleComDomain[] = …;
FakeDB;
class LevelDbPersistenceProviderUnitTest : public testing::Test { … };
TEST_F(LevelDbPersistenceProviderUnitTest, NormalStartupLogsHistograms) { … }
TEST_F(LevelDbPersistenceProviderUnitTest, FailedInitLogsHistograms) { … }
TEST_F(LevelDbPersistenceProviderUnitTest, FailedLoadLogsHistograms) { … }
TEST_F(LevelDbPersistenceProviderUnitTest, UpdatesAppliedInMemoryAndToDb) { … }
TEST_F(LevelDbPersistenceProviderUnitTest, TokensLoadedFromDbOnStartup) { … }
TEST_F(LevelDbPersistenceProviderUnitTest,
TokensLoadedFromDbOnStartupAreCleanedUpIfExpired) { … }
TEST_F(LevelDbPersistenceProviderUnitTest, QueriesBeforeDbLoad) { … }
TEST_F(LevelDbPersistenceProviderUnitTest,
LoadFromDbDoesNotOverwriteInMemoryData) { … }
TEST_F(LevelDbPersistenceProviderUnitTest,
WriteBeforeLoadShouldMergePartitions) { … }
TEST_F(
LevelDbPersistenceProviderUnitTest,
GetPotentialPersistentTrialTokensReturnsTokensForOriginsWithSameSiteKey) { … }
TEST_F(LevelDbPersistenceProviderUnitTest, SiteKeyIsETLDPlusOne) { … }
TEST_F(LevelDbPersistenceProviderUnitTest,
SiteKeyUsesPrivateRegistryAsEffectiveTopLevelDomain) { … }
TEST_F(LevelDbPersistenceProviderUnitTest, SiteKeyCanBeIpAddress) { … }
TEST_F(LevelDbPersistenceProviderUnitTest, SiteKeyCanBeLocalhost) { … }
TEST_F(LevelDbPersistenceProviderUnitTest, SiteKeyCanHaveNonstandardPort) { … }
TEST_F(LevelDbPersistenceProviderUnitTest,
OpaqueOriginAsSiteKeySerializesAsEmptyValue) { … }
}
}