diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-10 02:07:41 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-10 02:07:41 +0000 |
commit | 1e1cb3bc787a85e1791f737f831d00ee08db364d (patch) | |
tree | ab228ff464b8bd78aee795e58262bd6c11e5f3dc /remoting/base/compound_buffer_unittest.cc | |
parent | be4565bce9bb1a5b3f5477cc27e20da6ddcc1de7 (diff) | |
download | chromium_src-1e1cb3bc787a85e1791f737f831d00ee08db364d.zip chromium_src-1e1cb3bc787a85e1791f737f831d00ee08db364d.tar.gz chromium_src-1e1cb3bc787a85e1791f737f831d00ee08db364d.tar.bz2 |
Move code in src/remoting to the new callbacks.
BUG=None
TEST=Remoting still works.
Review URL: http://codereview.chromium.org/8493020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109367 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base/compound_buffer_unittest.cc')
-rw-r--r-- | remoting/base/compound_buffer_unittest.cc | 76 |
1 files changed, 34 insertions, 42 deletions
diff --git a/remoting/base/compound_buffer_unittest.cc b/remoting/base/compound_buffer_unittest.cc index 60b9b78..5ad3dce 100644 --- a/remoting/base/compound_buffer_unittest.cc +++ b/remoting/base/compound_buffer_unittest.cc @@ -4,7 +4,8 @@ #include <string> -#include "base/callback_old.h" +#include "base/bind.h" +#include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "net/base/io_buffer.h" #include "remoting/base/compound_buffer.h" @@ -82,7 +83,7 @@ class CompoundBufferTest : public testing::Test { // Iterate over chunks of data with sizes specified in |sizes| in the // interval [0..kDataSize]. |function| is called for each chunk. void IterateOverPieces(const int sizes[], - Callback2<int, int>::Type* function) { + const base::Callback<void(int, int)>& function) { DCHECK_GT(sizes[0], 0); int pos = 0; @@ -93,11 +94,10 @@ class CompoundBufferTest : public testing::Test { if (sizes[index] <= 0) index = 0; - function->Run(pos, size); + function.Run(pos, size); pos += size; } - delete function; } bool CompareData(const CompoundBuffer& buffer, char* data, int size) { @@ -179,89 +179,81 @@ class CompoundBufferTest : public testing::Test { TEST_F(CompoundBufferTest, Append) { target_.Clear(); - IterateOverPieces(kChunkSizes0, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Append)); + IterateOverPieces(kChunkSizes0, base::Bind( + &CompoundBufferTest::Append, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Append)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::Append, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); } TEST_F(CompoundBufferTest, AppendCopyOf) { target_.Clear(); - IterateOverPieces(kChunkSizes0, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::AppendCopyOf)); + IterateOverPieces(kChunkSizes0, base::Bind( + &CompoundBufferTest::AppendCopyOf, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::AppendCopyOf)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::AppendCopyOf, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); } TEST_F(CompoundBufferTest, Prepend) { target_.Clear(); - IterateOverPieces(kChunkSizes0, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Prepend)); + IterateOverPieces(kChunkSizes0, base::Bind( + &CompoundBufferTest::Prepend, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Prepend)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::Prepend, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); } TEST_F(CompoundBufferTest, PrependCopyOf) { target_.Clear(); - IterateOverPieces(kChunkSizes0, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::PrependCopyOf)); + IterateOverPieces(kChunkSizes0, base::Bind( + &CompoundBufferTest::PrependCopyOf, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::PrependCopyOf)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::PrependCopyOf, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); } TEST_F(CompoundBufferTest, CropFront) { target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Append)); - IterateOverPieces(kCropSizes, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::TestCropFront)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::Append, base::Unretained(this))); + IterateOverPieces(kCropSizes, base::Bind( + &CompoundBufferTest::TestCropFront, base::Unretained(this))); } TEST_F(CompoundBufferTest, CropBack) { target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Append)); - IterateOverPieces(kCropSizes, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::TestCropBack)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::Append, base::Unretained(this))); + IterateOverPieces(kCropSizes, base::Bind( + &CompoundBufferTest::TestCropBack, base::Unretained(this))); } TEST_F(CompoundBufferTest, CopyFrom) { target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Append)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::Append, base::Unretained(this))); { SCOPED_TRACE("CopyFrom.kCopySizes0"); - IterateOverPieces(kCopySizes0, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::TestCopyFrom)); + IterateOverPieces(kCopySizes0, base::Bind( + &CompoundBufferTest::TestCopyFrom, base::Unretained(this))); } { SCOPED_TRACE("CopyFrom.kCopySizes1"); - IterateOverPieces(kCopySizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::TestCopyFrom)); + IterateOverPieces(kCopySizes1, base::Bind( + &CompoundBufferTest::TestCopyFrom, base::Unretained(this))); } } |