summaryrefslogtreecommitdiffstats
path: root/cc/test/mock_helper.h
blob: 9ca9afba3798f14d1d45a1d04c5c6269cfb0608d (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
// 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 CC_TEST_MOCK_HELPER_H_
#define CC_TEST_MOCK_HELPER_H_

#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest-spi.h"
#include "testing/gtest/include/gtest/gtest.h"

#define EXPECT_MOCK_FAILURE(statement)                            \
  do {                                                            \
    class GTestExpectMockFailureHelper {                          \
     public:                                                      \
      static void Execute() { statement; }                        \
    };                                                            \
    ::testing::TestPartResultArray gtest_failures;                \
    {                                                             \
      ::testing::ScopedFakeTestPartResultReporter gtest_reporter( \
          ::testing::ScopedFakeTestPartResultReporter::           \
              INTERCEPT_ONLY_CURRENT_THREAD,                      \
          &gtest_failures);                                       \
      GTestExpectMockFailureHelper::Execute();                    \
    }                                                             \
    EXPECT_GT(gtest_failures.size(), 0);                          \
  } while (::testing::internal::AlwaysFalse())

#endif  // CC_TEST_MOCK_HELPER_H_