| 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_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_TEST_H_ | 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_TEST_H_ |
| 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_TEST_H_ | 6 #define SERVICES_SERVICE_MANAGER_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" |
| 11 #include "services/service_manager/public/cpp/connector.h" | 11 #include "services/service_manager/public/cpp/connector.h" |
| 12 #include "services/service_manager/public/cpp/service.h" | 12 #include "services/service_manager/public/cpp/service.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class MessageLoop; | 16 class MessageLoop; |
| 17 class Thread; | |
| 18 } | |
| 19 | |
| 20 namespace mojo { | |
| 21 namespace edk { | |
| 22 class ScopedIPCSupport; | |
| 23 } | |
| 24 } | 17 } |
| 25 | 18 |
| 26 namespace service_manager { | 19 namespace service_manager { |
| 27 | 20 |
| 28 class BackgroundServiceManager; | 21 class BackgroundServiceManager; |
| 29 class ServiceContext; | 22 class ServiceContext; |
| 30 | 23 |
| 31 namespace test { | 24 namespace test { |
| 32 | 25 |
| 33 class ServiceTest; | 26 class ServiceTest; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 52 DISALLOW_COPY_AND_ASSIGN(ServiceTestClient); | 45 DISALLOW_COPY_AND_ASSIGN(ServiceTestClient); |
| 53 }; | 46 }; |
| 54 | 47 |
| 55 class ServiceTest : public testing::Test { | 48 class ServiceTest : public testing::Test { |
| 56 public: | 49 public: |
| 57 ServiceTest(); | 50 ServiceTest(); |
| 58 // Initialize passing the name to use as the identity for the test itself. | 51 // Initialize passing the name to use as the identity for the test itself. |
| 59 // Once set via this constructor, it cannot be changed later by calling | 52 // Once set via this constructor, it cannot be changed later by calling |
| 60 // InitTestName(). The test executable must provide a manifest in the | 53 // InitTestName(). The test executable must provide a manifest in the |
| 61 // appropriate location that specifies this name also. | 54 // appropriate location that specifies this name also. |
| 62 explicit ServiceTest(const std::string& test_name, bool init_edk = false); | 55 explicit ServiceTest(const std::string& test_name, bool init_edk = true); |
| 63 ~ServiceTest() override; | 56 ~ServiceTest() override; |
| 64 | 57 |
| 65 protected: | 58 protected: |
| 66 // See constructor. Can only be called once. | 59 // See constructor. Can only be called once. |
| 67 void InitTestName(const std::string& test_name); | 60 void InitTestName(const std::string& test_name); |
| 68 | 61 |
| 69 Connector* connector() { return connector_; } | 62 Connector* connector() { return connector_; } |
| 70 | 63 |
| 71 // Instance information received from the Service Manager during OnStart(). | 64 // Instance information received from the Service Manager during OnStart(). |
| 72 const std::string& test_name() const { return initialize_name_; } | 65 const std::string& test_name() const { return initialize_name_; } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 93 private: | 86 private: |
| 94 friend ServiceTestClient; | 87 friend ServiceTestClient; |
| 95 | 88 |
| 96 std::unique_ptr<ServiceContext> context_; | 89 std::unique_ptr<ServiceContext> context_; |
| 97 std::unique_ptr<base::MessageLoop> message_loop_; | 90 std::unique_ptr<base::MessageLoop> message_loop_; |
| 98 std::unique_ptr<BackgroundServiceManager> background_service_manager_; | 91 std::unique_ptr<BackgroundServiceManager> background_service_manager_; |
| 99 | 92 |
| 100 // See constructor. | 93 // See constructor. |
| 101 std::string test_name_; | 94 std::string test_name_; |
| 102 bool init_edk_ = true; | 95 bool init_edk_ = true; |
| 103 std::unique_ptr<base::Thread> ipc_thread_; | |
| 104 std::unique_ptr<mojo::edk::ScopedIPCSupport> ipc_support_; | |
| 105 | 96 |
| 106 Connector* connector_ = nullptr; | 97 Connector* connector_ = nullptr; |
| 107 std::string initialize_name_; | 98 std::string initialize_name_; |
| 108 std::string initialize_userid_ = service_manager::mojom::kInheritUserID; | 99 std::string initialize_userid_ = service_manager::mojom::kInheritUserID; |
| 109 uint32_t initialize_instance_id_ = service_manager::mojom::kInvalidInstanceID; | 100 uint32_t initialize_instance_id_ = service_manager::mojom::kInvalidInstanceID; |
| 110 | 101 |
| 111 base::Closure initialize_called_; | 102 base::Closure initialize_called_; |
| 112 | 103 |
| 113 DISALLOW_COPY_AND_ASSIGN(ServiceTest); | 104 DISALLOW_COPY_AND_ASSIGN(ServiceTest); |
| 114 }; | 105 }; |
| 115 | 106 |
| 116 } // namespace test | 107 } // namespace test |
| 117 } // namespace service_manager | 108 } // namespace service_manager |
| 118 | 109 |
| 119 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_TEST_H_ | 110 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_TEST_H_ |
| OLD | NEW |