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/file_util.h" | 5 #include "base/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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual ~OperationForTest() {}; |
64 }; | 64 }; |
65 | 65 |
66 class ImageWriterOperationTest : public ImageWriterUnitTestBase { | 66 class ImageWriterOperationTest : public ImageWriterUnitTestBase { |
67 protected: | 67 protected: |
| 68 ImageWriterOperationTest() |
| 69 : profile_(new TestingProfile), manager_(profile_.get()) {} |
68 virtual void SetUp() OVERRIDE { | 70 virtual void SetUp() OVERRIDE { |
69 ImageWriterUnitTestBase::SetUp(); | 71 ImageWriterUnitTestBase::SetUp(); |
70 | 72 |
71 // Create the zip file. | 73 // Create the zip file. |
72 base::FilePath image_dir = temp_dir_.path().AppendASCII("zip"); | 74 base::FilePath image_dir = temp_dir_.path().AppendASCII("zip"); |
73 ASSERT_TRUE(base::CreateDirectory(image_dir)); | 75 ASSERT_TRUE(base::CreateDirectory(image_dir)); |
74 ASSERT_TRUE(base::CreateTemporaryFileInDir(image_dir, &image_path_)); | 76 ASSERT_TRUE(base::CreateTemporaryFileInDir(image_dir, &image_path_)); |
75 | 77 |
76 FillFile(image_path_, kImagePattern, kTestFileSize); | 78 FillFile(image_path_, kImagePattern, kTestFileSize); |
77 | 79 |
(...skipping 12 matching lines...) Expand all Loading... |
90 // Ensure all callbacks have been destroyed and cleanup occurs. | 92 // Ensure all callbacks have been destroyed and cleanup occurs. |
91 client_->Shutdown(); | 93 client_->Shutdown(); |
92 operation_->Cancel(); | 94 operation_->Cancel(); |
93 | 95 |
94 ImageWriterUnitTestBase::TearDown(); | 96 ImageWriterUnitTestBase::TearDown(); |
95 } | 97 } |
96 | 98 |
97 base::FilePath image_path_; | 99 base::FilePath image_path_; |
98 base::FilePath zip_file_; | 100 base::FilePath zip_file_; |
99 | 101 |
| 102 scoped_ptr<TestingProfile> profile_; |
| 103 |
100 MockOperationManager manager_; | 104 MockOperationManager manager_; |
101 scoped_refptr<FakeImageWriterClient> client_; | 105 scoped_refptr<FakeImageWriterClient> client_; |
102 scoped_refptr<OperationForTest> operation_; | 106 scoped_refptr<OperationForTest> operation_; |
103 }; | 107 }; |
104 | 108 |
105 } // namespace | 109 } // namespace |
106 | 110 |
107 // Unizpping a non-zip should do nothing. | 111 // Unizpping a non-zip should do nothing. |
108 TEST_F(ImageWriterOperationTest, UnzipNonZipFile) { | 112 TEST_F(ImageWriterOperationTest, UnzipNonZipFile) { |
109 EXPECT_CALL(manager_, OnProgress(kDummyExtensionId, _, _)).Times(0); | 113 EXPECT_CALL(manager_, OnProgress(kDummyExtensionId, _, _)).Times(0); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 #endif | 266 #endif |
263 | 267 |
264 // Tests that on creation the operation_ has the expected state. | 268 // Tests that on creation the operation_ has the expected state. |
265 TEST_F(ImageWriterOperationTest, Creation) { | 269 TEST_F(ImageWriterOperationTest, Creation) { |
266 EXPECT_EQ(0, operation_->GetProgress()); | 270 EXPECT_EQ(0, operation_->GetProgress()); |
267 EXPECT_EQ(image_writer_api::STAGE_UNKNOWN, operation_->GetStage()); | 271 EXPECT_EQ(image_writer_api::STAGE_UNKNOWN, operation_->GetStage()); |
268 } | 272 } |
269 | 273 |
270 } // namespace image_writer | 274 } // namespace image_writer |
271 } // namespace extensions | 275 } // namespace extensions |
OLD | NEW |