// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_TEST_TEST_CONNECTOR_FACTORY_H_ #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_TEST_TEST_CONNECTOR_FACTORY_H_ #include <map> #include <memory> #include <string> #include "base/token.h" #include "mojo/public/cpp/bindings/associated_receiver_set.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/mojom/connector.mojom.h" #include "services/service_manager/public/mojom/service_control.mojom.h" namespace service_manager { namespace mojom { class Service; } // namespace mojom // Creates Connector instances which route BindInterface requests directly to // manually registered Service implementations. Useful for testing production // code which is parameterized over a Connector, while bypassing all the // Service Manager machinery. Typical usage should look something like: // // TEST(MyTest, Foo) { // base::test::TaskEnvironment task_environment; // TestConnectorFactory connector_factory; // my_service::MyServiceImpl service(connector_factory.RegisterInstance( // my_service::mojom::kServiceName)); // // RunSomeClientCode(connector_factory.GetDefaultConnector()); // } // // Where |RunSomeClientCode()| would typically be some production code that // expects a functioning Connector and uses it to connect to the service you're // testing. class TestConnectorFactory : public mojom::ServiceControl { … }; } // namespace service_manager #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_TEST_TEST_CONNECTOR_FACTORY_H_