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

Unified Diff: ipc/ipc_message_attachment_set_posix_unittest.cc

Issue 2494943002: Remove IPC::BrokerableAttachment. (Closed)
Patch Set: extra test output Created 4 years, 1 month 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 | « ipc/ipc_message_attachment_set.cc ('k') | ipc/ipc_message_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_message_attachment_set_posix_unittest.cc
diff --git a/ipc/ipc_message_attachment_set_posix_unittest.cc b/ipc/ipc_message_attachment_set_posix_unittest.cc
index 5ebed84070ce3748485a231c040839ff9a5c7755..0bd143df4dee9eeb497599412d17803dcd05edb9 100644
--- a/ipc/ipc_message_attachment_set_posix_unittest.cc
+++ b/ipc/ipc_message_attachment_set_posix_unittest.cc
@@ -34,6 +34,12 @@ bool VerifyClosed(int fd) {
return true;
}
+int GetFdAt(MessageAttachmentSet* set, int id) {
+ return static_cast<internal::PlatformFileAttachment&>(
+ *set->GetAttachmentAt(id))
+ .TakePlatformFile();
+}
+
// The MessageAttachmentSet will try and close some of the descriptor numbers
// which we given it. This is the base descriptor value. It's great enough such
// that no real descriptor will accidently be closed.
@@ -82,44 +88,6 @@ TEST(MessageAttachmentSet, MaxSize) {
set->CommitAllDescriptors();
}
-#if defined(OS_ANDROID)
-#define MAYBE_SetDescriptors DISABLED_SetDescriptors
-#else
-#define MAYBE_SetDescriptors SetDescriptors
-#endif
-TEST(MessageAttachmentSet, MAYBE_SetDescriptors) {
- scoped_refptr<MessageAttachmentSet> set(new MessageAttachmentSet);
-
- ASSERT_TRUE(set->empty());
- set->AddDescriptorsToOwn(NULL, 0);
- ASSERT_TRUE(set->empty());
-
- const int fd = GetSafeFd();
- static const int fds[] = {fd};
- set->AddDescriptorsToOwn(fds, 1);
- ASSERT_TRUE(!set->empty());
- ASSERT_EQ(set->size(), 1u);
-
- set->CommitAllDescriptors();
-
- ASSERT_TRUE(VerifyClosed(fd));
-}
-
-TEST(MessageAttachmentSet, PeekDescriptors) {
- scoped_refptr<MessageAttachmentSet> set(new MessageAttachmentSet);
-
- set->PeekDescriptors(NULL);
- ASSERT_TRUE(
- set->AddAttachment(new internal::PlatformFileAttachment(kFDBase)));
-
- int fds[1];
- fds[0] = 0;
- set->PeekDescriptors(fds);
- ASSERT_EQ(fds[0], kFDBase);
- set->CommitAllDescriptors();
- ASSERT_TRUE(set->empty());
-}
-
TEST(MessageAttachmentSet, WalkInOrder) {
scoped_refptr<MessageAttachmentSet> set(new MessageAttachmentSet);
@@ -132,11 +100,9 @@ TEST(MessageAttachmentSet, WalkInOrder) {
ASSERT_TRUE(
set->AddAttachment(new internal::PlatformFileAttachment(kFDBase + 2)));
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(0)->TakePlatformFile(), kFDBase);
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(1)->TakePlatformFile(),
- kFDBase + 1);
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(2)->TakePlatformFile(),
- kFDBase + 2);
+ ASSERT_EQ(GetFdAt(set.get(), 0), kFDBase);
+ ASSERT_EQ(GetFdAt(set.get(), 1), kFDBase + 1);
+ ASSERT_EQ(GetFdAt(set.get(), 2), kFDBase + 2);
set->CommitAllDescriptors();
}
@@ -153,8 +119,8 @@ TEST(MessageAttachmentSet, WalkWrongOrder) {
ASSERT_TRUE(
set->AddAttachment(new internal::PlatformFileAttachment(kFDBase + 2)));
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(0)->TakePlatformFile(), kFDBase);
- ASSERT_FALSE(set->GetNonBrokerableAttachmentAt(2));
+ ASSERT_EQ(GetFdAt(set.get(), 0), kFDBase);
+ ASSERT_FALSE(set->GetAttachmentAt(2));
set->CommitAllDescriptors();
}
@@ -171,21 +137,15 @@ TEST(MessageAttachmentSet, WalkCycle) {
ASSERT_TRUE(
set->AddAttachment(new internal::PlatformFileAttachment(kFDBase + 2)));
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(0)->TakePlatformFile(), kFDBase);
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(1)->TakePlatformFile(),
- kFDBase + 1);
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(2)->TakePlatformFile(),
- kFDBase + 2);
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(0)->TakePlatformFile(), kFDBase);
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(1)->TakePlatformFile(),
- kFDBase + 1);
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(2)->TakePlatformFile(),
- kFDBase + 2);
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(0)->TakePlatformFile(), kFDBase);
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(1)->TakePlatformFile(),
- kFDBase + 1);
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(2)->TakePlatformFile(),
- kFDBase + 2);
+ ASSERT_EQ(GetFdAt(set.get(), 0), kFDBase);
+ ASSERT_EQ(GetFdAt(set.get(), 1), kFDBase + 1);
+ ASSERT_EQ(GetFdAt(set.get(), 2), kFDBase + 2);
+ ASSERT_EQ(GetFdAt(set.get(), 0), kFDBase);
+ ASSERT_EQ(GetFdAt(set.get(), 1), kFDBase + 1);
+ ASSERT_EQ(GetFdAt(set.get(), 2), kFDBase + 2);
+ ASSERT_EQ(GetFdAt(set.get(), 0), kFDBase);
+ ASSERT_EQ(GetFdAt(set.get(), 1), kFDBase + 1);
+ ASSERT_EQ(GetFdAt(set.get(), 2), kFDBase + 2);
set->CommitAllDescriptors();
}
« no previous file with comments | « ipc/ipc_message_attachment_set.cc ('k') | ipc/ipc_message_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698