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