1 // Copyright (c) 2012 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.
5 #include "media/base/gmock_callback_support.h"
8 #include "base/callback.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
13 using testing::MockFunction
;
17 typedef base::Callback
<void(const bool& src
, bool* dst
)> TestCallback
;
19 void SetBool(const bool& src
, bool* dst
) {
23 TEST(GmockCallbackSupportTest
, IsNullCallback
) {
24 MockFunction
<void(const TestCallback
&)> check
;
25 EXPECT_CALL(check
, Call(IsNullCallback()));
26 check
.Call(TestCallback());
29 TEST(GmockCallbackSupportTest
, IsNotNullCallback
) {
30 MockFunction
<void(const TestCallback
&)> check
;
31 EXPECT_CALL(check
, Call(IsNotNullCallback()));
32 check
.Call(base::Bind(&SetBool
));
35 TEST(GmockCallbackSupportTest
, RunClosure
) {
36 MockFunction
<void(const base::Closure
&)> check
;
38 EXPECT_CALL(check
, Call(IsNotNullCallback()))
39 .WillOnce(RunClosure
<0>());
40 check
.Call(base::Bind(&SetBool
, true, &dst
));
44 TEST(GmockCallbackSupportTest
, RunCallback0
) {
45 MockFunction
<void(const TestCallback
&)> check
;
47 EXPECT_CALL(check
, Call(IsNotNullCallback()))
48 .WillOnce(RunCallback
<0>(true, &dst
));
49 check
.Call(base::Bind(&SetBool
));
53 TEST(GmockCallbackSupportTest
, RunCallback1
) {
54 MockFunction
<void(int, const TestCallback
&)> check
;
56 EXPECT_CALL(check
, Call(0, IsNotNullCallback()))
57 .WillOnce(RunCallback
<1>(true, &dst
));
58 check
.Call(0, base::Bind(&SetBool
));
62 TEST(GmockCallbackSupportTest
, RunCallbackPassByRef
) {
63 MockFunction
<void(const TestCallback
&)> check
;
66 EXPECT_CALL(check
, Call(IsNotNullCallback()))
67 .WillOnce(RunCallback
<0>(ByRef(src
), &dst
));
69 check
.Call(base::Bind(&SetBool
));
73 TEST(GmockCallbackSupportTest
, RunCallbackPassByValue
) {
74 MockFunction
<void(const TestCallback
&)> check
;
77 EXPECT_CALL(check
, Call(IsNotNullCallback()))
78 .WillOnce(RunCallback
<0>(src
, &dst
));
80 check
.Call(base::Bind(&SetBool
));