| 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/error_messages.h" | 5 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
| 6 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" | 6 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" |
| 7 #include "chrome/browser/extensions/api/image_writer_private/write_from_file_ope
ration.h" | 7 #include "chrome/browser/extensions/api/image_writer_private/write_from_file_ope
ration.h" |
| 8 | 8 |
| 9 namespace extensions { | 9 namespace extensions { |
| 10 namespace image_writer { | 10 namespace image_writer { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 EXPECT_CALL(manager, OnError(kDummyExtensionId, | 33 EXPECT_CALL(manager, OnError(kDummyExtensionId, |
| 34 image_writer_api::STAGE_UNKNOWN, | 34 image_writer_api::STAGE_UNKNOWN, |
| 35 0, | 35 0, |
| 36 error::kImageInvalid)).Times(1); | 36 error::kImageInvalid)).Times(1); |
| 37 | 37 |
| 38 op->Start(); | 38 op->Start(); |
| 39 | 39 |
| 40 base::RunLoop().RunUntilIdle(); | 40 base::RunLoop().RunUntilIdle(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // Runs the entire WriteFromFile operation. | 43 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 44 TEST_F(ImageWriterFromFileTest, WriteFromFileEndToEnd) { | 44 TEST_F(ImageWriterFromFileTest, WriteFromFileEndToEnd) { |
| 45 MockOperationManager manager; | 45 MockOperationManager manager; |
| 46 | 46 |
| 47 scoped_refptr<WriteFromFileOperation> op = | 47 scoped_refptr<WriteFromFileOperation> op = |
| 48 new WriteFromFileOperation(manager.AsWeakPtr(), | 48 new WriteFromFileOperation(manager.AsWeakPtr(), |
| 49 kDummyExtensionId, | 49 kDummyExtensionId, |
| 50 test_image_path_, | 50 test_image_path_, |
| 51 test_device_path_.AsUTF8Unsafe()); | 51 test_device_path_.AsUTF8Unsafe()); |
| 52 #if !defined(OS_CHROMEOS) | |
| 53 scoped_refptr<FakeImageWriterClient> client = FakeImageWriterClient::Create(); | |
| 54 op->SetUtilityClientForTesting(client); | |
| 55 #endif | |
| 56 | 52 |
| 57 EXPECT_CALL(manager, | 53 EXPECT_CALL(manager, |
| 58 OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, _)) | 54 OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, _)) |
| 59 .Times(AnyNumber()); | 55 .Times(AnyNumber()); |
| 60 EXPECT_CALL(manager, | 56 EXPECT_CALL(manager, |
| 61 OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, 0)) | 57 OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, 0)) |
| 62 .Times(AtLeast(1)); | 58 .Times(AtLeast(1)); |
| 63 EXPECT_CALL(manager, | 59 EXPECT_CALL(manager, |
| 64 OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, 100)) | 60 OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, 100)) |
| 65 .Times(AtLeast(1)); | 61 .Times(AtLeast(1)); |
| 66 | |
| 67 #if !defined(OS_CHROMEOS) | |
| 68 // Chrome OS doesn't verify. | |
| 69 EXPECT_CALL( | 62 EXPECT_CALL( |
| 70 manager, | 63 manager, |
| 71 OnProgress(kDummyExtensionId, image_writer_api::STAGE_VERIFYWRITE, _)) | 64 OnProgress(kDummyExtensionId, image_writer_api::STAGE_VERIFYWRITE, _)) |
| 72 .Times(AnyNumber()); | 65 .Times(AnyNumber()); |
| 73 EXPECT_CALL( | 66 EXPECT_CALL( |
| 74 manager, | 67 manager, |
| 75 OnProgress(kDummyExtensionId, image_writer_api::STAGE_VERIFYWRITE, 0)) | 68 OnProgress(kDummyExtensionId, image_writer_api::STAGE_VERIFYWRITE, 0)) |
| 76 .Times(AtLeast(1)); | 69 .Times(AtLeast(1)); |
| 77 EXPECT_CALL( | 70 EXPECT_CALL( |
| 78 manager, | 71 manager, |
| 79 OnProgress(kDummyExtensionId, image_writer_api::STAGE_VERIFYWRITE, 100)) | 72 OnProgress(kDummyExtensionId, image_writer_api::STAGE_VERIFYWRITE, 100)) |
| 80 .Times(AtLeast(1)); | 73 .Times(AtLeast(1)); |
| 81 #endif | |
| 82 | |
| 83 EXPECT_CALL(manager, OnComplete(kDummyExtensionId)).Times(1); | 74 EXPECT_CALL(manager, OnComplete(kDummyExtensionId)).Times(1); |
| 84 EXPECT_CALL(manager, OnError(kDummyExtensionId, _, _, _)).Times(0); | 75 EXPECT_CALL(manager, OnError(kDummyExtensionId, _, _, _)).Times(0); |
| 85 | 76 |
| 86 op->Start(); | 77 op->Start(); |
| 87 | 78 |
| 88 base::RunLoop().RunUntilIdle(); | 79 base::RunLoop().RunUntilIdle(); |
| 89 #if !defined(OS_CHROMEOS) | 80 |
| 90 client->Progress(0); | 81 EXPECT_TRUE(base::ContentsEqual(test_image_path_, test_device_path_)); |
| 91 client->Progress(50); | 82 } |
| 92 client->Progress(100); | |
| 93 client->Success(); | |
| 94 base::RunLoop().RunUntilIdle(); | |
| 95 client->Progress(0); | |
| 96 client->Progress(50); | |
| 97 client->Progress(100); | |
| 98 client->Success(); | |
| 99 base::RunLoop().RunUntilIdle(); | |
| 100 #endif | 83 #endif |
| 101 } | |
| 102 | 84 |
| 103 } // namespace image_writer | 85 } // namespace image_writer |
| 104 } // namespace extensions | 86 } // namespace extensions |
| OLD | NEW |