summaryrefslogtreecommitdiff
path: root/brillo/http/mock_connection.h
diff options
context:
space:
mode:
Diffstat (limited to 'brillo/http/mock_connection.h')
-rw-r--r--brillo/http/mock_connection.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/brillo/http/mock_connection.h b/brillo/http/mock_connection.h
new file mode 100644
index 0000000..c57aac1
--- /dev/null
+++ b/brillo/http/mock_connection.h
@@ -0,0 +1,51 @@
+// Copyright 2014 The Chromium OS 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 LIBCHROMEOS_BRILLO_HTTP_MOCK_CONNECTION_H_
+#define LIBCHROMEOS_BRILLO_HTTP_MOCK_CONNECTION_H_
+
+#include <memory>
+#include <string>
+
+#include <base/macros.h>
+#include <brillo/http/http_connection.h>
+#include <gmock/gmock.h>
+
+namespace brillo {
+namespace http {
+
+class MockConnection : public Connection {
+ public:
+ using Connection::Connection;
+
+ MOCK_METHOD2(SendHeaders, bool(const HeaderList&, ErrorPtr*));
+ MOCK_METHOD2(MockSetRequestData, bool(Stream*, ErrorPtr*));
+ MOCK_METHOD1(MockSetResponseData, void(Stream*));
+ MOCK_METHOD1(FinishRequest, bool(ErrorPtr*));
+ MOCK_METHOD2(FinishRequestAsync,
+ RequestID(const SuccessCallback&, const ErrorCallback&));
+ MOCK_CONST_METHOD0(GetResponseStatusCode, int());
+ MOCK_CONST_METHOD0(GetResponseStatusText, std::string());
+ MOCK_CONST_METHOD0(GetProtocolVersion, std::string());
+ MOCK_CONST_METHOD1(GetResponseHeader, std::string(const std::string&));
+ MOCK_CONST_METHOD1(MockExtractDataStream, Stream*(brillo::ErrorPtr*));
+
+ private:
+ bool SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) override {
+ return MockSetRequestData(stream.get(), error);
+ }
+ void SetResponseData(StreamPtr stream) override {
+ MockSetResponseData(stream.get());
+ }
+ StreamPtr ExtractDataStream(brillo::ErrorPtr* error) override {
+ return StreamPtr{MockExtractDataStream(error)};
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(MockConnection);
+};
+
+} // namespace http
+} // namespace brillo
+
+#endif // LIBCHROMEOS_BRILLO_HTTP_MOCK_CONNECTION_H_