| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" | 5 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/location.h" |
| 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 11 | 14 |
| 12 #if defined(OS_CHROMEOS) | 15 #if defined(OS_CHROMEOS) |
| 13 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
| 14 #include "chromeos/dbus/fake_image_burner_client.h" | 17 #include "chromeos/dbus/fake_image_burner_client.h" |
| 15 #endif | 18 #endif |
| 16 | 19 |
| 17 namespace extensions { | 20 namespace extensions { |
| 18 namespace image_writer { | 21 namespace image_writer { |
| 19 | 22 |
| 20 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| 21 namespace { | 24 namespace { |
| 22 | 25 |
| 23 class ImageWriterFakeImageBurnerClient | 26 class ImageWriterFakeImageBurnerClient |
| 24 : public chromeos::FakeImageBurnerClient { | 27 : public chromeos::FakeImageBurnerClient { |
| 25 public: | 28 public: |
| 26 ImageWriterFakeImageBurnerClient() {} | 29 ImageWriterFakeImageBurnerClient() {} |
| 27 ~ImageWriterFakeImageBurnerClient() override {} | 30 ~ImageWriterFakeImageBurnerClient() override {} |
| 28 | 31 |
| 29 void SetEventHandlers( | 32 void SetEventHandlers( |
| 30 const BurnFinishedHandler& burn_finished_handler, | 33 const BurnFinishedHandler& burn_finished_handler, |
| 31 const BurnProgressUpdateHandler& burn_progress_update_handler) override { | 34 const BurnProgressUpdateHandler& burn_progress_update_handler) override { |
| 32 burn_finished_handler_ = burn_finished_handler; | 35 burn_finished_handler_ = burn_finished_handler; |
| 33 burn_progress_update_handler_ = burn_progress_update_handler; | 36 burn_progress_update_handler_ = burn_progress_update_handler; |
| 34 } | 37 } |
| 35 | 38 |
| 36 void BurnImage(const std::string& from_path, | 39 void BurnImage(const std::string& from_path, |
| 37 const std::string& to_path, | 40 const std::string& to_path, |
| 38 const ErrorCallback& error_callback) override { | 41 const ErrorCallback& error_callback) override { |
| 39 base::MessageLoop::current()->PostTask(FROM_HERE, | 42 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 40 base::Bind(burn_progress_update_handler_, to_path, 0, 100)); | 43 FROM_HERE, base::Bind(burn_progress_update_handler_, to_path, 0, 100)); |
| 41 base::MessageLoop::current()->PostTask(FROM_HERE, | 44 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 42 base::Bind(burn_progress_update_handler_, to_path, 50, 100)); | 45 FROM_HERE, base::Bind(burn_progress_update_handler_, to_path, 50, 100)); |
| 43 base::MessageLoop::current()->PostTask(FROM_HERE, | 46 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 47 FROM_HERE, |
| 44 base::Bind(burn_progress_update_handler_, to_path, 100, 100)); | 48 base::Bind(burn_progress_update_handler_, to_path, 100, 100)); |
| 45 base::MessageLoop::current()->PostTask(FROM_HERE, | 49 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 46 base::Bind(burn_finished_handler_, to_path, true, "")); | 50 FROM_HERE, base::Bind(burn_finished_handler_, to_path, true, "")); |
| 47 } | 51 } |
| 48 | 52 |
| 49 private: | 53 private: |
| 50 BurnFinishedHandler burn_finished_handler_; | 54 BurnFinishedHandler burn_finished_handler_; |
| 51 BurnProgressUpdateHandler burn_progress_update_handler_; | 55 BurnProgressUpdateHandler burn_progress_update_handler_; |
| 52 }; | 56 }; |
| 53 | 57 |
| 54 } // namespace | 58 } // namespace |
| 55 #endif | 59 #endif |
| 56 | 60 |
| 57 MockOperationManager::MockOperationManager() : OperationManager(NULL) {} | 61 MockOperationManager::MockOperationManager() : OperationManager(NULL) {} |
| 58 MockOperationManager::MockOperationManager(content::BrowserContext* context) | 62 MockOperationManager::MockOperationManager(content::BrowserContext* context) |
| 59 : OperationManager(context) {} | 63 : OperationManager(context) {} |
| 60 MockOperationManager::~MockOperationManager() {} | 64 MockOperationManager::~MockOperationManager() {} |
| 61 | 65 |
| 62 #if defined(OS_CHROMEOS) | 66 #if defined(OS_CHROMEOS) |
| 63 FakeDiskMountManager::FakeDiskMountManager() {} | 67 FakeDiskMountManager::FakeDiskMountManager() {} |
| 64 FakeDiskMountManager::~FakeDiskMountManager() {} | 68 FakeDiskMountManager::~FakeDiskMountManager() {} |
| 65 | 69 |
| 66 void FakeDiskMountManager::UnmountDeviceRecursively( | 70 void FakeDiskMountManager::UnmountDeviceRecursively( |
| 67 const std::string& device_path, | 71 const std::string& device_path, |
| 68 const UnmountDeviceRecursivelyCallbackType& callback) { | 72 const UnmountDeviceRecursivelyCallbackType& callback) { |
| 69 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); | 73 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 74 base::Bind(callback, true)); |
| 70 } | 75 } |
| 71 #endif | 76 #endif |
| 72 | 77 |
| 73 FakeImageWriterClient::FakeImageWriterClient() {} | 78 FakeImageWriterClient::FakeImageWriterClient() {} |
| 74 FakeImageWriterClient::~FakeImageWriterClient() {} | 79 FakeImageWriterClient::~FakeImageWriterClient() {} |
| 75 | 80 |
| 76 void FakeImageWriterClient::Write(const ProgressCallback& progress_callback, | 81 void FakeImageWriterClient::Write(const ProgressCallback& progress_callback, |
| 77 const SuccessCallback& success_callback, | 82 const SuccessCallback& success_callback, |
| 78 const ErrorCallback& error_callback, | 83 const ErrorCallback& error_callback, |
| 79 const base::FilePath& source, | 84 const base::FilePath& source, |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 test_utils_.SetUp(); | 273 test_utils_.SetUp(); |
| 269 } | 274 } |
| 270 | 275 |
| 271 void ImageWriterUnitTestBase::TearDown() { | 276 void ImageWriterUnitTestBase::TearDown() { |
| 272 testing::Test::TearDown(); | 277 testing::Test::TearDown(); |
| 273 test_utils_.TearDown(); | 278 test_utils_.TearDown(); |
| 274 } | 279 } |
| 275 | 280 |
| 276 } // namespace image_writer | 281 } // namespace image_writer |
| 277 } // namespace extensions | 282 } // namespace extensions |
| OLD | NEW |