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/extensions/api/image_writer_private/error_messages.h" | 6 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
7 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h
" | 7 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h
" |
8 #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/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_system_factory.h" | 10 #include "chrome/browser/extensions/extension_system_factory.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 #include "extensions/browser/event_router.h" | 13 #include "extensions/browser/event_router.h" |
14 | 14 |
15 #if defined(OS_CHROMEOS) | 15 #if defined(OS_CHROMEOS) |
16 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" | 16 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" |
17 #include "chrome/browser/chromeos/settings/cros_settings.h" | 17 #include "chrome/browser/chromeos/settings/cros_settings.h" |
18 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 18 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
19 #endif | 19 #endif |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 namespace image_writer { | 22 namespace image_writer { |
23 | 23 |
24 // 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 |
25 // the event router put the logic here. | 25 // the event router put the logic here. |
26 class FakeEventRouter : public extensions::EventRouter { | 26 class FakeEventRouter : public extensions::EventRouter { |
27 public: | 27 public: |
28 explicit FakeEventRouter(Profile* profile) : EventRouter(profile, NULL) {} | 28 explicit FakeEventRouter(Profile* profile) : EventRouter(profile, NULL) {} |
29 | 29 |
30 virtual void DispatchEventToExtension( | 30 void DispatchEventToExtension(const std::string& extension_id, |
31 const std::string& extension_id, | 31 scoped_ptr<extensions::Event> event) override { |
32 scoped_ptr<extensions::Event> event) override { | |
33 // Do nothing with the event as no tests currently care. | 32 // Do nothing with the event as no tests currently care. |
34 } | 33 } |
35 }; | 34 }; |
36 | 35 |
37 // A fake ExtensionSystem that returns a FakeEventRouter for event_router(). | 36 // A fake ExtensionSystem that returns a FakeEventRouter for event_router(). |
38 class FakeExtensionSystem : public extensions::TestExtensionSystem { | 37 class FakeExtensionSystem : public extensions::TestExtensionSystem { |
39 public: | 38 public: |
40 explicit FakeExtensionSystem(Profile* profile) | 39 explicit FakeExtensionSystem(Profile* profile) |
41 : TestExtensionSystem(profile) { | 40 : TestExtensionSystem(profile) { |
42 fake_event_router_.reset(new FakeEventRouter(profile)); | 41 fake_event_router_.reset(new FakeEventRouter(profile)); |
43 } | 42 } |
44 | 43 |
45 virtual EventRouter* event_router() override { | 44 EventRouter* event_router() override { return fake_event_router_.get(); } |
46 return fake_event_router_.get(); | |
47 } | |
48 | 45 |
49 private: | 46 private: |
50 scoped_ptr<FakeEventRouter> fake_event_router_; | 47 scoped_ptr<FakeEventRouter> fake_event_router_; |
51 }; | 48 }; |
52 | 49 |
53 // Factory function to register for the ExtensionSystem. | 50 // Factory function to register for the ExtensionSystem. |
54 KeyedService* BuildFakeExtensionSystem(content::BrowserContext* profile) { | 51 KeyedService* BuildFakeExtensionSystem(content::BrowserContext* profile) { |
55 return new FakeExtensionSystem(static_cast<Profile*>(profile)); | 52 return new FakeExtensionSystem(static_cast<Profile*>(profile)); |
56 } | 53 } |
57 | 54 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 EXPECT_TRUE(cancelled_); | 149 EXPECT_TRUE(cancelled_); |
153 EXPECT_TRUE(cancel_success_); | 150 EXPECT_TRUE(cancel_success_); |
154 EXPECT_EQ("", cancel_error_); | 151 EXPECT_EQ("", cancel_error_); |
155 | 152 |
156 base::RunLoop().RunUntilIdle(); | 153 base::RunLoop().RunUntilIdle(); |
157 } | 154 } |
158 | 155 |
159 } // namespace | 156 } // namespace |
160 } // namespace image_writer | 157 } // namespace image_writer |
161 } // namespace extensions | 158 } // namespace extensions |
OLD | NEW |