1 // Copyright 2015 The Weave Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef LIBWEAVE_INCLUDE_WEAVE_TEST_FAKE_STREAM_H_
6 #define LIBWEAVE_INCLUDE_WEAVE_TEST_FAKE_STREAM_H_
7 
8 #include <weave/stream.h>
9 
10 #include <string>
11 
12 #include <base/time/time.h>
13 #include <gmock/gmock.h>
14 
15 namespace weave {
16 
17 namespace provider {
18 class TaskRunner;
19 }
20 
21 namespace test {
22 
23 class FakeStream : public Stream {
24  public:
25   explicit FakeStream(provider::TaskRunner* task_runner);
26   FakeStream(provider::TaskRunner* task_runner, const std::string& read_data);
27 
28   void ExpectWritePacketString(base::TimeDelta, const std::string& data);
29   void AddReadPacketString(base::TimeDelta, const std::string& data);
30 
31   void CancelPendingOperations() override;
32   void Read(void* buffer,
33             size_t size_to_read,
34             const ReadCallback& callback) override;
35   void Write(const void* buffer,
36              size_t size_to_write,
37              const WriteCallback& callback) override;
38 
39  private:
40   provider::TaskRunner* task_runner_{nullptr};
41   std::string write_data_;
42   std::string read_data_;
43 };
44 
45 }  // namespace test
46 }  // namespace weave
47 
48 #endif  // LIBWEAVE_INCLUDE_WEAVE_TEST_FAKE_STREAM_H_
49