| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 static_cast<RemoteObject*>(result.get())->GetHandle()); | 277 static_cast<RemoteObject*>(result.get())->GetHandle()); |
| 278 | 278 |
| 279 EXPECT_FALSE(reader.HasMoreData()); | 279 EXPECT_FALSE(reader.HasMoreData()); |
| 280 } | 280 } |
| 281 | 281 |
| 282 TEST(BinderTransactionDataReadWriteTest, FileDescriptor) { | 282 TEST(BinderTransactionDataReadWriteTest, FileDescriptor) { |
| 283 // Prepare a test file. | 283 // Prepare a test file. |
| 284 base::ScopedTempDir temp_dir; | 284 base::ScopedTempDir temp_dir; |
| 285 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 285 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 286 base::FilePath path; | 286 base::FilePath path; |
| 287 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.path(), &path)); | 287 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.GetPath(), &path)); |
| 288 | 288 |
| 289 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ); | 289 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ); |
| 290 ASSERT_TRUE(file.IsValid()); | 290 ASSERT_TRUE(file.IsValid()); |
| 291 | 291 |
| 292 base::ScopedFD scoped_fd(file.TakePlatformFile()); | 292 base::ScopedFD scoped_fd(file.TakePlatformFile()); |
| 293 int kFdValue = scoped_fd.get(); | 293 int kFdValue = scoped_fd.get(); |
| 294 | 294 |
| 295 // Write the file descriptor. | 295 // Write the file descriptor. |
| 296 WritableTransactionData data; | 296 WritableTransactionData data; |
| 297 data.WriteFileDescriptor(std::move(scoped_fd)); | 297 data.WriteFileDescriptor(std::move(scoped_fd)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 309 EXPECT_EQ(kFdValue, result.handle); | 309 EXPECT_EQ(kFdValue, result.handle); |
| 310 } | 310 } |
| 311 // Read the file descriptor. | 311 // Read the file descriptor. |
| 312 TransactionDataReader reader(data); | 312 TransactionDataReader reader(data); |
| 313 int result = -1; | 313 int result = -1; |
| 314 EXPECT_TRUE(reader.ReadFileDescriptor(&result)); | 314 EXPECT_TRUE(reader.ReadFileDescriptor(&result)); |
| 315 EXPECT_EQ(kFdValue, result); | 315 EXPECT_EQ(kFdValue, result); |
| 316 } | 316 } |
| 317 | 317 |
| 318 } // namespace binder | 318 } // namespace binder |
| OLD | NEW |