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

Unified Diff: components/download/internal/test/test_store.cc

Issue 2870753003: Add a Model to the download component. (Closed)
Patch Set: Renamed test base class Created 3 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
« no previous file with comments | « components/download/internal/test/test_store.h ('k') | components/download/public/clients.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/download/internal/test/test_store.cc
diff --git a/components/download/internal/test/test_store.cc b/components/download/internal/test/test_store.cc
new file mode 100644
index 0000000000000000000000000000000000000000..01faec77b989ba5ae43a2329756d599ec48826a2
--- /dev/null
+++ b/components/download/internal/test/test_store.cc
@@ -0,0 +1,73 @@
+// Copyright 2017 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.
+
+#include "components/download/internal/test/test_store.h"
+
+#include "components/download/internal/entry.h"
+
+namespace download {
+namespace test {
+
+TestStore::TestStore()
+ : ready_(false), init_called_(false), destroy_called_(false) {}
+
+TestStore::~TestStore() {}
+
+bool TestStore::IsInitialized() {
+ return ready_;
+}
+
+void TestStore::Initialize(InitCallback callback) {
+ init_called_ = true;
+ init_callback_ = std::move(callback);
+}
+
+void TestStore::Destroy(StoreCallback callback) {
+ destroy_called_ = true;
+ destroy_callback_ = std::move(callback);
+}
+
+void TestStore::Update(const Entry& entry, StoreCallback callback) {
+ updated_entries_.push_back(entry);
+ update_callback_ = std::move(callback);
+}
+
+void TestStore::Remove(const std::string& guid, StoreCallback callback) {
+ removed_entries_.push_back(guid);
+ remove_callback_ = std::move(callback);
+}
+
+// Callback trigger methods.
+void TestStore::TriggerInit(bool success,
+ std::unique_ptr<std::vector<Entry>> entries) {
+ ready_ = success;
+ DCHECK(init_callback_);
+ std::move(init_callback_).Run(success, std::move(entries));
+}
+
+void TestStore::TriggerDestroy(bool success) {
+ DCHECK(destroy_callback_);
+ std::move(destroy_callback_).Run(success);
+}
+
+void TestStore::TriggerUpdate(bool success) {
+ DCHECK(update_callback_);
+ std::move(update_callback_).Run(success);
+}
+
+void TestStore::TriggerRemove(bool success) {
+ DCHECK(remove_callback_);
+ std::move(remove_callback_).Run(success);
+}
+
+const Entry* TestStore::LastUpdatedEntry() const {
+ return &updated_entries_.back();
+}
+
+std::string TestStore::LastRemovedEntry() const {
+ return removed_entries_.back();
+}
+
+} // namespace test
+} // namespace download
« no previous file with comments | « components/download/internal/test/test_store.h ('k') | components/download/public/clients.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698