#include "components/offline_pages/core/background/request_queue_store.h"
#include <memory>
#include <string>
#include <utility>
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/test_mock_time_task_runner.h"
#include "components/offline_pages/core/background/request_queue.h"
#include "components/offline_pages/core/background/save_page_request.h"
#include "components/offline_pages/core/offline_clock.h"
#include "sql/database.h"
#include "sql/statement.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace offline_pages {
#define REQUEST_QUEUE_TABLE_NAME …
UpdateStatus;
namespace {
const int64_t kRequestId = …;
const int64_t kRequestId2 = …;
const int64_t kRequestId3 = …;
const ClientId kClientId("bookmark", "1234");
const ClientId kClientId2("async", "5678");
const bool kUserRequested = …;
const char kRequestOrigin[] = …;
enum class LastResult { … };
SavePageRequest GetTestRequest(const GURL& url, const GURL& original_url) { … }
void BuildTestStoreWithSchemaFromM57(const base::FilePath& file,
const GURL& url) { … }
void BuildTestStoreWithSchemaFromM58(const base::FilePath& file,
const GURL& url,
const GURL& original_url) { … }
void BuildTestStoreWithSchemaFromM61(const base::FilePath& file,
const GURL& url,
const GURL& original_url) { … }
void BuildTestStoreWithSchemaFromM72(const base::FilePath& file,
const GURL& url,
const GURL& original_url) { … }
class RequestQueueStoreTestBase : public testing::Test { … };
RequestQueueStoreTestBase::RequestQueueStoreTestBase()
: … { … }
void RequestQueueStoreTestBase::TearDown() { … }
void RequestQueueStoreTestBase::PumpLoop() { … }
void RequestQueueStoreTestBase::ClearResults() { … }
void RequestQueueStoreTestBase::InitializeStore(RequestQueueStore* store) { … }
void RequestQueueStoreTestBase::InitializeCallback(bool success) { … }
void RequestQueueStoreTestBase::GetRequestsDone(
bool result,
std::vector<std::unique_ptr<SavePageRequest>> requests) { … }
void RequestQueueStoreTestBase::AddOrUpdateDone(UpdateStatus status) { … }
void RequestQueueStoreTestBase::AddRequestDone(AddRequestResult result) { … }
void RequestQueueStoreTestBase::UpdateRequestDone(UpdateRequestsResult result) { … }
void RequestQueueStoreTestBase::ResetDone(bool result) { … }
class RequestQueueStoreTest : public RequestQueueStoreTestBase { … };
TEST_F(RequestQueueStoreTest, UpgradeFromVersion57Store) { … }
TEST_F(RequestQueueStoreTest, UpgradeFromVersion58Store) { … }
TEST_F(RequestQueueStoreTest, UpgradeFromVersion61Store) { … }
TEST_F(RequestQueueStoreTest, UpgradeFromVersion72Store) { … }
TEST_F(RequestQueueStoreTest, GetRequestsEmpty) { … }
TEST_F(RequestQueueStoreTest, GetRequestsByIds) { … }
TEST_F(RequestQueueStoreTest, AddRequest) { … }
TEST_F(RequestQueueStoreTest, AddAndGetRequestsMatch) { … }
TEST_F(RequestQueueStoreTest, UpdateRequest) { … }
TEST_F(RequestQueueStoreTest, RemoveRequests) { … }
TEST_F(RequestQueueStoreTest, ResetStore) { … }
TEST_F(RequestQueueStoreTest, SaveCloseReopenRead) { … }
}
}