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 "chrome/browser/extensions/api/image_writer_private/operation_manager.h
" | 5 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h
" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" | 12 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
13 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" | 13 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/extensions/extension_system_factory.h" | 15 #include "chrome/browser/extensions/extension_system_factory.h" |
16 #include "chrome/browser/extensions/test_extension_system.h" | 16 #include "chrome/browser/extensions/test_extension_system.h" |
17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
18 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
19 #include "extensions/browser/event_router_factory.h" | 19 #include "extensions/browser/event_router_factory.h" |
20 | 20 |
21 #if defined(OS_CHROMEOS) | |
22 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" | |
23 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
24 #include "chrome/browser/chromeos/settings/device_settings_service.h" | |
25 #endif | |
26 | |
27 namespace extensions { | 21 namespace extensions { |
28 namespace image_writer { | 22 namespace image_writer { |
29 | 23 |
30 // A fake for the EventRouter. If tests require monitoring of interaction with | 24 // A fake for the EventRouter. If tests require monitoring of interaction with |
31 // the event router put the logic here. | 25 // the event router put the logic here. |
32 class FakeEventRouter : public extensions::EventRouter { | 26 class FakeEventRouter : public extensions::EventRouter { |
33 public: | 27 public: |
34 explicit FakeEventRouter(Profile* profile) : EventRouter(profile, NULL) {} | 28 explicit FakeEventRouter(Profile* profile) : EventRouter(profile, NULL) {} |
35 | 29 |
36 void DispatchEventToExtension( | 30 void DispatchEventToExtension( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 bool started_; | 72 bool started_; |
79 bool start_success_; | 73 bool start_success_; |
80 std::string start_error_; | 74 std::string start_error_; |
81 | 75 |
82 bool cancelled_; | 76 bool cancelled_; |
83 bool cancel_success_; | 77 bool cancel_success_; |
84 std::string cancel_error_; | 78 std::string cancel_error_; |
85 | 79 |
86 TestingProfile test_profile_; | 80 TestingProfile test_profile_; |
87 FakeEventRouter* event_router_; | 81 FakeEventRouter* event_router_; |
88 | |
89 #if defined(OS_CHROMEOS) | |
90 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | |
91 chromeos::ScopedTestCrosSettings test_cros_settings_; | |
92 chromeos::ScopedTestUserManager test_user_manager_; | |
93 #endif | |
94 }; | 82 }; |
95 | 83 |
96 TEST_F(ImageWriterOperationManagerTest, WriteFromFile) { | 84 TEST_F(ImageWriterOperationManagerTest, WriteFromFile) { |
97 OperationManager manager(&test_profile_); | 85 OperationManager manager(&test_profile_); |
98 | 86 |
99 manager.StartWriteFromFile( | 87 manager.StartWriteFromFile( |
100 kDummyExtensionId, | 88 kDummyExtensionId, |
101 test_utils_.GetImagePath(), | 89 test_utils_.GetImagePath(), |
102 test_utils_.GetDevicePath().AsUTF8Unsafe(), | 90 test_utils_.GetDevicePath().AsUTF8Unsafe(), |
103 base::Bind(&ImageWriterOperationManagerTest::StartCallback, | 91 base::Bind(&ImageWriterOperationManagerTest::StartCallback, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 EXPECT_TRUE(cancelled_); | 128 EXPECT_TRUE(cancelled_); |
141 EXPECT_TRUE(cancel_success_); | 129 EXPECT_TRUE(cancel_success_); |
142 EXPECT_EQ("", cancel_error_); | 130 EXPECT_EQ("", cancel_error_); |
143 | 131 |
144 base::RunLoop().RunUntilIdle(); | 132 base::RunLoop().RunUntilIdle(); |
145 } | 133 } |
146 | 134 |
147 } // namespace | 135 } // namespace |
148 } // namespace image_writer | 136 } // namespace image_writer |
149 } // namespace extensions | 137 } // namespace extensions |
OLD | NEW |