Output data about media requests to the netlog too.
[chromium-blink-merge.git] / base / callback_unittest.cc
blobbc15927ddade2d6278e60d6e51c567430a2b8cbc
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"
10 namespace {
12 class HelperObject {
13 public:
14 HelperObject() : next_number_(0) { }
15 int GetNextNumber() { return ++next_number_; }
16 void GetNextNumberArg(int* number) { *number = GetNextNumber(); }
18 private:
19 int next_number_;
22 } // namespace
24 TEST(Callback, OneArg) {
25 HelperObject obj;
26 scoped_ptr<Callback1<int*>::Type> callback(
27 NewCallback(&obj, &HelperObject::GetNextNumberArg));
29 int number = 0;
30 callback->Run(&number);
31 EXPECT_EQ(number, 1);
34 TEST(Callback, ReturnValue) {
35 HelperObject obj;
36 scoped_ptr<CallbackWithReturnValue<int>::Type> callback(
37 NewCallbackWithReturnValue(&obj, &HelperObject::GetNextNumber));
39 EXPECT_EQ(callback->Run(), 1);