Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Unified Diff: services/resource_coordinator/resource_coordinator_service_unittest.cc

Issue 2798713002: Global Resource Coordinator: Basic service internals (Closed)
Patch Set: Wrap EventType directly in resource_coordinator namespace when using helper Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698