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

Side by Side Diff: chromeos/arc/bridge/arc_bridge_service_unittest.cc

Issue 1412863004: arc-bridge: Add the ARC Bridge Service (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Created 5 years, 2 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 "chromeos/arc/bridge/arc_bridge_service.h"
6
7 #include "base/memory/ref_counted.h"
8 #include "base/run_loop.h"
9 #include "ipc/ipc_channel.h"
10 #include "ipc/ipc_channel_proxy.h"
11 #include "testing/gmock/include/gmock/gmock.h"
satorux1 2015/10/23 06:10:58 gmock should generally be avoided in Chrome. Let's
Luis Héctor Chávez 2015/10/27 00:37:48 Done.
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 using testing::_;
15 using testing::Invoke;
16
17 namespace arc {
18
19 namespace {
20
21 class ArcBridgeInstanceEndpointStub : public BridgeInstanceEndpoint {
22 public:
23 ArcBridgeInstanceEndpointStub() {}
24
25 void OnRegisterInputDevice(const std::string& name,
26 const std::string& device_type,
27 base::FileDescriptor fd) {}
28
29 private:
30 DISALLOW_COPY_AND_ASSIGN(ArcBridgeInstanceEndpointStub);
31 };
32
33 class MockArcBridgeServiceObserver : public ArcBridgeService::Observer {
34 public:
35 MockArcBridgeServiceObserver() {}
36 ~MockArcBridgeServiceObserver() override {}
37
38 MOCK_METHOD1(OnInstanceStarted, void(bool));
39 MOCK_METHOD0(OnInstanceReady, void());
40 MOCK_METHOD0(OnInstanceStopped, void());
41 };
42
43 // Exercises the basic functionality of the ARC Bridge Service. A message from
44 // within the instance should cause the observer to be notified.
45 TEST(ArcBridgeTest, Basic) {
46 base::MessageLoopForUI message_loop;
47
48 MockArcBridgeServiceObserver observer;
49 EXPECT_CALL(observer, OnInstanceReady())
50 .Times(1)
51 .WillOnce(Invoke([&message_loop]() {
52 message_loop.PostTask(FROM_HERE, message_loop.QuitClosure());
53 }));
54
55 ArcBridgeInstanceEndpointStub instance_endpoint;
56 ArcBridgeService service(nullptr);
57 service.AddObserver(&observer);
58
59 std::string channel_name = IPC::Channel::GenerateUniqueRandomChannelID();
60 EXPECT_TRUE(service.Connect(IPC::ChannelHandle(channel_name),
61 IPC::Channel::MODE_SERVER));
62 EXPECT_TRUE(instance_endpoint.Connect(IPC::ChannelHandle(channel_name),
63 IPC::Channel::MODE_CLIENT));
64
65 EXPECT_TRUE(instance_endpoint.InstanceReady());
66
67 base::RunLoop run_loop;
68 run_loop.Run();
69 }
70
71 } // namespace
72
73 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698