1 // Copyright (c) 2009 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 "base/callback.h"
6 #include "base/scoped_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h"
14 HelperObject() : next_number_(0) { }
15 int GetNextNumber() { return ++next_number_
; }
16 void GetNextNumberArg(int* number
) { *number
= GetNextNumber(); }
24 TEST(Callback
, OneArg
) {
26 scoped_ptr
<Callback1
<int*>::Type
> callback(
27 NewCallback(&obj
, &HelperObject::GetNextNumberArg
));
30 callback
->Run(&number
);
34 TEST(Callback
, ReturnValue
) {
36 scoped_ptr
<CallbackWithReturnValue
<int>::Type
> callback(
37 NewCallbackWithReturnValue(&obj
, &HelperObject::GetNextNumber
));
39 EXPECT_EQ(callback
->Run(), 1);