| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This test is POSIX only. | 5 // This test is POSIX only. |
| 6 | 6 |
| 7 #include "ipc/ipc_message_attachment_set.h" | 7 #include "ipc/ipc_message_attachment_set.h" |
| 8 | 8 |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // TODO(morrita): This test is wrong. TakeDescriptorAt() shouldn't be | 147 // TODO(morrita): This test is wrong. TakeDescriptorAt() shouldn't be |
| 148 // used to retrieve borrowed descriptors. That never happens in production. | 148 // used to retrieve borrowed descriptors. That never happens in production. |
| 149 ASSERT_TRUE( | 149 ASSERT_TRUE( |
| 150 set->AddAttachment(new internal::PlatformFileAttachment(kFDBase))); | 150 set->AddAttachment(new internal::PlatformFileAttachment(kFDBase))); |
| 151 ASSERT_TRUE( | 151 ASSERT_TRUE( |
| 152 set->AddAttachment(new internal::PlatformFileAttachment(kFDBase + 1))); | 152 set->AddAttachment(new internal::PlatformFileAttachment(kFDBase + 1))); |
| 153 ASSERT_TRUE( | 153 ASSERT_TRUE( |
| 154 set->AddAttachment(new internal::PlatformFileAttachment(kFDBase + 2))); | 154 set->AddAttachment(new internal::PlatformFileAttachment(kFDBase + 2))); |
| 155 | 155 |
| 156 ASSERT_EQ(set->GetNonBrokerableAttachmentAt(0)->TakePlatformFile(), kFDBase); | 156 ASSERT_EQ(set->GetNonBrokerableAttachmentAt(0)->TakePlatformFile(), kFDBase); |
| 157 ASSERT_EQ(set->GetNonBrokerableAttachmentAt(2), nullptr); | 157 ASSERT_FALSE(set->GetNonBrokerableAttachmentAt(2)); |
| 158 | 158 |
| 159 set->CommitAllDescriptors(); | 159 set->CommitAllDescriptors(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 TEST(MessageAttachmentSet, WalkCycle) { | 162 TEST(MessageAttachmentSet, WalkCycle) { |
| 163 scoped_refptr<MessageAttachmentSet> set(new MessageAttachmentSet); | 163 scoped_refptr<MessageAttachmentSet> set(new MessageAttachmentSet); |
| 164 | 164 |
| 165 // TODO(morrita): This test is wrong. TakeDescriptorAt() shouldn't be | 165 // TODO(morrita): This test is wrong. TakeDescriptorAt() shouldn't be |
| 166 // used to retrieve borrowed descriptors. That never happens in production. | 166 // used to retrieve borrowed descriptors. That never happens in production. |
| 167 ASSERT_TRUE( | 167 ASSERT_TRUE( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 const int fd = GetSafeFd(); | 211 const int fd = GetSafeFd(); |
| 212 ASSERT_TRUE(set->AddAttachment( | 212 ASSERT_TRUE(set->AddAttachment( |
| 213 new internal::PlatformFileAttachment(base::ScopedFD(fd)))); | 213 new internal::PlatformFileAttachment(base::ScopedFD(fd)))); |
| 214 set->CommitAllDescriptors(); | 214 set->CommitAllDescriptors(); |
| 215 | 215 |
| 216 ASSERT_TRUE(VerifyClosed(fd)); | 216 ASSERT_TRUE(VerifyClosed(fd)); |
| 217 } | 217 } |
| 218 | 218 |
| 219 } // namespace | 219 } // namespace |
| 220 } // namespace IPC | 220 } // namespace IPC |
| OLD | NEW |