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

Unified Diff: components/download/internal/test/test_download_driver.h

Issue 2880933002: Download driver for components/download. (Closed)
Patch Set: 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
Index: components/download/internal/test/test_download_driver.h
diff --git a/components/download/internal/test/test_download_driver.h b/components/download/internal/test/test_download_driver.h
new file mode 100644
index 0000000000000000000000000000000000000000..5ffefdcaba51e63a8149bf1bdcdb689bca1a1509
--- /dev/null
+++ b/components/download/internal/test/test_download_driver.h
@@ -0,0 +1,49 @@
+// 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.
+
+#ifndef COMPONENTS_DOWNLOAD_INTERNAL_TEST_TEST_DOWNLOAD_DRIVER_H_
+#define COMPONENTS_DOWNLOAD_INTERNAL_TEST_TEST_DOWNLOAD_DRIVER_H_
+
+#include "base/macros.h"
+#include "components/download/internal/download_driver.h"
+
+namespace download {
+
+// Download driver that simulates content layer download logic.
+class TestDownloadDriver : public DownloadDriver {
+ public:
+ TestDownloadDriver();
+ ~TestDownloadDriver();
+
+ // Marks download driver as ready, used to test logic that depends on
+ // data initialization.
+ void MakeReady();
+
+ // Simulates download events from content layer.
+ void NotifyDownloadUpdate(const std::string& guid,
+ const base::FilePath& path,
+ uint64_t size);
+ void NotifyDownloadFailed(const std::string& guid, int reason);
+ void NotifyDownloadSucceeded(const std::string& guid,
+ const base::FilePath& path,
+ int reason);
+
+ // DownloadDriver implementation.
+ void Start(const DownloadParams& params) override;
+ void Cancel(const std::string& guid) override;
+ void Pause(const std::string& guid) override;
+ void Resume(const std::string& guid) override;
+ bool IsReady() const override;
+ void SetObserver(DownloadDriver::Observer* observer) override;
+
+ private:
+ bool is_ready_;
+ DownloadDriver::Observer* observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestDownloadDriver);
+};
+
+} // namespace download
+
+#endif // COMPONENTS_DOWNLOAD_CONTENT_TEST_TEST_DOWNLOAD_DRIVER_H_

Powered by Google App Engine
This is Rietveld 408576698