Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Unified Diff: components/offline_pages/fake_offline_page_model.h

Issue 2016313003: Adds unit tests for Offliner SavePage implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build.gn file name and lint Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« components/offline_pages/BUILD.gn ('K') | « components/offline_pages/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/fake_offline_page_model.h
diff --git a/components/offline_pages/fake_offline_page_model.h b/components/offline_pages/fake_offline_page_model.h
new file mode 100644
index 0000000000000000000000000000000000000000..df107baa871ede598e43b16fc570933ef2b66ea8
--- /dev/null
+++ b/components/offline_pages/fake_offline_page_model.h
@@ -0,0 +1,86 @@
+// Copyright 2016 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_FAKE_OFFLINE_PAGE_MODEL_H_
+#define COMPONENTS_OFFLINE_PAGES_FAKE_OFFLINE_PAGE_MODEL_H_
+
+#include <set>
+#include <string>
+#include <vector>
+
+#include "components/offline_pages/offline_page_model.h"
+
+namespace offline_pages {
+
+// Fake implementation of OfflinePageModel interface for testing. Besides using
+// as a fake for tests, it may also be subclassed to mock specific methods
+// needed for a set of tests.
+class FakeOfflinePageModel : public OfflinePageModel {
fgorski 2016/06/01 18:04:00 Did you consider naming it differently, e.g. TestO
Pete Williamson 2016/06/01 19:47:47 I agree that StubOfflinePageModel is good. I don'
dougarnett 2016/06/01 20:28:28 Done
+ public:
+ FakeOfflinePageModel() {}
+ ~FakeOfflinePageModel() override {}
+
+ void AddObserver(Observer* observer) override {}
+ void RemoveObserver(Observer* observer) override {}
+ void SavePage(const GURL& url,
+ const ClientId& client_id,
+ std::unique_ptr<OfflinePageArchiver> archiver,
+ const SavePageCallback& callback) override {}
+ void MarkPageAccessed(int64_t offline_id) override {}
+ void ClearAll(const base::Closure& callback) override {}
+ void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids,
+ const DeletePageCallback& callback) override {}
+ void DeletePagesByURLPredicate(const UrlPredicate& predicate,
+ const DeletePageCallback& callback) override {}
+ void HasPages(const std::string& name_space,
+ const HasPagesCallback& callback) override {}
+ void CheckPagesExistOffline(
+ const std::set<GURL>& urls,
+ const CheckPagesExistOfflineCallback& callback) override {}
+ void GetAllPages(const MultipleOfflinePageItemCallback& callback) override {}
+ void GetOfflineIdsForClientId(
+ const ClientId& client_id,
+ const MultipleOfflineIdCallback& callback) override {}
+ const std::vector<int64_t> MaybeGetOfflineIdsForClientId(
+ const ClientId& client_id) const override {
+ return offline_ids_;
+ }
+ void GetPageByOfflineId(
+ int64_t offline_id,
+ const SingleOfflinePageItemCallback& callback) override {}
+ const OfflinePageItem* MaybeGetPageByOfflineId(
+ int64_t offline_id) const override {
+ return nullptr;
+ }
+ void GetPageByOfflineURL(
+ const GURL& offline_url,
+ const SingleOfflinePageItemCallback& callback) override {}
+ const OfflinePageItem* MaybeGetPageByOfflineURL(
+ const GURL& offline_url) const override {
+ return nullptr;
+ }
+ void GetPagesByOnlineURL(
+ const GURL& online_url,
+ const MultipleOfflinePageItemCallback& callback) override {}
+ void GetBestPageForOnlineURL(
+ const GURL& online_url,
+ const SingleOfflinePageItemCallback callback) override {}
+ const OfflinePageItem* MaybeGetBestPageForOnlineURL(
+ const GURL& online_url) const override {
+ return nullptr;
+ }
+ void CheckForExternalFileDeletion() override {}
+ void ExpirePages(const std::vector<int64_t>& offline_ids,
+ const base::Time& expiration_time,
+ const base::Callback<void(bool)>& callback) override {}
+ ClientPolicyController* GetPolicyController() override { return nullptr; }
+ bool is_loaded() const override { return true; }
+
+ private:
+ std::vector<int64_t> offline_ids_;
+};
+
+} // namespace offline_pages
+
+#endif // COMPONENTS_OFFLINE_PAGES_FAKE_OFFLINE_PAGE_MODEL_H_
« components/offline_pages/BUILD.gn ('K') | « components/offline_pages/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698