blob: 830b0b4ed1745577e1f79529facf681e4015f6fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_OFFLINE_PAGES_CORE_MODEL_MODEL_TASK_TEST_BASE_H_
#define COMPONENTS_OFFLINE_PAGES_CORE_MODEL_MODEL_TASK_TEST_BASE_H_
#include <memory>
#include "base/files/scoped_temp_dir.h"
#include "base/memory/weak_ptr.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/offline_pages/core/archive_manager.h"
#include "components/offline_pages/core/client_policy_controller.h"
#include "components/offline_pages/core/model/offline_page_item_generator.h"
#include "components/offline_pages/core/offline_page_item.h"
#include "components/offline_pages/core/offline_page_metadata_store_test_util.h"
#include "components/offline_pages/core/offline_page_types.h"
#include "components/offline_pages/core/offline_store_types.h"
#include "components/offline_pages/core/task_test_base.h"
namespace offline_pages {
class ModelTaskTestBase : public TaskTestBase,
public base::SupportsWeakPtr<ModelTaskTestBase> {
public:
ModelTaskTestBase();
~ModelTaskTestBase() override;
void SetUp() override;
void TearDown() override;
const base::FilePath& TemporaryDir();
const base::FilePath& PrivateDir();
const base::FilePath& PublicDir();
// Calls generator()->CreateItemWithTempFile() and inserts the item into the
// database.
OfflinePageItem AddPage();
// Calls generator()->CreateItem() and inserts the item into the database.
OfflinePageItem AddPageWithoutFile();
// Calls generator()->CreateItemWithTempFile() but will not insert the item
// into database.
OfflinePageItem AddPageWithoutDBEntry();
OfflinePageMetadataStoreTestUtil* store_test_util() {
return &store_test_util_;
}
OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); }
OfflinePageItemGenerator* generator() { return &generator_; }
ArchiveManager* archive_manager() { return archive_manager_.get(); }
ClientPolicyController* policy_controller() { return &policy_controller_; }
private:
OfflinePageMetadataStoreTestUtil store_test_util_;
OfflinePageItemGenerator generator_;
base::ScopedTempDir temporary_dir_;
base::ScopedTempDir private_dir_;
base::ScopedTempDir public_dir_;
std::unique_ptr<ArchiveManager> archive_manager_;
ClientPolicyController policy_controller_;
};
} // namespace offline_pages
#endif // COMPONENTS_OFFLINE_PAGES_CORE_MODEL_MODEL_TASK_TEST_BASE_H_
|