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" |
(...skipping 11 matching lines...) Expand all Loading... |
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 virtual void DispatchEventToExtension( |
31 const std::string& extension_id, | 31 const std::string& extension_id, |
32 scoped_ptr<extensions::Event> event) OVERRIDE { | 32 scoped_ptr<extensions::Event> event) override { |
33 // Do nothing with the event as no tests currently care. | 33 // Do nothing with the event as no tests currently care. |
34 } | 34 } |
35 }; | 35 }; |
36 | 36 |
37 // A fake ExtensionSystem that returns a FakeEventRouter for event_router(). | 37 // A fake ExtensionSystem that returns a FakeEventRouter for event_router(). |
38 class FakeExtensionSystem : public extensions::TestExtensionSystem { | 38 class FakeExtensionSystem : public extensions::TestExtensionSystem { |
39 public: | 39 public: |
40 explicit FakeExtensionSystem(Profile* profile) | 40 explicit FakeExtensionSystem(Profile* profile) |
41 : TestExtensionSystem(profile) { | 41 : TestExtensionSystem(profile) { |
42 fake_event_router_.reset(new FakeEventRouter(profile)); | 42 fake_event_router_.reset(new FakeEventRouter(profile)); |
43 } | 43 } |
44 | 44 |
45 virtual EventRouter* event_router() OVERRIDE { | 45 virtual EventRouter* event_router() override { |
46 return fake_event_router_.get(); | 46 return fake_event_router_.get(); |
47 } | 47 } |
48 | 48 |
49 private: | 49 private: |
50 scoped_ptr<FakeEventRouter> fake_event_router_; | 50 scoped_ptr<FakeEventRouter> fake_event_router_; |
51 }; | 51 }; |
52 | 52 |
53 // Factory function to register for the ExtensionSystem. | 53 // Factory function to register for the ExtensionSystem. |
54 KeyedService* BuildFakeExtensionSystem(content::BrowserContext* profile) { | 54 KeyedService* BuildFakeExtensionSystem(content::BrowserContext* profile) { |
55 return new FakeExtensionSystem(static_cast<Profile*>(profile)); | 55 return new FakeExtensionSystem(static_cast<Profile*>(profile)); |
(...skipping 14 matching lines...) Expand all Loading... |
70 cancel_success_ = true; | 70 cancel_success_ = true; |
71 cancel_error_ = error; | 71 cancel_error_ = error; |
72 } | 72 } |
73 | 73 |
74 protected: | 74 protected: |
75 ImageWriterOperationManagerTest() | 75 ImageWriterOperationManagerTest() |
76 : started_(false), | 76 : started_(false), |
77 start_success_(false) { | 77 start_success_(false) { |
78 } | 78 } |
79 | 79 |
80 virtual void SetUp() OVERRIDE { | 80 virtual void SetUp() override { |
81 ImageWriterUnitTestBase::SetUp(); | 81 ImageWriterUnitTestBase::SetUp(); |
82 extension_system_ = static_cast<FakeExtensionSystem*>( | 82 extension_system_ = static_cast<FakeExtensionSystem*>( |
83 ExtensionSystemFactory::GetInstance()-> | 83 ExtensionSystemFactory::GetInstance()-> |
84 SetTestingFactoryAndUse(&test_profile_, &BuildFakeExtensionSystem)); | 84 SetTestingFactoryAndUse(&test_profile_, &BuildFakeExtensionSystem)); |
85 event_router_ = static_cast<FakeEventRouter*>( | 85 event_router_ = static_cast<FakeEventRouter*>( |
86 extension_system_->event_router()); | 86 extension_system_->event_router()); |
87 } | 87 } |
88 | 88 |
89 bool started_; | 89 bool started_; |
90 bool start_success_; | 90 bool start_success_; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 EXPECT_TRUE(cancelled_); | 152 EXPECT_TRUE(cancelled_); |
153 EXPECT_TRUE(cancel_success_); | 153 EXPECT_TRUE(cancel_success_); |
154 EXPECT_EQ("", cancel_error_); | 154 EXPECT_EQ("", cancel_error_); |
155 | 155 |
156 base::RunLoop().RunUntilIdle(); | 156 base::RunLoop().RunUntilIdle(); |
157 } | 157 } |
158 | 158 |
159 } // namespace | 159 } // namespace |
160 } // namespace image_writer | 160 } // namespace image_writer |
161 } // namespace extensions | 161 } // namespace extensions |
OLD | NEW |