| 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/users/user_manager.h" | 6 #include "chrome/browser/chromeos/login/users/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
" | 8 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h
" |
| 9 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" | 9 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 scoped_ptr<FakeEventRouter> fake_event_router_; | 51 scoped_ptr<FakeEventRouter> fake_event_router_; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 // Factory function to register for the ExtensionSystem. | 54 // Factory function to register for the ExtensionSystem. |
| 55 KeyedService* BuildFakeExtensionSystem(content::BrowserContext* profile) { | 55 KeyedService* BuildFakeExtensionSystem(content::BrowserContext* profile) { |
| 56 return new FakeExtensionSystem(static_cast<Profile*>(profile)); | 56 return new FakeExtensionSystem(static_cast<Profile*>(profile)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 namespace { | 59 namespace { |
| 60 | 60 |
| 61 class ImageWriterOperationManagerTest | 61 class ImageWriterOperationManagerTest : public ImageWriterUnitTestBase { |
| 62 : public ImageWriterUnitTestBase { | |
| 63 public: | 62 public: |
| 64 void StartCallback(bool success, const std::string& error) { | 63 void StartCallback(bool success, const std::string& error) { |
| 65 started_ = true; | 64 started_ = true; |
| 66 start_success_ = success; | 65 start_success_ = success; |
| 67 start_error_ = error; | 66 start_error_ = error; |
| 68 } | 67 } |
| 69 | 68 |
| 70 void CancelCallback(bool success, const std::string& error) { | 69 void CancelCallback(bool success, const std::string& error) { |
| 71 cancelled_ = true; | 70 cancelled_ = true; |
| 72 cancel_success_ = true; | 71 cancel_success_ = true; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 103 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 105 chromeos::ScopedTestCrosSettings test_cros_settings_; | 104 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 106 chromeos::ScopedTestUserManager test_user_manager_; | 105 chromeos::ScopedTestUserManager test_user_manager_; |
| 107 #endif | 106 #endif |
| 108 }; | 107 }; |
| 109 | 108 |
| 110 TEST_F(ImageWriterOperationManagerTest, WriteFromFile) { | 109 TEST_F(ImageWriterOperationManagerTest, WriteFromFile) { |
| 111 OperationManager manager(&test_profile_); | 110 OperationManager manager(&test_profile_); |
| 112 | 111 |
| 113 manager.StartWriteFromFile( | 112 manager.StartWriteFromFile( |
| 114 kDummyExtensionId, | 113 kDummyExtensionId, |
| 115 test_image_path_, | 114 test_utils_.GetImagePath(), |
| 116 test_device_path_.AsUTF8Unsafe(), | 115 test_utils_.GetDevicePath().AsUTF8Unsafe(), |
| 117 base::Bind(&ImageWriterOperationManagerTest::StartCallback, | 116 base::Bind(&ImageWriterOperationManagerTest::StartCallback, |
| 118 base::Unretained(this))); | 117 base::Unretained(this))); |
| 119 | 118 |
| 120 EXPECT_TRUE(started_); | 119 EXPECT_TRUE(started_); |
| 121 EXPECT_TRUE(start_success_); | 120 EXPECT_TRUE(start_success_); |
| 122 EXPECT_EQ("", start_error_); | 121 EXPECT_EQ("", start_error_); |
| 123 | 122 |
| 124 manager.CancelWrite( | 123 manager.CancelWrite( |
| 125 kDummyExtensionId, | 124 kDummyExtensionId, |
| 126 base::Bind(&ImageWriterOperationManagerTest::CancelCallback, | 125 base::Bind(&ImageWriterOperationManagerTest::CancelCallback, |
| 127 base::Unretained(this))); | 126 base::Unretained(this))); |
| 128 | 127 |
| 129 EXPECT_TRUE(cancelled_); | 128 EXPECT_TRUE(cancelled_); |
| 130 EXPECT_TRUE(cancel_success_); | 129 EXPECT_TRUE(cancel_success_); |
| 131 EXPECT_EQ("", cancel_error_); | 130 EXPECT_EQ("", cancel_error_); |
| 132 | 131 |
| 133 base::RunLoop().RunUntilIdle(); | 132 base::RunLoop().RunUntilIdle(); |
| 134 } | 133 } |
| 135 | 134 |
| 136 TEST_F(ImageWriterOperationManagerTest, DestroyPartitions) { | 135 TEST_F(ImageWriterOperationManagerTest, DestroyPartitions) { |
| 137 OperationManager manager(&test_profile_); | 136 OperationManager manager(&test_profile_); |
| 138 | 137 |
| 139 manager.DestroyPartitions( | 138 manager.DestroyPartitions( |
| 140 kDummyExtensionId, | 139 kDummyExtensionId, |
| 141 test_device_path_.AsUTF8Unsafe(), | 140 test_utils_.GetDevicePath().AsUTF8Unsafe(), |
| 142 base::Bind(&ImageWriterOperationManagerTest::StartCallback, | 141 base::Bind(&ImageWriterOperationManagerTest::StartCallback, |
| 143 base::Unretained(this))); | 142 base::Unretained(this))); |
| 144 | 143 |
| 145 EXPECT_TRUE(started_); | 144 EXPECT_TRUE(started_); |
| 146 EXPECT_TRUE(start_success_); | 145 EXPECT_TRUE(start_success_); |
| 147 EXPECT_EQ("", start_error_); | 146 EXPECT_EQ("", start_error_); |
| 148 | 147 |
| 149 manager.CancelWrite( | 148 manager.CancelWrite( |
| 150 kDummyExtensionId, | 149 kDummyExtensionId, |
| 151 base::Bind(&ImageWriterOperationManagerTest::CancelCallback, | 150 base::Bind(&ImageWriterOperationManagerTest::CancelCallback, |
| 152 base::Unretained(this))); | 151 base::Unretained(this))); |
| 153 | 152 |
| 154 EXPECT_TRUE(cancelled_); | 153 EXPECT_TRUE(cancelled_); |
| 155 EXPECT_TRUE(cancel_success_); | 154 EXPECT_TRUE(cancel_success_); |
| 156 EXPECT_EQ("", cancel_error_); | 155 EXPECT_EQ("", cancel_error_); |
| 157 | 156 |
| 158 base::RunLoop().RunUntilIdle(); | 157 base::RunLoop().RunUntilIdle(); |
| 159 } | 158 } |
| 160 | 159 |
| 161 } // namespace | 160 } // namespace |
| 162 } // namespace image_writer | 161 } // namespace image_writer |
| 163 } // namespace extensions | 162 } // namespace extensions |
| OLD | NEW |