| 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 #include "services/service_manager/background/background_service_manager.h" | 5 #include "services/service_manager/background/background_service_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "services/service_manager/background/tests/test.mojom.h" | 12 #include "services/service_manager/background/tests/test.mojom.h" |
| 13 #include "services/service_manager/public/cpp/connector.h" | 13 #include "services/service_manager/public/cpp/connector.h" |
| 14 #include "services/service_manager/public/cpp/service.h" | 14 #include "services/service_manager/public/cpp/service.h" |
| 15 #include "services/service_manager/public/cpp/service_context.h" | 15 #include "services/service_manager/public/cpp/service_context.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace service_manager { | 18 namespace service_manager { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const char kTestName[] = "background_service_manager_unittest"; | 21 const char kTestName[] = "background_service_manager_unittest"; |
| 22 const char kAppName[] = "background_service_manager_test_service"; | 22 const char kAppName[] = "background_service_manager_test_service"; |
| 23 | 23 |
| 24 // The parent unit test suite service, not the underlying test service. | 24 // The parent unit test suite service, not the underlying test service. |
| 25 class ServiceImpl : public Service { | 25 class ServiceImpl : public Service { |
| 26 public: | 26 public: |
| 27 ServiceImpl() {} | 27 ServiceImpl() {} |
| 28 ~ServiceImpl() override {} | 28 ~ServiceImpl() override {} |
| 29 | 29 |
| 30 // Service: | |
| 31 bool OnConnect(const ServiceInfo& remote_info, | |
| 32 InterfaceRegistry* registry) override { | |
| 33 return false; | |
| 34 } | |
| 35 | |
| 36 private: | 30 private: |
| 37 DISALLOW_COPY_AND_ASSIGN(ServiceImpl); | 31 DISALLOW_COPY_AND_ASSIGN(ServiceImpl); |
| 38 }; | 32 }; |
| 39 | 33 |
| 40 void SetFlagAndRunClosure(bool* flag, const base::Closure& closure) { | 34 void SetFlagAndRunClosure(bool* flag, const base::Closure& closure) { |
| 41 *flag = true; | 35 *flag = true; |
| 42 closure.Run(); | 36 closure.Run(); |
| 43 } | 37 } |
| 44 | 38 |
| 45 // Uses BackgroundServiceManager to start the service manager in the background | 39 // Uses BackgroundServiceManager to start the service manager in the background |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // Ask the service to quit itself. | 96 // Ask the service to quit itself. |
| 103 test_service->Quit(); | 97 test_service->Quit(); |
| 104 run_loop.Run(); | 98 run_loop.Run(); |
| 105 | 99 |
| 106 // The run loop was quit by the callback and not by something else. | 100 // The run loop was quit by the callback and not by something else. |
| 107 EXPECT_TRUE(callback_called); | 101 EXPECT_TRUE(callback_called); |
| 108 } | 102 } |
| 109 | 103 |
| 110 } // namespace | 104 } // namespace |
| 111 } // namespace service_manager | 105 } // namespace service_manager |
| OLD | NEW |