| 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
" | 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" |
| 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/user_manager.h" | 16 #include "chrome/browser/chromeos/login/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 using testing::_; | |
| 25 using testing::Lt; | |
| 26 using testing::AnyNumber; | |
| 27 using testing::AtLeast; | |
| 28 | |
| 29 namespace { | |
| 30 | |
| 31 // 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 |
| 32 // the event router put the logic here. | 25 // the event router put the logic here. |
| 33 class FakeEventRouter : public extensions::EventRouter { | 26 class FakeEventRouter : public extensions::EventRouter { |
| 34 public: | 27 public: |
| 35 explicit FakeEventRouter(Profile* profile) : EventRouter(profile, NULL) {} | 28 explicit FakeEventRouter(Profile* profile) : EventRouter(profile, NULL) {} |
| 36 | 29 |
| 37 virtual void DispatchEventToExtension( | 30 virtual void DispatchEventToExtension( |
| 38 const std::string& extension_id, | 31 const std::string& extension_id, |
| 39 scoped_ptr<extensions::Event> event) OVERRIDE { | 32 scoped_ptr<extensions::Event> event) OVERRIDE { |
| 40 // Do nothing with the event as no tests currently care. | 33 // Do nothing with the event as no tests currently care. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 56 private: | 49 private: |
| 57 scoped_ptr<FakeEventRouter> fake_event_router_; | 50 scoped_ptr<FakeEventRouter> fake_event_router_; |
| 58 }; | 51 }; |
| 59 | 52 |
| 60 // Factory function to register for the ExtensionSystem. | 53 // Factory function to register for the ExtensionSystem. |
| 61 BrowserContextKeyedService* BuildFakeExtensionSystem( | 54 BrowserContextKeyedService* BuildFakeExtensionSystem( |
| 62 content::BrowserContext* profile) { | 55 content::BrowserContext* profile) { |
| 63 return new FakeExtensionSystem(static_cast<Profile*>(profile)); | 56 return new FakeExtensionSystem(static_cast<Profile*>(profile)); |
| 64 } | 57 } |
| 65 | 58 |
| 59 namespace { |
| 60 |
| 66 class ImageWriterOperationManagerTest | 61 class ImageWriterOperationManagerTest |
| 67 : public ImageWriterUnitTestBase { | 62 : public ImageWriterUnitTestBase { |
| 68 public: | 63 public: |
| 69 void StartCallback(bool success, const std::string& error) { | 64 void StartCallback(bool success, const std::string& error) { |
| 70 started_ = true; | 65 started_ = true; |
| 71 start_success_ = success; | 66 start_success_ = success; |
| 72 start_error_ = error; | 67 start_error_ = error; |
| 73 } | 68 } |
| 74 | 69 |
| 75 protected: | 70 protected: |
| 76 ImageWriterOperationManagerTest() | 71 ImageWriterOperationManagerTest() |
| 77 : started_(false), | 72 : started_(false), |
| 78 start_success_(false) {} | 73 start_success_(false) { |
| 74 } |
| 79 | 75 |
| 80 virtual void SetUp() OVERRIDE { | 76 virtual void SetUp() OVERRIDE { |
| 81 ImageWriterUnitTestBase::SetUp(); | 77 ImageWriterUnitTestBase::SetUp(); |
| 82 extension_system_ = static_cast<FakeExtensionSystem*>( | 78 extension_system_ = static_cast<FakeExtensionSystem*>( |
| 83 ExtensionSystemFactory::GetInstance()-> | 79 ExtensionSystemFactory::GetInstance()-> |
| 84 SetTestingFactoryAndUse(&test_profile_, &BuildFakeExtensionSystem)); | 80 SetTestingFactoryAndUse(&test_profile_, &BuildFakeExtensionSystem)); |
| 85 event_router_ = static_cast<FakeEventRouter*>( | 81 event_router_ = static_cast<FakeEventRouter*>( |
| 86 extension_system_->event_router()); | 82 extension_system_->event_router()); |
| 87 } | 83 } |
| 88 | 84 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 EXPECT_TRUE(started_); | 126 EXPECT_TRUE(started_); |
| 131 EXPECT_TRUE(start_success_); | 127 EXPECT_TRUE(start_success_); |
| 132 EXPECT_EQ("", start_error_); | 128 EXPECT_EQ("", start_error_); |
| 133 | 129 |
| 134 base::RunLoop().RunUntilIdle(); | 130 base::RunLoop().RunUntilIdle(); |
| 135 } | 131 } |
| 136 | 132 |
| 137 } // namespace | 133 } // namespace |
| 138 } // namespace image_writer | 134 } // namespace image_writer |
| 139 } // namespace extensions | 135 } // namespace extensions |
| OLD | NEW |