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

Side by Side Diff: services/resource_coordinator/resource_coordinator_service_unittest.cc

Issue 2856173003: Revert of Global Resource Coordinator: Basic service internals (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <memory>
6
7 #include "base/macros.h"
8 #include "base/run_loop.h"
9 #include "mojo/public/cpp/bindings/binding.h"
10 #include "services/resource_coordinator/public/interfaces/coordination_unit_prov ider.mojom.h"
11 #include "services/resource_coordinator/public/interfaces/service_constants.mojo m.h"
12 #include "services/service_manager/public/cpp/service.h"
13 #include "services/service_manager/public/cpp/service_test.h"
14
15 namespace resource_coordinator {
16
17 class ResourceCoordinatorTest : public service_manager::test::ServiceTest,
18 public mojom::CoordinationPolicyCallback {
19 public:
20 ResourceCoordinatorTest()
21 : service_manager::test::ServiceTest("resource_coordinator_unittests"),
22 binding_(this) {}
23 ~ResourceCoordinatorTest() override {}
24
25 protected:
26 void SetUp() override {
27 service_manager::test::ServiceTest::SetUp();
28 connector()->StartService(mojom::kServiceName);
29 }
30
31 mojom::CoordinationPolicyCallbackPtr GetPolicyCallback() {
32 return binding_.CreateInterfacePtrAndBind();
33 }
34
35 void QuitOnPolicyCallback(base::RunLoop* loop) { loop_ = loop; }
36
37 private:
38 // mojom::CoordinationPolicyCallback:
39 void SetCoordinationPolicy(
40 resource_coordinator::mojom::CoordinationPolicyPtr policy) override {
41 loop_->Quit();
42 }
43
44 mojo::Binding<mojom::CoordinationPolicyCallback> binding_;
45 base::RunLoop* loop_ = nullptr;
46
47 DISALLOW_COPY_AND_ASSIGN(ResourceCoordinatorTest);
48 };
49
50 TEST_F(ResourceCoordinatorTest, ResourceCoordinatorInstantiate) {
51 mojom::CoordinationUnitProviderPtr provider;
52 connector()->BindInterface(mojom::kServiceName, mojo::MakeRequest(&provider));
53
54 CoordinationUnitID new_id(CoordinationUnitType::kWebContents, "test_id");
55 mojom::CoordinationUnitPtr coordination_unit;
56 provider->CreateCoordinationUnit(mojo::MakeRequest(&coordination_unit),
57 new_id);
58
59 coordination_unit->SetCoordinationPolicyCallback(GetPolicyCallback());
60
61 base::RunLoop loop;
62 QuitOnPolicyCallback(&loop);
63 loop.Run();
64 }
65
66 } // namespace resource_coordinator
OLDNEW
« no previous file with comments | « services/resource_coordinator/resource_coordinator_service.cc ('k') | services/resource_coordinator/service_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698