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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/arc/bridge/arc_bridge_service_unittest.cc
diff --git a/chromeos/arc/bridge/arc_bridge_service_unittest.cc b/chromeos/arc/bridge/arc_bridge_service_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..14fb4c4a8140bf35c4541bb3b25c4a4f6c1054eb
--- /dev/null
+++ b/chromeos/arc/bridge/arc_bridge_service_unittest.cc
@@ -0,0 +1,73 @@
+// 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 "chromeos/arc/bridge/arc_bridge_service.h"
+
+#include "base/memory/ref_counted.h"
+#include "base/run_loop.h"
+#include "ipc/ipc_channel.h"
+#include "ipc/ipc_channel_proxy.h"
+#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.
+#include "testing/gtest/include/gtest/gtest.h"
+
+using testing::_;
+using testing::Invoke;
+
+namespace arc {
+
+namespace {
+
+class ArcBridgeInstanceEndpointStub : public BridgeInstanceEndpoint {
+ public:
+ ArcBridgeInstanceEndpointStub() {}
+
+ void OnRegisterInputDevice(const std::string& name,
+ const std::string& device_type,
+ base::FileDescriptor fd) {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ArcBridgeInstanceEndpointStub);
+};
+
+class MockArcBridgeServiceObserver : public ArcBridgeService::Observer {
+ public:
+ MockArcBridgeServiceObserver() {}
+ ~MockArcBridgeServiceObserver() override {}
+
+ MOCK_METHOD1(OnInstanceStarted, void(bool));
+ MOCK_METHOD0(OnInstanceReady, void());
+ MOCK_METHOD0(OnInstanceStopped, void());
+};
+
+// Exercises the basic functionality of the ARC Bridge Service. A message from
+// within the instance should cause the observer to be notified.
+TEST(ArcBridgeTest, Basic) {
+ base::MessageLoopForUI message_loop;
+
+ MockArcBridgeServiceObserver observer;
+ EXPECT_CALL(observer, OnInstanceReady())
+ .Times(1)
+ .WillOnce(Invoke([&message_loop]() {
+ message_loop.PostTask(FROM_HERE, message_loop.QuitClosure());
+ }));
+
+ ArcBridgeInstanceEndpointStub instance_endpoint;
+ ArcBridgeService service(nullptr);
+ service.AddObserver(&observer);
+
+ std::string channel_name = IPC::Channel::GenerateUniqueRandomChannelID();
+ EXPECT_TRUE(service.Connect(IPC::ChannelHandle(channel_name),
+ IPC::Channel::MODE_SERVER));
+ EXPECT_TRUE(instance_endpoint.Connect(IPC::ChannelHandle(channel_name),
+ IPC::Channel::MODE_CLIENT));
+
+ EXPECT_TRUE(instance_endpoint.InstanceReady());
+
+ base::RunLoop run_loop;
+ run_loop.Run();
+}
+
+} // namespace
+
+} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698