OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/test/scoped_task_environment.h" | |
14 #include "chrome/utility/image_writer/error_messages.h" | 13 #include "chrome/utility/image_writer/error_messages.h" |
15 #include "chrome/utility/image_writer/image_writer.h" | 14 #include "chrome/utility/image_writer/image_writer.h" |
16 #include "chrome/utility/image_writer/image_writer_handler.h" | 15 #include "chrome/utility/image_writer/image_writer_handler.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
19 | 18 |
20 namespace image_writer { | 19 namespace image_writer { |
21 | 20 |
22 using testing::_; | 21 using testing::_; |
23 using testing::AnyNumber; | 22 using testing::AnyNumber; |
(...skipping 23 matching lines...) Expand all Loading... |
47 | 46 |
48 ASSERT_TRUE(base::WriteFile(path, buffer.get(), kTestFileSize)); | 47 ASSERT_TRUE(base::WriteFile(path, buffer.get(), kTestFileSize)); |
49 } | 48 } |
50 | 49 |
51 void FillDefault(const base::FilePath& path) { FillFile(path, kTestPattern); } | 50 void FillDefault(const base::FilePath& path) { FillFile(path, kTestPattern); } |
52 | 51 |
53 base::FilePath image_path_; | 52 base::FilePath image_path_; |
54 base::FilePath device_path_; | 53 base::FilePath device_path_; |
55 | 54 |
56 private: | 55 private: |
57 base::test::ScopedTaskEnvironment scoped_task_environment_; | 56 base::MessageLoop message_loop_; |
58 base::ScopedTempDir temp_dir_; | 57 base::ScopedTempDir temp_dir_; |
59 }; | 58 }; |
60 | 59 |
61 class MockHandler : public ImageWriterHandler { | 60 class MockHandler : public ImageWriterHandler { |
62 public: | 61 public: |
63 MOCK_METHOD1(SendProgress, void(int64_t)); | 62 MOCK_METHOD1(SendProgress, void(int64_t)); |
64 MOCK_METHOD1(SendFailed, void(const std::string& message)); | 63 MOCK_METHOD1(SendFailed, void(const std::string& message)); |
65 MOCK_METHOD0(SendSucceeded, void()); | 64 MOCK_METHOD0(SendSucceeded, void()); |
66 }; | 65 }; |
67 | 66 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 EXPECT_CALL(mock_handler, SendFailed(_)).Times(0); | 224 EXPECT_CALL(mock_handler, SendFailed(_)).Times(0); |
226 | 225 |
227 FillDefault(image_path_); | 226 FillDefault(image_path_); |
228 | 227 |
229 image_writer.Write(); | 228 image_writer.Write(); |
230 | 229 |
231 base::RunLoop().RunUntilIdle(); | 230 base::RunLoop().RunUntilIdle(); |
232 } | 231 } |
233 | 232 |
234 } // namespace image_writer | 233 } // namespace image_writer |
OLD | NEW |