chromium/base/test/mock_callback.h

// This file was GENERATED by command:
//     pump.py mock_callback.h.pump
// DO NOT EDIT BY HAND!!!

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Analogous to GMock's built-in MockFunction, but for base::Callback instead of
// std::function. It takes the full callback type as a parameter, so that it can
// support both OnceCallback and RepeatingCallback. Furthermore, this file
// defines convenience typedefs in the form of MockOnceCallback<Signature>,
// MockRepeatingCallback<Signature>, MockOnceClosure and MockRepeatingClosure.
//
// Use:
//   using FooCallback = base::RepeatingCallback<int(std::string)>;
//
//   TEST(FooTest, RunsCallbackWithBarArgument) {
//     base::MockCallback<FooCallback> callback;
//     EXPECT_CALL(callback, Run("bar")).WillOnce(Return(1));
//     Foo(callback.Get());
//   }
//
// Or equivalently:
//
//   TEST(FooTest, RunsCallbackWithBarArgument) {
//     base::MockRepeatingCallback<int(std::string)> callback;
//     EXPECT_CALL(callback, Run("bar")).WillOnce(Return(1));
//     Foo(callback.Get());
//   }
//
//
// Can be used with StrictMock and NiceMock. Caller must ensure that it outlives
// any base::Callback obtained from it.

#ifndef BASE_TEST_MOCK_CALLBACK_H_
#define BASE_TEST_MOCK_CALLBACK_H_

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace base {

// clang-format off

template <typename F>
class MockCallback;

MockOnceCallback;
MockRepeatingCallback;

MockOnceClosure;
MockRepeatingClosure;

MockCallback<RepeatingCallback<R ()>>;

MockCallback<OnceCallback<R ()>>;

MockCallback<RepeatingCallback<R (A1)>>;

MockCallback<OnceCallback<R (A1)>>;

MockCallback<RepeatingCallback<R (A1, A2)>>;

MockCallback<OnceCallback<R (A1, A2)>>;

MockCallback<RepeatingCallback<R (A1, A2, A3)>>;

MockCallback<OnceCallback<R (A1, A2, A3)>>;

MockCallback<RepeatingCallback<R (A1, A2, A3, A4)>>;

MockCallback<OnceCallback<R (A1, A2, A3, A4)>>;

MockCallback<RepeatingCallback<R (A1, A2, A3, A4, A5)>>;

MockCallback<OnceCallback<R (A1, A2, A3, A4, A5)>>;

MockCallback<RepeatingCallback<R (A1, A2, A3, A4, A5, A6)>>;

MockCallback<OnceCallback<R (A1, A2, A3, A4, A5, A6)>>;

MockCallback<RepeatingCallback<R (A1, A2, A3, A4, A5, A6, A7)>>;

MockCallback<OnceCallback<R (A1, A2, A3, A4, A5, A6, A7)>>;

MockCallback<RepeatingCallback<R (A1, A2, A3, A4, A5, A6, A7, A8)>>;

MockCallback<OnceCallback<R (A1, A2, A3, A4, A5, A6, A7, A8)>>;

MockCallback<RepeatingCallback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)>>;

MockCallback<OnceCallback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)>>;

MockCallback<RepeatingCallback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>>;

MockCallback<OnceCallback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>>;

// clang-format on

}  // namespace base

#endif  // BASE_TEST_MOCK_CALLBACK_H_