#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/session_proto_db/session_proto_db.h"
#include <map>
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/thread_pool.h"
#include "components/leveldb_proto/testing/fake_db.h"
#include "components/session_proto_db/session_proto_db_test_proto.pb.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
KeyValuePair;
namespace {
persisted_state_db::PersistedStateContentProto BuildProto(
const char* protoKey,
const std::vector<uint8_t> byteArray) { … }
session_proto_db::SessionProtoDBTestProto BuildTestProto(const char* key,
const int32_t value) { … }
const char kMockKeyA[] = …;
const char kMockKeyPrefixA[] = …;
const std::vector<uint8_t> kMockValueArrayA = {0xfa, 0x5b, 0x4c, 0x12};
const persisted_state_db::PersistedStateContentProto kMockValueA =
BuildProto(kMockKeyA, kMockValueArrayA);
const std::vector<
SessionProtoDB<persisted_state_db::PersistedStateContentProto>::KeyAndValue>
kExpectedA = {{kMockKeyA, kMockValueA}};
const char kMockKeyB[] = …;
const std::vector<uint8_t> kMockValueArrayB = {0x3c, 0x9f, 0x5e, 0x69};
const persisted_state_db::PersistedStateContentProto kMockValueB =
BuildProto(kMockKeyB, kMockValueArrayB);
const std::vector<
SessionProtoDB<persisted_state_db::PersistedStateContentProto>::KeyAndValue>
kExpectedB = {{kMockKeyB, kMockValueB}};
const std::vector<
SessionProtoDB<persisted_state_db::PersistedStateContentProto>::KeyAndValue>
kExpectedAB = {{kMockKeyA, kMockValueA}, {kMockKeyB, kMockValueB}};
const std::vector<
SessionProtoDB<persisted_state_db::PersistedStateContentProto>::KeyAndValue>
kEmptyExpected = {};
const session_proto_db::SessionProtoDBTestProto kTestProto =
BuildTestProto(kMockKeyA, 42);
const std::vector<
SessionProtoDB<session_proto_db::SessionProtoDBTestProto>::KeyAndValue>
kTestProtoExpected = {{kMockKeyA, kTestProto}};
const char kSPTDTab1Key[] = …;
const persisted_state_db::PersistedStateContentProto kSPTDTab1Value =
BuildProto(kSPTDTab1Key, {0x5b, 0x2c});
const char kSPTDTab2Key[] = …;
const persisted_state_db::PersistedStateContentProto kSPTDTab2Value =
BuildProto(kSPTDTab2Key, {0xfe, 0xab});
const char kSPTDTab3Key[] = …;
const persisted_state_db::PersistedStateContentProto kSPTDTab3Value =
BuildProto(kSPTDTab3Key, {0x0a, 0x1b});
const char kMPTDTab1Key[] = …;
const persisted_state_db::PersistedStateContentProto kMPTDTab1Value =
BuildProto(kMPTDTab1Key, {0xaa, 0x3b});
const char kMatchingDataIdForMaintenance[] = …;
const char kNonMatchingDataIdForMaintenance[] = …;
}
class SessionProtoDBTest : public testing::Test { … };
TEST_F(SessionProtoDBTest, TestArbitraryProto) { … }
TEST_F(SessionProtoDBTest, TestInit) { … }
TEST_F(SessionProtoDBTest, TestKeyInsertionSucceeded) { … }
TEST_F(SessionProtoDBTest, TestKeyInsertionFailed) { … }
TEST_F(SessionProtoDBTest, TestKeyInsertionPrefix) { … }
TEST_F(SessionProtoDBTest, TestLoadOneEntry) { … }
TEST_F(SessionProtoDBTest, TestLoadAllEntries) { … }
TEST_F(SessionProtoDBTest, TestDeleteWithPrefix) { … }
TEST_F(SessionProtoDBTest, TestDeleteOneEntry) { … }
TEST_F(SessionProtoDBTest, TestDeferredOperations) { … }
TEST_F(SessionProtoDBTest, TestInitializationFailure) { … }
TEST_F(SessionProtoDBTest, TestUpdateEntries) { … }
TEST_F(SessionProtoDBTest, TestMaintenanceKeepSomeKeys) { … }
TEST_F(SessionProtoDBTest, TestMaintenanceKeepNoKeys) { … }
TEST_F(SessionProtoDBTest, TestMaintenanceNonMatchingDataId) { … }