Index: services/resource_coordinator/resource_coordinator_service_unittest.cc |
diff --git a/services/resource_coordinator/resource_coordinator_service_unittest.cc b/services/resource_coordinator/resource_coordinator_service_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..46b830d6ab163d4efa90b8d57e42fec52a19707b |
--- /dev/null |
+++ b/services/resource_coordinator/resource_coordinator_service_unittest.cc |
@@ -0,0 +1,65 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <memory> |
+ |
+#include "base/macros.h" |
+#include "base/run_loop.h" |
+#include "mojo/public/cpp/bindings/binding.h" |
+#include "services/resource_coordinator/public/interfaces/coordination_unit_provider.mojom.h" |
+#include "services/resource_coordinator/public/interfaces/service_constants.mojom.h" |
+#include "services/service_manager/public/cpp/service.h" |
+#include "services/service_manager/public/cpp/service_test.h" |
+ |
+namespace resource_coordinator { |
+ |
+class ResourceCoordinatorTest : public service_manager::test::ServiceTest, |
+ public mojom::PolicyCallback { |
+ public: |
+ ResourceCoordinatorTest() |
+ : service_manager::test::ServiceTest("resource_coordinator_unittests"), |
+ binding_(this) {} |
+ ~ResourceCoordinatorTest() override {} |
+ |
+ protected: |
+ void SetUp() override { |
+ service_manager::test::ServiceTest::SetUp(); |
+ connector()->StartService(mojom::kServiceName); |
+ } |
+ |
+ mojom::PolicyCallbackPtr GetPolicyCallback() { |
+ return binding_.CreateInterfacePtrAndBind(); |
+ } |
+ |
+ void QuitOnPolicyCallback(base::RunLoop* loop) { loop_ = loop; } |
+ |
+ private: |
+ // mojom::PolicyCallback: |
+ void SetPolicy(resource_coordinator::mojom::PolicyPtr policy) override { |
+ loop_->Quit(); |
+ } |
+ |
+ mojo::Binding<mojom::PolicyCallback> binding_; |
+ base::RunLoop* loop_ = nullptr; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ResourceCoordinatorTest); |
+}; |
+ |
+TEST_F(ResourceCoordinatorTest, ResourceCoordinatorInstantiate) { |
+ mojom::CoordinationUnitProviderPtr provider; |
+ connector()->BindInterface(mojom::kServiceName, mojo::MakeRequest(&provider)); |
+ |
+ CoordinationUnitID new_id(CoordinationUnitType::WEBCONTENTS, "test_id"); |
+ mojom::CoordinationUnitPtr coordination_unit; |
+ provider->CreateCoordinationUnit(mojo::MakeRequest(&coordination_unit), |
+ new_id); |
+ |
+ coordination_unit->SetPolicyCallback(GetPolicyCallback()); |
+ |
+ base::RunLoop loop; |
+ QuitOnPolicyCallback(&loop); |
+ loop.Run(); |
+} |
+ |
+} // namespace resource_coordinator |