chromium/components/offline_pages/core/offline_page_metadata_store_unittest.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/offline_pages/core/offline_page_metadata_store.h"

#include <stdint.h>
#include <memory>
#include <set>
#include <string>
#include <utility>

#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/test_mock_time_task_runner.h"
#include "components/offline_pages/core/client_namespace_constants.h"
#include "components/offline_pages/core/model/offline_page_item_generator.h"
#include "components/offline_pages/core/offline_clock.h"
#include "components/offline_pages/core/offline_page_item.h"
#include "components/offline_pages/core/offline_page_model.h"
#include "components/offline_pages/core/offline_page_visuals.h"
#include "components/offline_pages/core/offline_store_utils.h"
#include "sql/database.h"
#include "sql/meta_table.h"
#include "sql/statement.h"
#include "sql/transaction.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace offline_pages {

namespace {
InitializationStatus;
OfflinePageSet;

#define OFFLINE_PAGES_TABLE_V1

const char kTestClientNamespace[] =;
const char kTestURL[] =;
const char kOriginalTestURL[] =;
const ClientId kTestClientId1(kTestClientNamespace, "1234");
const ClientId kTestClientId2(kTestClientNamespace, "5678");
const base::FilePath::CharType kFilePath[] =);
int64_t kFileSize =;
int64_t kOfflineId =;
const char kTestRequestOrigin[] =;
int64_t kTestSystemDownloadId =;
const char kTestDigest[] =;
const base::Time kVisualsExpiration =;
const char kTestSnippet[] =;
const char kTestAttribution[] =;

OfflinePageVisuals TestVisuals() {}

// Build a store with outdated schema to simulate the upgrading process.
void BuildTestStoreWithSchemaFromM52(const base::FilePath& file) {}

void BuildTestStoreWithSchemaFromM53(const base::FilePath& file) {}

void BuildTestStoreWithSchemaFromM54(const base::FilePath& file) {}

void BuildTestStoreWithSchemaFromM55(const base::FilePath& file) {}

void BuildTestStoreWithSchemaFromM56(const base::FilePath& file) {}

void BuildTestStoreWithSchemaFromM57(const base::FilePath& file) {}

void BuildTestStoreWithSchemaFromM61(const base::FilePath& file) {}

void InjectItemInM62Store(sql::Database* db, const OfflinePageItem& item) {}

void BuildTestStoreWithSchemaFromM62(const base::FilePath& file) {}

void BuildTestStoreWithSchemaVersion1(const base::FilePath& file) {}

void BuildTestStoreWithSchemaVersion2(const base::FilePath& file) {}

bool InsertVisualsVersion3(sql::Database* db,
                           const OfflinePageVisuals& visuals) {}

void BuildTestStoreWithSchemaVersion3(const base::FilePath& file) {}

// Create an offline page item from a SQL result.  Expects complete rows with
// all columns present.
OfflinePageItem MakeOfflinePageItem(sql::Statement* statement) {}

std::vector<OfflinePageItem> GetOfflinePagesSync(sql::Database* db) {}

class OfflinePageMetadataStoreTest : public testing::Test {};

// Loads empty store and makes sure that there are no offline pages stored in
// it.
TEST_F(OfflinePageMetadataStoreTest, LoadEmptyStore) {}

TEST_F(OfflinePageMetadataStoreTest, GetOfflinePagesFromInvalidStore) {}

// Loads a store which has an outdated schema.
// These tests would crash if it's not handling correctly when we're loading
// old version stores.
TEST_F(OfflinePageMetadataStoreTest, LoadVersion52Store) {}
TEST_F(OfflinePageMetadataStoreTest, LoadVersion53Store) {}
TEST_F(OfflinePageMetadataStoreTest, LoadVersion54Store) {}
TEST_F(OfflinePageMetadataStoreTest, LoadVersion55Store) {}
TEST_F(OfflinePageMetadataStoreTest, LoadVersion56Store) {}
TEST_F(OfflinePageMetadataStoreTest, LoadVersion57Store) {}
TEST_F(OfflinePageMetadataStoreTest, LoadVersion61Store) {}
TEST_F(OfflinePageMetadataStoreTest, LoadVersion62Store) {}

TEST_F(OfflinePageMetadataStoreTest, LoadStoreWithMetaVersion1) {}

TEST_F(OfflinePageMetadataStoreTest, LoadStoreWithMetaVersion2) {}

TEST_F(OfflinePageMetadataStoreTest, LoadStoreWithMetaVersion3) {}

// Adds metadata of an offline page into a store and then opens the store
// again to make sure that stored metadata survives store restarts.
TEST_F(OfflinePageMetadataStoreTest, AddOfflinePage) {}

TEST_F(OfflinePageMetadataStoreTest, AddSameOfflinePageTwice) {}

// Adds metadata of multiple offline pages into a store and removes some.
TEST_F(OfflinePageMetadataStoreTest, AddRemoveMultipleOfflinePages) {}

TEST_F(OfflinePageMetadataStoreTest, StoreCloses) {}

TEST_F(OfflinePageMetadataStoreTest, MultiplePendingCalls) {}

}  // namespace
}  // namespace offline_pages