summaryrefslogtreecommitdiffstats
path: root/src/test/rbd_mirror/test_mock_fixture.h
blob: 5ce1a748bd675b162ee2873a2238422c7bbc7390 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#ifndef CEPH_TEST_RBD_MIRROR_TEST_MOCK_FIXTURE_H
#define CEPH_TEST_RBD_MIRROR_TEST_MOCK_FIXTURE_H

#include "test/rbd_mirror/test_fixture.h"
#include "test/librados_test_stub/LibradosTestStub.h"
#include <boost/shared_ptr.hpp>
#include <gmock/gmock.h>

namespace librados {
class TestRadosClient;
class MockTestMemIoCtxImpl;
class MockTestMemRadosClient;
}

namespace librbd {
class MockImageCtx;
}

ACTION_P(CompleteContext, r) {
  arg0->complete(r);
}

namespace rbd {
namespace mirror {

class TestMockFixture : public TestFixture {
public:
  typedef boost::shared_ptr<librados::TestRadosClient> TestRadosClientPtr;

  static void SetUpTestCase();
  static void TearDownTestCase();

  virtual void SetUp();
  virtual void TearDown();

  void expect_test_features(librbd::MockImageCtx &mock_image_ctx);

  ::testing::NiceMock<librados::MockTestMemRadosClient> &get_mock_rados_client() {
    return *s_mock_rados_client;
  }

private:
  static TestRadosClientPtr s_test_rados_client;
  static ::testing::NiceMock<librados::MockTestMemRadosClient> *s_mock_rados_client;
};

} // namespace mirror
} // namespace rbd

#endif // CEPH_TEST_RBD_MIRROR_TEST_MOCK_FIXTURE_H