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

Unified Diff: components/proximity_auth/fake_connection.h

Issue 1351473003: Refactor fake Connection subclasses in proximity_auth/ tests to a single file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client_rename
Patch Set: rebase Created 5 years, 3 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/proximity_auth/fake_connection.h
diff --git a/components/proximity_auth/fake_connection.h b/components/proximity_auth/fake_connection.h
new file mode 100644
index 0000000000000000000000000000000000000000..8a8732def2b7b8159cd6b1f3d90cb66ae38151ca
--- /dev/null
+++ b/components/proximity_auth/fake_connection.h
@@ -0,0 +1,53 @@
+// Copyright 2015 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_PROXIMITY_AUTH_FAKE_CONNECTION_H
+#define COMPONENTS_PROXIMITY_AUTH_FAKE_CONNECTION_H
+
+#include "components/proximity_auth/connection.h"
+
+namespace proximity_auth {
+
+// A fake implementation of Connection to use in tests.
+class FakeConnection : public Connection {
+ public:
+ FakeConnection(const RemoteDevice& remote_device);
+ ~FakeConnection() override;
+
+ // Connection:
+ void Connect() override;
+ void Disconnect() override;
+
+ // Completes the current send operation with success |success|.
+ void FinishSendingMessageWithSuccess(bool success);
+
+ // Simulates receiving a wire message with the given |payload|, bypassing the
+ // container WireMessage format.
+ void ReceiveMessageWithPayload(const std::string& payload);
+
+ // Returns the current message in progress of being sent.
+ WireMessage* current_message() { return current_message_.get(); }
+
+ using Connection::SetStatus;
+
+ private:
+ // Connection:
+ void SendMessageImpl(scoped_ptr<WireMessage> message) override;
+ scoped_ptr<WireMessage> DeserializeWireMessage(
+ bool* is_incomplete_message) override;
+
+ // The message currently being sent. Only set between a call to
+ // SendMessageImpl() and FinishSendingMessageWithSuccess().
+ scoped_ptr<WireMessage> current_message_;
+
+ // The payload that should be returned when DeserializeWireMessage() is
+ // called.
+ std::string pending_payload_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeConnection);
+};
+
+} // namespace proximity_auth
+
+#endif // COMPONENTS_PROXIMITY_AUTH_FAKE_CONNECTION_H
« no previous file with comments | « components/proximity_auth/bluetooth_throttler_impl_unittest.cc ('k') | components/proximity_auth/fake_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698