| 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 "base/files/file_util.h" | 5 #include "base/files/file_util.h" |
| 6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" | 9 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
| 10 #include "chrome/browser/extensions/api/image_writer_private/operation.h" | 10 #include "chrome/browser/extensions/api/image_writer_private/operation.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 // This class gives us a generic Operation with the ability to set or inspect | 31 // This class gives us a generic Operation with the ability to set or inspect |
| 32 // the current path to the image file. | 32 // the current path to the image file. |
| 33 class OperationForTest : public Operation { | 33 class OperationForTest : public Operation { |
| 34 public: | 34 public: |
| 35 OperationForTest(base::WeakPtr<OperationManager> manager_, | 35 OperationForTest(base::WeakPtr<OperationManager> manager_, |
| 36 const ExtensionId& extension_id, | 36 const ExtensionId& extension_id, |
| 37 const std::string& device_path) | 37 const std::string& device_path) |
| 38 : Operation(manager_, extension_id, device_path) {} | 38 : Operation(manager_, extension_id, device_path) {} |
| 39 | 39 |
| 40 virtual void StartImpl() override {} | 40 void StartImpl() override {} |
| 41 | 41 |
| 42 // Expose internal stages for testing. | 42 // Expose internal stages for testing. |
| 43 void Unzip(const base::Closure& continuation) { | 43 void Unzip(const base::Closure& continuation) { |
| 44 Operation::Unzip(continuation); | 44 Operation::Unzip(continuation); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void Write(const base::Closure& continuation) { | 47 void Write(const base::Closure& continuation) { |
| 48 Operation::Write(continuation); | 48 Operation::Write(continuation); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void VerifyWrite(const base::Closure& continuation) { | 51 void VerifyWrite(const base::Closure& continuation) { |
| 52 Operation::VerifyWrite(continuation); | 52 Operation::VerifyWrite(continuation); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Helpers to set-up state for intermediate stages. | 55 // Helpers to set-up state for intermediate stages. |
| 56 void SetImagePath(const base::FilePath image_path) { | 56 void SetImagePath(const base::FilePath image_path) { |
| 57 image_path_ = image_path; | 57 image_path_ = image_path; |
| 58 } | 58 } |
| 59 | 59 |
| 60 base::FilePath GetImagePath() { return image_path_; } | 60 base::FilePath GetImagePath() { return image_path_; } |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 virtual ~OperationForTest() {}; | 63 ~OperationForTest() override{}; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 class ImageWriterOperationTest : public ImageWriterUnitTestBase { | 66 class ImageWriterOperationTest : public ImageWriterUnitTestBase { |
| 67 protected: | 67 protected: |
| 68 ImageWriterOperationTest() | 68 ImageWriterOperationTest() |
| 69 : profile_(new TestingProfile), manager_(profile_.get()) {} | 69 : profile_(new TestingProfile), manager_(profile_.get()) {} |
| 70 virtual void SetUp() override { | 70 virtual void SetUp() override { |
| 71 ImageWriterUnitTestBase::SetUp(); | 71 ImageWriterUnitTestBase::SetUp(); |
| 72 | 72 |
| 73 // Create the zip file. | 73 // Create the zip file. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 #endif | 260 #endif |
| 261 | 261 |
| 262 // Tests that on creation the operation_ has the expected state. | 262 // Tests that on creation the operation_ has the expected state. |
| 263 TEST_F(ImageWriterOperationTest, Creation) { | 263 TEST_F(ImageWriterOperationTest, Creation) { |
| 264 EXPECT_EQ(0, operation_->GetProgress()); | 264 EXPECT_EQ(0, operation_->GetProgress()); |
| 265 EXPECT_EQ(image_writer_api::STAGE_UNKNOWN, operation_->GetStage()); | 265 EXPECT_EQ(image_writer_api::STAGE_UNKNOWN, operation_->GetStage()); |
| 266 } | 266 } |
| 267 | 267 |
| 268 } // namespace image_writer | 268 } // namespace image_writer |
| 269 } // namespace extensions | 269 } // namespace extensions |
| OLD | NEW |