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 |