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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "chrome/browser/chromeos/login/user_manager.h" | 6 #include "chrome/browser/chromeos/login/user_manager.h" |
7 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" | 7 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
8 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h
" | |
9 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" | 8 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" |
| 9 #include "chrome/browser/extensions/api/image_writer_private/write_from_file_ope
ration.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/test_extension_system.h" | 11 #include "chrome/browser/extensions/test_extension_system.h" |
12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
13 | 13 |
14 #if defined(OS_CHROMEOS) | 14 #if defined(OS_CHROMEOS) |
15 #include "chrome/browser/chromeos/login/user_manager.h" | 15 #include "chrome/browser/chromeos/login/user_manager.h" |
16 #include "chrome/browser/chromeos/settings/cros_settings.h" | 16 #include "chrome/browser/chromeos/settings/cros_settings.h" |
17 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 17 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
18 #endif | 18 #endif |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 namespace image_writer { | 21 namespace image_writer { |
22 | 22 |
23 using testing::_; | 23 using testing::_; |
24 using testing::Lt; | 24 using testing::Lt; |
25 using testing::AnyNumber; | 25 using testing::AnyNumber; |
26 using testing::AtLeast; | 26 using testing::AtLeast; |
27 | 27 |
28 namespace { | |
29 | |
30 class ImageWriterOperationManagerTest | 28 class ImageWriterOperationManagerTest |
31 : public ImageWriterUnitTestBase { | 29 : public ImageWriterUnitTestBase { |
32 public: | 30 public: |
33 void StartCallback(bool success, const std::string& error) { | 31 void StartCallback(bool success, const std::string& error) { |
34 started_ = true; | 32 started_ = true; |
35 start_success_ = success; | 33 start_success_ = success; |
36 start_error_ = error; | 34 start_error_ = error; |
37 } | 35 } |
38 | 36 |
39 protected: | 37 protected: |
(...skipping 23 matching lines...) Expand all Loading... |
63 chromeos::ScopedTestCrosSettings test_cros_settings_; | 61 chromeos::ScopedTestCrosSettings test_cros_settings_; |
64 chromeos::ScopedTestUserManager test_user_manager_; | 62 chromeos::ScopedTestUserManager test_user_manager_; |
65 #endif | 63 #endif |
66 }; | 64 }; |
67 | 65 |
68 TEST_F(ImageWriterOperationManagerTest, WriteFromFile) { | 66 TEST_F(ImageWriterOperationManagerTest, WriteFromFile) { |
69 OperationManager manager(&test_profile_); | 67 OperationManager manager(&test_profile_); |
70 | 68 |
71 manager.StartWriteFromFile( | 69 manager.StartWriteFromFile( |
72 kDummyExtensionId, | 70 kDummyExtensionId, |
73 test_image_path_, | 71 test_image_, |
74 test_device_path_.AsUTF8Unsafe(), | 72 test_device_.AsUTF8Unsafe(), |
75 base::Bind(&ImageWriterOperationManagerTest::StartCallback, | 73 base::Bind(&ImageWriterOperationManagerTest::StartCallback, |
76 base::Unretained(this))); | 74 base::Unretained(this))); |
77 | 75 |
78 EXPECT_TRUE(started_); | 76 EXPECT_TRUE(started_); |
79 EXPECT_TRUE(start_success_); | 77 EXPECT_TRUE(start_success_); |
80 EXPECT_EQ("", start_error_); | 78 EXPECT_EQ("", start_error_); |
81 } | 79 } |
82 | 80 |
83 TEST_F(ImageWriterOperationManagerTest, DestroyPartitions) { | 81 } // namespace image_writer |
84 OperationManager manager(&test_profile_); | 82 } // namespace extensions |
85 | |
86 manager.DestroyPartitions( | |
87 kDummyExtensionId, | |
88 test_device_path_.AsUTF8Unsafe(), | |
89 base::Bind(&ImageWriterOperationManagerTest::StartCallback, | |
90 base::Unretained(this))); | |
91 | |
92 EXPECT_TRUE(started_); | |
93 EXPECT_TRUE(start_success_); | |
94 EXPECT_EQ("", start_error_); | |
95 } | |
96 | |
97 } // namespace | |
98 } // namespace image_writer | |
99 } // namespace extensions | |
OLD | NEW |