Chromium Code Reviews| Index: extensions/test/service_registration_manager_test_api.h |
| diff --git a/extensions/test/service_registration_manager_test_api.h b/extensions/test/service_registration_manager_test_api.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7706dc2e1ef90f220bbfbd14b6d062309f561bfd |
| --- /dev/null |
| +++ b/extensions/test/service_registration_manager_test_api.h |
| @@ -0,0 +1,72 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef EXTENSIONS_TEST_SERVICE_REGISTRATION_MANAGER_TEST_API_H_ |
| +#define EXTENSIONS_TEST_SERVICE_REGISTRATION_MANAGER_TEST_API_H_ |
| + |
| +#include "extensions/browser/service_registration_manager.h" |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +namespace extensions { |
| +namespace internal { |
| + |
| +class TestServiceRegistrationManager : public ServiceRegistrationManager { |
| + public: |
| + TestServiceRegistrationManager(); |
| + ~TestServiceRegistrationManager(); |
| + |
| + // Overrides an existing service factory with |factory| for testing. This |
| + // does not alter the permission checks used to determine whether a service |
| + // is available. |
| + template <typename Interface> |
| + void OverrideServiceFactoryForTest( |
| + const base::Callback<void(mojo::InterfaceRequest<Interface>)>& factory) { |
| + bool inserted = |
| + test_factories_.insert(std::make_pair( |
| + Interface::Name_, |
| + linked_ptr<internal::ServiceFactoryBase>( |
| + new internal::ServiceFactory<Interface>( |
| + factory)))).second; |
|
raymes
2014/10/24 00:09:30
Please break this up a bit to reduce the indenting
Sam McNally
2014/10/24 03:55:56
Done.
|
| + DCHECK(inserted); |
| + } |
| + |
| + virtual void AddServiceToServiceRegistry( |
| + content::ServiceRegistry* service_registry, |
| + ServiceFactoryBase* service_factory) override; |
| + |
| + private: |
| + std::map<std::string, linked_ptr<ServiceFactoryBase>> test_factories_; |
| + |
| + ServiceRegistrationManager* service_registration_manager_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TestServiceRegistrationManager); |
| +}; |
| + |
| +} // namespace internal |
| + |
| +class ServiceRegistrationManagerTestApi { |
|
raymes
2014/10/24 00:09:30
Why not just expose TestServiceRegistrationManager
Sam McNally
2014/10/24 03:55:56
ServiceRegistrationManager isn't really part of th
raymes
2014/10/27 00:11:46
As discussed, let's get rid of this class and just
Sam McNally
2014/10/27 06:56:25
Done.
|
| + public: |
| + ServiceRegistrationManagerTestApi(); |
| + ~ServiceRegistrationManagerTestApi(); |
| + |
| + // Overrides an existing service factory with |factory| for testing. This |
| + // does not alter the permission checks used to determine whether a service |
| + // is available. |
| + template <typename Interface> |
| + void OverrideServiceFactoryForTest( |
| + const base::Callback<void(mojo::InterfaceRequest<Interface>)>& factory) { |
| + service_registration_manager_.OverrideServiceFactoryForTest(factory); |
| + } |
| + |
| + private: |
| + internal::TestServiceRegistrationManager service_registration_manager_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ServiceRegistrationManagerTestApi); |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // EXTENSIONS_TEST_SERVICE_REGISTRATION_MANAGER_TEST_API_H_ |