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

Side by Side Diff: services/test/service_unittest.cc

Issue 2829003005: Test service as minimum repro for sharing memory handle (Closed)
Patch Set: 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
« no previous file with comments | « services/test/service_manifest.json ('k') | services/test/service_unittest_manifest.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 "base/memory/ref_counted.h"
6 #include "base/run_loop.h"
7 #include "base/test/mock_callback.h"
8 #include "mojo/public/cpp/bindings/binding.h"
9 #include "services/service_manager/public/cpp/service_test.h"
10 #include "services/test/public/interfaces/service.mojom.h"
11 #include "testing/gmock/include/gmock/gmock.h"
12
13 using testing::Exactly;
14 using testing::_;
15 using testing::InvokeWithoutArgs;
16
17 namespace test {
18
19 class TestServiceTest : public service_manager::test::ServiceTest {
20 public:
21 TestServiceTest() : service_manager::test::ServiceTest("test_unittests") {}
22 ~TestServiceTest() override {}
23
24 void SetUp() override {
25 service_manager::test::ServiceTest::SetUp();
26 connector()->BindInterface("test", &service_);
27 }
28
29 protected:
30 mojom::ServicePtr service_;
31 };
32
33 class MockReceiver : public mojom::Receiver {
34 public:
35 MockReceiver(mojom::ReceiverRequest request)
36 : binding_(this, std::move(request)) {}
37 ~MockReceiver() override {}
38
39 // Use forwarding method to work around gmock not supporting move-only types.
40 void ReceiveBufferHandle(
41 mojo::ScopedSharedBufferHandle buffer_handle) override {
42 DoReceiveBufferHandle(&buffer_handle);
43 }
44
45 MOCK_METHOD1(DoReceiveBufferHandle, void(mojo::ScopedSharedBufferHandle*));
46
47 private:
48 const mojo::Binding<mojom::Receiver> binding_;
49 };
50
51 TEST_F(TestServiceTest, ReceiveTestBufferHandle) {
52 base::RunLoop wait_loop;
53 mojom::ReceiverPtr receiver_proxy;
54 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy));
55 EXPECT_CALL(receiver, DoReceiveBufferHandle(_))
56 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); }));
57 service_->ShareBufferToTestReceiver(std::move(receiver_proxy));
58 wait_loop.Run();
59 }
60
61 } // namespace test
OLDNEW
« no previous file with comments | « services/test/service_manifest.json ('k') | services/test/service_unittest_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698