1 // Copyright 2015 The Chromium 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 COMPONENTS_VIZ_TEST_MOCK_HELPER_H_
6 #define COMPONENTS_VIZ_TEST_MOCK_HELPER_H_
7 
8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest-spi.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 
12 #define EXPECT_MOCK_FAILURE(statement)                            \
13   do {                                                            \
14     class GTestExpectMockFailureHelper {                          \
15      public:                                                      \
16       static void Execute() { statement; }                        \
17     };                                                            \
18     ::testing::TestPartResultArray gtest_failures;                \
19     {                                                             \
20       ::testing::ScopedFakeTestPartResultReporter gtest_reporter( \
21           ::testing::ScopedFakeTestPartResultReporter::           \
22               INTERCEPT_ONLY_CURRENT_THREAD,                      \
23           &gtest_failures);                                       \
24       GTestExpectMockFailureHelper::Execute();                    \
25     }                                                             \
26     EXPECT_GT(gtest_failures.size(), 0);                          \
27   } while (::testing::internal::AlwaysFalse())
28 
29 #endif  // COMPONENTS_VIZ_TEST_MOCK_HELPER_H_
30