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/public/cpp/service_test.h" | 5 #include "services/service_manager/public/cpp/service_test.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 initialize_userid_ = user_id; | 60 initialize_userid_ = user_id; |
61 initialize_called_.Run(); | 61 initialize_called_.Run(); |
62 } | 62 } |
63 | 63 |
64 void ServiceTest::SetUp() { | 64 void ServiceTest::SetUp() { |
65 message_loop_ = CreateMessageLoop(); | 65 message_loop_ = CreateMessageLoop(); |
66 | 66 |
67 DCHECK(!init_edk_); | 67 DCHECK(!init_edk_); |
68 | 68 |
69 background_service_manager_ = | 69 background_service_manager_ = |
70 base::MakeUnique<service_manager::BackgroundServiceManager>( | 70 base::MakeUnique<service_manager::BackgroundServiceManager>(nullptr, |
71 nullptr, nullptr); | 71 nullptr); |
72 | 72 |
73 // Create the service manager connection. We don't proceed until we get our | 73 // Create the service manager connection. We don't proceed until we get our |
74 // Service's OnStart() method is called. | 74 // Service's OnStart() method is called. |
75 base::RunLoop run_loop; | 75 base::RunLoop run_loop; |
76 base::MessageLoop::ScopedNestableTaskAllower allow( | 76 base::MessageLoop::ScopedNestableTaskAllower allow( |
77 base::MessageLoop::current()); | 77 base::MessageLoop::current()); |
78 initialize_called_ = run_loop.QuitClosure(); | 78 initialize_called_ = run_loop.QuitClosure(); |
79 | 79 |
80 mojom::ServicePtr service; | 80 mojom::ServicePtr service; |
81 context_ = base::MakeUnique<ServiceContext>(CreateService(), | 81 context_ = base::MakeUnique<ServiceContext>(CreateService(), |
82 mojom::ServiceRequest(&service)); | 82 mojom::ServiceRequest(&service)); |
83 background_service_manager_->RegisterService( | 83 background_service_manager_->RegisterService( |
84 Identity(test_name_, mojom::kRootUserID), std::move(service), nullptr); | 84 Identity(test_name_, mojom::kRootUserID), std::move(service), nullptr); |
85 connector_ = context_->connector(); | 85 connector_ = context_->connector(); |
86 run_loop.Run(); | 86 run_loop.Run(); |
87 } | 87 } |
88 | 88 |
89 void ServiceTest::TearDown() { | 89 void ServiceTest::TearDown() { |
90 background_service_manager_.reset(); | 90 background_service_manager_.reset(); |
91 context_.reset(); | 91 context_.reset(); |
92 message_loop_.reset(); | 92 message_loop_.reset(); |
93 } | 93 } |
94 | 94 |
95 } // namespace test | 95 } // namespace test |
96 } // namespace service_manager | 96 } // namespace service_manager |
OLD | NEW |