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

Unified Diff: dbus/message_unittest.cc

Issue 9700072: dbus: add support for passing file descriptors (Closed) Base URL: http://git.chromium.org/git/chromium/src@master
Patch Set: fix unit test to not run where fd-passing support is missing Created 8 years, 9 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: dbus/message_unittest.cc
diff --git a/dbus/message_unittest.cc b/dbus/message_unittest.cc
index a40ba0aa740f5538ec5b0c784020fa6587096616..4dfffc1b49aae06d474182db1b48be2bcd5b810d 100644
--- a/dbus/message_unittest.cc
+++ b/dbus/message_unittest.cc
@@ -40,7 +40,7 @@ TEST(MessageTest, AppendAndPopBasicDataTypes) {
scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty());
dbus::MessageWriter writer(message.get());
- // Append 0, 1, 2, 3, 4, 5, 6, 7, 8, "string", "/object/path".
+ // Append 0, 1, 2, 3, 4, 5, 6, 7, 8, "string", "/object/path", stdout.
satorux1 2012/03/28 20:49:37 nit: remove ", stdout"
Sam Leffler 2012/03/28 22:06:33 Done.
writer.AppendByte(0);
writer.AppendBool(true);
writer.AppendInt16(2);
@@ -94,6 +94,29 @@ TEST(MessageTest, AppendAndPopBasicDataTypes) {
EXPECT_EQ(dbus::ObjectPath("/object/path"), object_path_value);
}
+// Check all basic types can be properly written and read.
+TEST(MessageTest, AppendAndPopFileDescriptor) {
+ if (!dbus::kDBusTypeUnixFdIsSupported)
+ return;
satorux1 2012/03/28 20:49:37 Could you add some logging like if (!dbus::kDBusT
Sam Leffler 2012/03/28 22:06:33 Done.
+
+ scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty());
+ dbus::MessageWriter writer(message.get());
+
+ // Append stdout.
+ dbus::FileDescriptor temp(1);
+ writer.AppendFileDescriptor(temp);
+
+ dbus::FileDescriptor fd_value;
+
+ dbus::MessageReader reader(message.get());
+ ASSERT_TRUE(reader.HasMoreData());
+ ASSERT_TRUE(reader.PopFileDescriptor(&fd_value));
+ ASSERT_FALSE(reader.HasMoreData());
+
+ // stdout should be returned.
+ // TODO(sleffler) need to fstat each fd to compare
keybuk 2012/03/28 20:41:30 This should be trivial enough, fstat will get you
satorux1 2012/03/28 20:49:37 Why cannot we do EXPECT_EQ(1, fd_value.value())?
keybuk 2012/03/28 20:56:18 No, dbus calls dup() all over the place like crazy
satorux1 2012/03/28 21:09:32 Then, we need some comment about it. :)
Sam Leffler 2012/03/28 22:06:33 Implemented the test case. I used fstat calls whi
satorux1 2012/03/28 22:20:41 No need to worry about #ifdef. This only compiles
+}
+
// Check all variant types can be properly written and read.
TEST(MessageTest, AppendAndPopVariantDataTypes) {
scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty());

Powered by Google App Engine
This is Rietveld 408576698