| 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 <utility> |
| 6 #include <vector> | 7 #include <vector> |
| 7 | 8 |
| 8 #include "base/bind.h" | 9 #include "base/bind.h" |
| 9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #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" | 13 #include "services/resource_coordinator/coordination_unit/coordination_unit_prov
ider_impl.h" |
| 12 #include "services/service_manager/public/cpp/service_context_ref.h" | 14 #include "services/service_manager/public/cpp/service_context_ref.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 16 |
| 15 namespace resource_coordinator { | 17 namespace resource_coordinator { |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 void OnLastServiceRefDestroyed() { | 21 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 | 22 |
| 44 class TestCoordinationUnit : public mojom::CoordinationPolicyCallback { | 23 class TestCoordinationUnit : public mojom::CoordinationPolicyCallback { |
| 45 public: | 24 public: |
| 46 TestCoordinationUnit(CoordinationUnitProviderImpl* provider, | 25 TestCoordinationUnit(CoordinationUnitProviderImpl* provider, |
| 47 const CoordinationUnitType& type, | 26 const CoordinationUnitType& type, |
| 48 const std::string& id) | 27 const std::string& id) |
| 49 : binding_(this) { | 28 : binding_(this) { |
| 50 CHECK(provider); | 29 CHECK(provider); |
| 51 | 30 |
| 52 CoordinationUnitID new_cu_id(type, id); | 31 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(); | 166 mojom::EventPtr event = mojom::Event::New(); |
| 188 event->type = mojom::EventType::kTestEvent; | 167 event->type = mojom::EventType::kTestEvent; |
| 189 parent_unit.interface()->SendEvent(std::move(event)); | 168 parent_unit.interface()->SendEvent(std::move(event)); |
| 190 | 169 |
| 191 parent_callback.Run(); | 170 parent_callback.Run(); |
| 192 child_callback.Run(); | 171 child_callback.Run(); |
| 193 } | 172 } |
| 194 } | 173 } |
| 195 | 174 |
| 196 } // namespace resource_coordinator | 175 } // namespace resource_coordinator |
| OLD | NEW |