| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 <memory> | 5 #include <memory> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "services/resource_coordinator/coordination_unit/coordination_unit_impl
_unittest_util.h" |
| 11 #include "services/resource_coordinator/coordination_unit/coordination_unit_prov
ider_impl.h" | 12 #include "services/resource_coordinator/coordination_unit/coordination_unit_prov
ider_impl.h" |
| 12 #include "services/service_manager/public/cpp/service_context_ref.h" | 13 #include "services/service_manager/public/cpp/service_context_ref.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 namespace resource_coordinator { | 16 namespace resource_coordinator { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 void OnLastServiceRefDestroyed() { | 20 class CoordinationUnitImplTest : public CoordinationUnitImplTestBase {}; |
| 20 // No-op. This is required by service_manager::ServiceContextRefFactory | |
| 21 // construction but not needed for the tests. | |
| 22 } | |
| 23 | |
| 24 class CoordinationUnitImplTest : public testing::Test { | |
| 25 public: | |
| 26 CoordinationUnitImplTest() | |
| 27 : service_ref_factory_(base::Bind(&OnLastServiceRefDestroyed)), | |
| 28 provider_(&service_ref_factory_) {} | |
| 29 ~CoordinationUnitImplTest() override {} | |
| 30 | |
| 31 // testing::Test: | |
| 32 void TearDown() override { base::RunLoop().RunUntilIdle(); } | |
| 33 | |
| 34 protected: | |
| 35 CoordinationUnitProviderImpl* provider() { return &provider_; } | |
| 36 | |
| 37 private: | |
| 38 base::MessageLoop message_loop_; | |
| 39 | |
| 40 service_manager::ServiceContextRefFactory service_ref_factory_; | |
| 41 CoordinationUnitProviderImpl provider_; | |
| 42 }; | |
| 43 | 21 |
| 44 class TestCoordinationUnit : public mojom::CoordinationPolicyCallback { | 22 class TestCoordinationUnit : public mojom::CoordinationPolicyCallback { |
| 45 public: | 23 public: |
| 46 TestCoordinationUnit(CoordinationUnitProviderImpl* provider, | 24 TestCoordinationUnit(CoordinationUnitProviderImpl* provider, |
| 47 const CoordinationUnitType& type, | 25 const CoordinationUnitType& type, |
| 48 const std::string& id) | 26 const std::string& id) |
| 49 : binding_(this) { | 27 : binding_(this) { |
| 50 CHECK(provider); | 28 CHECK(provider); |
| 51 | 29 |
| 52 CoordinationUnitID new_cu_id(type, id); | 30 CoordinationUnitID new_cu_id(type, id); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 mojom::EventPtr event = mojom::Event::New(); | 165 mojom::EventPtr event = mojom::Event::New(); |
| 188 event->type = mojom::EventType::kTestEvent; | 166 event->type = mojom::EventType::kTestEvent; |
| 189 parent_unit.interface()->SendEvent(std::move(event)); | 167 parent_unit.interface()->SendEvent(std::move(event)); |
| 190 | 168 |
| 191 parent_callback.Run(); | 169 parent_callback.Run(); |
| 192 child_callback.Run(); | 170 child_callback.Run(); |
| 193 } | 171 } |
| 194 } | 172 } |
| 195 | 173 |
| 196 } // namespace resource_coordinator | 174 } // namespace resource_coordinator |
| OLD | NEW |