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

Side by Side 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 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::PolicyCallback {
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::PolicyCallbackPtr GetPolicyCallback() {
32 return binding_.CreateInterfacePtrAndBind();
33 }
34
35 void QuitOnPolicyCallback(base::RunLoop* loop) { loop_ = loop; }
36
37 private:
38 // mojom::PolicyCallback:
39 void SetPolicy(resource_coordinator::mojom::PolicyPtr policy) override {
40 loop_->Quit();
41 }
42
43 mojo::Binding<mojom::PolicyCallback> binding_;
44 base::RunLoop* loop_ = nullptr;
45
46 DISALLOW_COPY_AND_ASSIGN(ResourceCoordinatorTest);
47 };
48
49 TEST_F(ResourceCoordinatorTest, ResourceCoordinatorInstantiate) {
50 mojom::CoordinationUnitProviderPtr provider;
51 connector()->BindInterface(mojom::kServiceName, mojo::MakeRequest(&provider));
52
53 CoordinationUnitID new_id(CoordinationUnitType::WEBCONTENTS, "test_id");
54 mojom::CoordinationUnitPtr coordination_unit;
55 provider->CreateCoordinationUnit(mojo::MakeRequest(&coordination_unit),
56 new_id);
57
58 coordination_unit->SetPolicyCallback(GetPolicyCallback());
59
60 base::RunLoop loop;
61 QuitOnPolicyCallback(&loop);
62 loop.Run();
63 }
64
65 } // namespace resource_coordinator
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698