#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
#include <stdint.h>
#include <unordered_map>
#include <utility>
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/task_environment.h"
#include "base/values.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h"
#include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h"
#include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h"
#include "chrome/browser/sync_file_system/drive_backend/metadata_database_index.h"
#include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_interface.h"
#include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h"
#include "chrome/browser/sync_file_system/sync_file_system_test_util.h"
#include "google_apis/drive/drive_api_parser.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/leveldatabase/env_chromium.h"
#include "third_party/leveldatabase/leveldb_chrome.h"
#include "third_party/leveldatabase/src/include/leveldb/db.h"
#include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
#define FPL(a) …
namespace sync_file_system {
namespace drive_backend {
namespace {
FileIDList;
const int64_t kInitialChangeID = …;
const int64_t kSyncRootTrackerID = …;
const char kSyncRootFolderID[] = …;
struct TrackedFile { … };
void ExpectEquivalentServiceMetadata(
const MetadataDatabaseIndexInterface* left,
const MetadataDatabaseIndexInterface* right) { … }
void ExpectEquivalent(const FileMetadata* left, const FileMetadata* right) { … }
void ExpectEquivalent(const FileTracker* left, const FileTracker* right) { … }
void ExpectEquivalent(int64_t left, int64_t right) { … }
template <typename Container>
void ExpectEquivalentMaps(const Container& left, const Container& right);
template <typename Key, typename Value>
void ExpectEquivalent(const std::map<Key, Value>& left,
const std::map<Key, Value>& right) { … }
template <typename Key, typename Value>
void ExpectEquivalent(const std::unordered_map<Key, Value>& left,
const std::unordered_map<Key, Value>& right) { … }
template <typename Key, typename Value>
void ExpectEquivalent(
const std::unordered_map<Key, std::unique_ptr<Value>>& left,
const std::unordered_map<Key, std::unique_ptr<Value>>& right) { … }
template <typename Container>
void ExpectEquivalentSets(const Container& left, const Container& right);
template <typename Value, typename Comparator>
void ExpectEquivalent(const std::set<Value, Comparator>& left,
const std::set<Value, Comparator>& right) { … }
template <typename Value>
void ExpectEquivalent(const std::unordered_set<Value>& left,
const std::unordered_set<Value>& right) { … }
void ExpectEquivalent(const TrackerIDSet& left,
const TrackerIDSet& right) { … }
template <typename Container>
void ExpectEquivalentMaps(const Container& left, const Container& right) { … }
template <typename Container>
void ExpectEquivalentSets(const Container& left, const Container& right) { … }
base::FilePath CreateNormalizedPath(const base::FilePath::StringType& path) { … }
}
class MetadataDatabaseTest : public testing::TestWithParam<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(MetadataDatabaseTest, InitializationTest_Empty) { … }
TEST_P(MetadataDatabaseTest, InitializationTest_SimpleTree) { … }
TEST_P(MetadataDatabaseTest, AppManagementTest) { … }
TEST_P(MetadataDatabaseTest, BuildPathTest) { … }
TEST_P(MetadataDatabaseTest, FindNearestActiveAncestorTest) { … }
TEST_P(MetadataDatabaseTest, UpdateByChangeListTest) { … }
TEST_P(MetadataDatabaseTest, PopulateFolderTest_RegularFolder) { … }
TEST_P(MetadataDatabaseTest, PopulateFolderTest_InactiveFolder) { … }
TEST_P(MetadataDatabaseTest, PopulateFolderTest_DisabledAppRoot) { … }
TEST_P(MetadataDatabaseTest, DISABLED_UpdateTrackerTest) { … }
TEST_P(MetadataDatabaseTest, PopulateInitialDataTest) { … }
TEST_P(MetadataDatabaseTest, DumpFiles) { … }
TEST_P(MetadataDatabaseTest, ClearDatabase) { … }
}
}