| Index: trunk/src/chrome/browser/extensions/api/image_writer_private/test_utils.cc
|
| ===================================================================
|
| --- trunk/src/chrome/browser/extensions/api/image_writer_private/test_utils.cc (revision 252593)
|
| +++ trunk/src/chrome/browser/extensions/api/image_writer_private/test_utils.cc (working copy)
|
| @@ -55,65 +55,14 @@
|
| : OperationManager(profile) {}
|
| MockOperationManager::~MockOperationManager() {}
|
|
|
| -FakeImageWriterClient::FakeImageWriterClient() {}
|
| -FakeImageWriterClient::~FakeImageWriterClient() {}
|
| -
|
| -void FakeImageWriterClient::Write(const ProgressCallback& progress_callback,
|
| - const SuccessCallback& success_callback,
|
| - const ErrorCallback& error_callback,
|
| - const base::FilePath& source,
|
| - const base::FilePath& target) {
|
| - progress_callback_ = progress_callback;
|
| - success_callback_ = success_callback;
|
| - error_callback_ = error_callback;
|
| -}
|
| -
|
| -void FakeImageWriterClient::Verify(const ProgressCallback& progress_callback,
|
| - const SuccessCallback& success_callback,
|
| - const ErrorCallback& error_callback,
|
| - const base::FilePath& source,
|
| - const base::FilePath& target) {
|
| - progress_callback_ = progress_callback;
|
| - success_callback_ = success_callback;
|
| - error_callback_ = error_callback;
|
| -}
|
| -
|
| -void FakeImageWriterClient::Cancel(const CancelCallback& cancel_callback) {
|
| - cancel_callback_ = cancel_callback;
|
| -}
|
| -
|
| -void FakeImageWriterClient::Shutdown() {
|
| - // Clear handlers to not hold any reference to the caller.
|
| - success_callback_ = base::Closure();
|
| - progress_callback_ = base::Callback<void(int64)>();
|
| - error_callback_ = base::Callback<void(const std::string&)>();
|
| - cancel_callback_ = base::Closure();
|
| -}
|
| -
|
| -void FakeImageWriterClient::Progress(int64 progress) {
|
| - progress_callback_.Run(progress);
|
| -}
|
| -
|
| -void FakeImageWriterClient::Success() { success_callback_.Run(); }
|
| -
|
| -void FakeImageWriterClient::Error(const std::string& message) {
|
| - error_callback_.Run(message);
|
| -}
|
| -
|
| -void FakeImageWriterClient::Cancel() { cancel_callback_.Run(); }
|
| -
|
| -scoped_refptr<FakeImageWriterClient> FakeImageWriterClient::Create() {
|
| - return scoped_refptr<FakeImageWriterClient>(new FakeImageWriterClient());
|
| -}
|
| -
|
| ImageWriterUnitTestBase::ImageWriterUnitTestBase()
|
| : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {}
|
| ImageWriterUnitTestBase::~ImageWriterUnitTestBase() {}
|
|
|
| void ImageWriterUnitTestBase::SetUp() {
|
| testing::Test::SetUp();
|
| -
|
| ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
| +
|
| ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(),
|
| &test_image_path_));
|
| ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(),
|
| @@ -140,27 +89,6 @@
|
| #endif
|
| }
|
|
|
| -bool ImageWriterUnitTestBase::ImageWrittenToDevice(
|
| - const base::FilePath& image_path,
|
| - const base::FilePath& device_path) {
|
| - scoped_ptr<char[]> image_buffer(new char[kTestFileSize]);
|
| - scoped_ptr<char[]> device_buffer(new char[kTestFileSize]);
|
| -
|
| - int image_bytes_read =
|
| - ReadFile(image_path, image_buffer.get(), kTestFileSize);
|
| -
|
| - if (image_bytes_read < 0)
|
| - return false;
|
| -
|
| - int device_bytes_read =
|
| - ReadFile(device_path, device_buffer.get(), kTestFileSize);
|
| -
|
| - if (image_bytes_read != device_bytes_read)
|
| - return false;
|
| -
|
| - return memcmp(image_buffer.get(), device_buffer.get(), image_bytes_read) == 0;
|
| -}
|
| -
|
| bool ImageWriterUnitTestBase::FillFile(const base::FilePath& file,
|
| const int pattern,
|
| const int length) {
|
|
|