| Index: trunk/src/chrome/browser/extensions/api/image_writer_private/operation_unittest.cc
|
| ===================================================================
|
| --- trunk/src/chrome/browser/extensions/api/image_writer_private/operation_unittest.cc (revision 282139)
|
| +++ trunk/src/chrome/browser/extensions/api/image_writer_private/operation_unittest.cc (working copy)
|
| @@ -71,25 +71,26 @@
|
| ImageWriterUnitTestBase::SetUp();
|
|
|
| // Create the zip file.
|
| - base::FilePath image_dir = test_utils_.GetTempDir().AppendASCII("zip");
|
| + base::FilePath image_dir = temp_dir_.path().AppendASCII("zip");
|
| ASSERT_TRUE(base::CreateDirectory(image_dir));
|
| ASSERT_TRUE(base::CreateTemporaryFileInDir(image_dir, &image_path_));
|
|
|
| - test_utils_.FillFile(image_path_, kImagePattern, kTestFileSize);
|
| + FillFile(image_path_, kImagePattern, kTestFileSize);
|
|
|
| - zip_file_ = test_utils_.GetTempDir().AppendASCII("test_image.zip");
|
| + zip_file_ = temp_dir_.path().AppendASCII("test_image.zip");
|
| ASSERT_TRUE(zip::Zip(image_dir, zip_file_, true));
|
|
|
| // Operation setup.
|
| - operation_ =
|
| - new OperationForTest(manager_.AsWeakPtr(),
|
| - kDummyExtensionId,
|
| - test_utils_.GetDevicePath().AsUTF8Unsafe());
|
| - operation_->SetImagePath(test_utils_.GetImagePath());
|
| + operation_ = new OperationForTest(manager_.AsWeakPtr(),
|
| + kDummyExtensionId,
|
| + test_device_path_.AsUTF8Unsafe());
|
| + client_ = FakeImageWriterClient::Create();
|
| + operation_->SetImagePath(test_image_path_);
|
| }
|
|
|
| virtual void TearDown() OVERRIDE {
|
| // Ensure all callbacks have been destroyed and cleanup occurs.
|
| + client_->Shutdown();
|
| operation_->Cancel();
|
|
|
| ImageWriterUnitTestBase::TearDown();
|
| @@ -101,6 +102,7 @@
|
| scoped_ptr<TestingProfile> profile_;
|
|
|
| MockOperationManager manager_;
|
| + scoped_refptr<FakeImageWriterClient> client_;
|
| scoped_refptr<OperationForTest> operation_;
|
| };
|
|
|
| @@ -152,6 +154,10 @@
|
|
|
| #if defined(OS_LINUX)
|
| TEST_F(ImageWriterOperationTest, WriteImageToDevice) {
|
| +#if !defined(OS_CHROMEOS)
|
| + operation_->SetUtilityClientForTesting(client_);
|
| +#endif
|
| +
|
| EXPECT_CALL(manager_, OnError(kDummyExtensionId, _, _, _)).Times(0);
|
| EXPECT_CALL(manager_,
|
| OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, _))
|
| @@ -173,10 +179,10 @@
|
| base::RunLoop().RunUntilIdle();
|
|
|
| #if !defined(OS_CHROMEOS)
|
| - test_utils_.GetUtilityClient()->Progress(0);
|
| - test_utils_.GetUtilityClient()->Progress(kTestFileSize / 2);
|
| - test_utils_.GetUtilityClient()->Progress(kTestFileSize);
|
| - test_utils_.GetUtilityClient()->Success();
|
| + client_->Progress(0);
|
| + client_->Progress(kTestFileSize / 2);
|
| + client_->Progress(kTestFileSize);
|
| + client_->Success();
|
|
|
| base::RunLoop().RunUntilIdle();
|
| #endif
|
| @@ -188,6 +194,8 @@
|
| // are skipped.
|
|
|
| TEST_F(ImageWriterOperationTest, VerifyFileSuccess) {
|
| + operation_->SetUtilityClientForTesting(client_);
|
| +
|
| EXPECT_CALL(manager_, OnError(kDummyExtensionId, _, _, _)).Times(0);
|
| EXPECT_CALL(
|
| manager_,
|
| @@ -202,8 +210,7 @@
|
| OnProgress(kDummyExtensionId, image_writer_api::STAGE_VERIFYWRITE, 100))
|
| .Times(AtLeast(1));
|
|
|
| - test_utils_.FillFile(
|
| - test_utils_.GetDevicePath(), kImagePattern, kTestFileSize);
|
| + FillFile(test_device_path_, kImagePattern, kTestFileSize);
|
|
|
| operation_->Start();
|
| content::BrowserThread::PostTask(content::BrowserThread::FILE,
|
| @@ -214,17 +221,17 @@
|
|
|
| base::RunLoop().RunUntilIdle();
|
|
|
| -#if !defined(OS_CHROMEOS)
|
| - test_utils_.GetUtilityClient()->Progress(0);
|
| - test_utils_.GetUtilityClient()->Progress(kTestFileSize / 2);
|
| - test_utils_.GetUtilityClient()->Progress(kTestFileSize);
|
| - test_utils_.GetUtilityClient()->Success();
|
| -#endif
|
| + client_->Progress(0);
|
| + client_->Progress(kTestFileSize / 2);
|
| + client_->Progress(kTestFileSize);
|
| + client_->Success();
|
|
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| TEST_F(ImageWriterOperationTest, VerifyFileFailure) {
|
| + operation_->SetUtilityClientForTesting(client_);
|
| +
|
| EXPECT_CALL(
|
| manager_,
|
| OnProgress(kDummyExtensionId, image_writer_api::STAGE_VERIFYWRITE, _))
|
| @@ -239,8 +246,7 @@
|
| OnError(kDummyExtensionId, image_writer_api::STAGE_VERIFYWRITE, _, _))
|
| .Times(1);
|
|
|
| - test_utils_.FillFile(
|
| - test_utils_.GetDevicePath(), kDevicePattern, kTestFileSize);
|
| + FillFile(test_device_path_, kDevicePattern, kTestFileSize);
|
|
|
| operation_->Start();
|
| content::BrowserThread::PostTask(content::BrowserThread::FILE,
|
| @@ -251,9 +257,9 @@
|
|
|
| base::RunLoop().RunUntilIdle();
|
|
|
| - test_utils_.GetUtilityClient()->Progress(0);
|
| - test_utils_.GetUtilityClient()->Progress(kTestFileSize / 2);
|
| - test_utils_.GetUtilityClient()->Error(error::kVerificationFailed);
|
| + client_->Progress(0);
|
| + client_->Progress(kTestFileSize / 2);
|
| + client_->Error(error::kVerificationFailed);
|
|
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|