| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef SERVICES_SHELL_PUBLIC_CPP_SERVICE_TEST_H_ | 5 #ifndef SERVICES_SHELL_PUBLIC_CPP_SERVICE_TEST_H_ |
| 6 #define SERVICES_SHELL_PUBLIC_CPP_SERVICE_TEST_H_ | 6 #define SERVICES_SHELL_PUBLIC_CPP_SERVICE_TEST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // A default implementation of Service for use in ServiceTests. Tests wishing | 28 // A default implementation of Service for use in ServiceTests. Tests wishing |
| 29 // to customize this should subclass this class instead of Service, | 29 // to customize this should subclass this class instead of Service, |
| 30 // otherwise they will have to call ServiceTest::OnStartCalled() to forward | 30 // otherwise they will have to call ServiceTest::OnStartCalled() to forward |
| 31 // metadata from OnStart() to the test. | 31 // metadata from OnStart() to the test. |
| 32 class ServiceTestClient : public Service { | 32 class ServiceTestClient : public Service { |
| 33 public: | 33 public: |
| 34 explicit ServiceTestClient(ServiceTest* test); | 34 explicit ServiceTestClient(ServiceTest* test); |
| 35 ~ServiceTestClient() override; | 35 ~ServiceTestClient() override; |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 void OnStart(Connector* connector, | 38 void OnStart(const Identity& identity) override; |
| 39 const Identity& identity, | |
| 40 uint32_t id) override; | |
| 41 | 39 |
| 42 private: | 40 private: |
| 43 ServiceTest* test_; | 41 ServiceTest* test_; |
| 44 | 42 |
| 45 DISALLOW_COPY_AND_ASSIGN(ServiceTestClient); | 43 DISALLOW_COPY_AND_ASSIGN(ServiceTestClient); |
| 46 }; | 44 }; |
| 47 | 45 |
| 48 class ServiceTest : public testing::Test { | 46 class ServiceTest : public testing::Test { |
| 49 public: | 47 public: |
| 50 ServiceTest(); | 48 ServiceTest(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 70 // via OnStart(). Override to customize, but custom implementations must | 68 // via OnStart(). Override to customize, but custom implementations must |
| 71 // call OnStartCalled() to forward the metadata so test_name() etc all | 69 // call OnStartCalled() to forward the metadata so test_name() etc all |
| 72 // work. | 70 // work. |
| 73 virtual std::unique_ptr<Service> CreateService(); | 71 virtual std::unique_ptr<Service> CreateService(); |
| 74 | 72 |
| 75 virtual std::unique_ptr<base::MessageLoop> CreateMessageLoop(); | 73 virtual std::unique_ptr<base::MessageLoop> CreateMessageLoop(); |
| 76 | 74 |
| 77 // Call to set OnStart() metadata when GetService() is overridden. | 75 // Call to set OnStart() metadata when GetService() is overridden. |
| 78 void OnStartCalled(Connector* connector, | 76 void OnStartCalled(Connector* connector, |
| 79 const std::string& name, | 77 const std::string& name, |
| 80 const std::string& userid, | 78 const std::string& userid); |
| 81 uint32_t id); | |
| 82 | 79 |
| 83 // testing::Test: | 80 // testing::Test: |
| 84 void SetUp() override; | 81 void SetUp() override; |
| 85 void TearDown() override; | 82 void TearDown() override; |
| 86 | 83 |
| 87 private: | 84 private: |
| 88 friend ServiceTestClient; | 85 friend ServiceTestClient; |
| 89 | 86 |
| 90 std::unique_ptr<Service> service_; | 87 std::unique_ptr<Service> service_; |
| 91 | 88 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 103 | 100 |
| 104 base::Closure initialize_called_; | 101 base::Closure initialize_called_; |
| 105 | 102 |
| 106 DISALLOW_COPY_AND_ASSIGN(ServiceTest); | 103 DISALLOW_COPY_AND_ASSIGN(ServiceTest); |
| 107 }; | 104 }; |
| 108 | 105 |
| 109 } // namespace test | 106 } // namespace test |
| 110 } // namespace shell | 107 } // namespace shell |
| 111 | 108 |
| 112 #endif // SERVICES_SHELL_PUBLIC_CPP_SERVICE_TEST_H_ | 109 #endif // SERVICES_SHELL_PUBLIC_CPP_SERVICE_TEST_H_ |
| OLD | NEW |