Home | History | Annotate | Download | only in streams
      1 // Copyright 2015 The Chromium OS 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 LIBBRILLO_BRILLO_STREAMS_MOCK_STREAM_H_
      6 #define LIBBRILLO_BRILLO_STREAMS_MOCK_STREAM_H_
      7 
      8 #include <gmock/gmock.h>
      9 
     10 #include <brillo/streams/stream.h>
     11 
     12 namespace brillo {
     13 
     14 // Mock Stream implementation for testing.
     15 class MockStream : public Stream {
     16  public:
     17   MockStream() = default;
     18 
     19   MOCK_CONST_METHOD0(IsOpen, bool());
     20   MOCK_CONST_METHOD0(CanRead, bool());
     21   MOCK_CONST_METHOD0(CanWrite, bool());
     22   MOCK_CONST_METHOD0(CanSeek, bool());
     23   MOCK_CONST_METHOD0(CanGetSize, bool());
     24 
     25   MOCK_CONST_METHOD0(GetSize, uint64_t());
     26   MOCK_METHOD2(SetSizeBlocking, bool(uint64_t, ErrorPtr*));
     27   MOCK_CONST_METHOD0(GetRemainingSize, uint64_t());
     28 
     29   MOCK_CONST_METHOD0(GetPosition, uint64_t());
     30   MOCK_METHOD4(Seek, bool(int64_t, Whence, uint64_t*, ErrorPtr*));
     31 
     32   MOCK_METHOD5(ReadAsync, bool(void*,
     33                                size_t,
     34                                const base::Callback<void(size_t)>&,
     35                                const ErrorCallback&,
     36                                ErrorPtr*));
     37   MOCK_METHOD5(ReadAllAsync, bool(void*,
     38                                   size_t,
     39                                   const base::Closure&,
     40                                   const ErrorCallback&,
     41                                   ErrorPtr*));
     42   MOCK_METHOD5(ReadNonBlocking, bool(void*, size_t, size_t*, bool*, ErrorPtr*));
     43   MOCK_METHOD4(ReadBlocking, bool(void*, size_t, size_t*, ErrorPtr*));
     44   MOCK_METHOD3(ReadAllBlocking, bool(void*, size_t, ErrorPtr*));
     45 
     46   MOCK_METHOD5(WriteAsync, bool(const void*,
     47                                 size_t,
     48                                 const base::Callback<void(size_t)>&,
     49                                 const ErrorCallback&,
     50                                 ErrorPtr*));
     51   MOCK_METHOD5(WriteAllAsync, bool(const void*,
     52                                    size_t,
     53                                    const base::Closure&,
     54                                    const ErrorCallback&,
     55                                    ErrorPtr*));
     56   MOCK_METHOD4(WriteNonBlocking, bool(const void*, size_t, size_t*, ErrorPtr*));
     57   MOCK_METHOD4(WriteBlocking, bool(const void*, size_t, size_t*, ErrorPtr*));
     58   MOCK_METHOD3(WriteAllBlocking, bool(const void*, size_t, ErrorPtr*));
     59 
     60   MOCK_METHOD1(FlushBlocking, bool(ErrorPtr*));
     61   MOCK_METHOD1(CloseBlocking, bool(ErrorPtr*));
     62 
     63   MOCK_METHOD3(WaitForData, bool(AccessMode,
     64                                  const base::Callback<void(AccessMode)>&,
     65                                  ErrorPtr*));
     66   MOCK_METHOD4(WaitForDataBlocking,
     67                bool(AccessMode, base::TimeDelta, AccessMode*, ErrorPtr*));
     68 
     69  private:
     70   DISALLOW_COPY_AND_ASSIGN(MockStream);
     71 };
     72 
     73 }  // namespace brillo
     74 
     75 #endif  // LIBBRILLO_BRILLO_STREAMS_MOCK_STREAM_H_
     76