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

Unified Diff: components/mus/gpu/gpu_type_converters_unittest.cc

Issue 1923593003: Add mus::mojom::ChannelHandle for passing IPC::ChannelHandle via mojo IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/mus/gpu/gpu_type_converters.cc ('k') | components/mus/gpu/mus_gpu_unittests_app_manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/gpu/gpu_type_converters_unittest.cc
diff --git a/components/mus/gpu/gpu_type_converters_unittest.cc b/components/mus/gpu/gpu_type_converters_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..14722dcd8af65ad73b29aab7f105e6892016e754
--- /dev/null
+++ b/components/mus/gpu/gpu_type_converters_unittest.cc
@@ -0,0 +1,57 @@
+// Copyright 2016 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 <string>
+
+#include "base/files/scoped_file.h"
+#include "components/mus/gpu/gpu_type_converters.h"
+#include "build/build_config.h"
+#include "ipc/ipc_channel.h"
+#include "ipc/ipc_channel_handle.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// Test for mojo TypeConverter of mus::mojom::ChannelHandle.
+TEST(MusGpuTypeConvertersTest, ChannelHandle) {
+ {
+ const std::string channel_name = "test_channel_name";
+ IPC::ChannelHandle handle(channel_name);
+
+ mus::mojom::ChannelHandlePtr mojo_handle =
+ mus::mojom::ChannelHandle::From(handle);
+ ASSERT_EQ(mojo_handle->name, channel_name);
+ EXPECT_FALSE(mojo_handle->socket.is_valid());
+
+ handle = mojo_handle.To<IPC::ChannelHandle>();
+ ASSERT_EQ(handle.name, channel_name);
+#if defined(OS_POSIX)
+ ASSERT_EQ(handle.socket.fd, -1);
+#endif
+ }
+
+#if defined(OS_POSIX)
+ {
+ const std::string channel_name = "test_channel_name";
+ int fd1 = -1;
+ int fd2 = -1;
+ bool result = IPC::SocketPair(&fd1, &fd2);
+ EXPECT_TRUE(result);
+
+ base::ScopedFD scoped_fd1(fd1);
+ base::ScopedFD scoped_fd2(fd2);
+ IPC::ChannelHandle handle(channel_name,
+ base::FileDescriptor(scoped_fd1.get(), false));
+
+ mus::mojom::ChannelHandlePtr mojo_handle =
+ mus::mojom::ChannelHandle::From(handle);
+ ASSERT_EQ(mojo_handle->name, channel_name);
+ EXPECT_TRUE(mojo_handle->socket.is_valid());
+
+ handle = mojo_handle.To<IPC::ChannelHandle>();
+ ASSERT_EQ(handle.name, channel_name);
+ ASSERT_NE(handle.socket.fd, -1);
+ EXPECT_TRUE(handle.socket.auto_close);
+ base::ScopedFD socped_fd3(handle.socket.fd);
+ }
+#endif
+}
« no previous file with comments | « components/mus/gpu/gpu_type_converters.cc ('k') | components/mus/gpu/mus_gpu_unittests_app_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698