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

Unified Diff: content/browser/file_descriptor_info_impl_unittest.cc

Issue 2950153002: Improve process launch handle sharing API. (Closed)
Patch Set: Merge Created 3 years, 5 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 | « content/browser/file_descriptor_info_impl.cc ('k') | content/browser/posix_file_descriptor_info_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/file_descriptor_info_impl_unittest.cc
diff --git a/content/browser/file_descriptor_info_impl_unittest.cc b/content/browser/file_descriptor_info_impl_unittest.cc
deleted file mode 100644
index 1d442f796820f283f47f83ac9c134c68f0e14bbe..0000000000000000000000000000000000000000
--- a/content/browser/file_descriptor_info_impl_unittest.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) 2012 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 "content/browser/file_descriptor_info_impl.h"
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <utility>
-
-#include "base/posix/eintr_wrapper.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-// Get a safe file descriptor for test purposes.
-// TODO(morrita) Merge with things in file_descriptor_set_posix_unittest.cc
-int GetSafeFd() {
- return open("/dev/null", O_RDONLY);
-}
-
-// Returns true if fd was already closed. Closes fd if not closed.
-// TODO(morrita) Merge with things in file_descriptor_set_posix_unittest.cc
-bool VerifyClosed(int fd) {
- const int duped = dup(fd);
- if (duped != -1) {
- EXPECT_NE(IGNORE_EINTR(close(duped)), -1);
- EXPECT_NE(IGNORE_EINTR(close(fd)), -1);
- return false;
- }
- return true;
-}
-
-} // namespace
-
-namespace content {
-
-typedef testing::Test FileDescriptorInfoTest;
-
-TEST_F(FileDescriptorInfoTest, Transfer) {
- int testingId = 42;
- std::unique_ptr<FileDescriptorInfo> target(FileDescriptorInfoImpl::Create());
- base::ScopedFD fd(GetSafeFd());
-
- int raw_fd = fd.get();
- target->Transfer(testingId, std::move(fd));
- ASSERT_EQ(1U, target->GetMappingSize());
- ASSERT_EQ(target->GetFDAt(0), raw_fd);
- ASSERT_EQ(target->GetIDAt(0), testingId);
-
- target.reset();
-
- ASSERT_TRUE(VerifyClosed(raw_fd));
-}
-
-TEST_F(FileDescriptorInfoTest, Share) {
- int testingId = 42;
- std::unique_ptr<FileDescriptorInfo> target(FileDescriptorInfoImpl::Create());
- base::ScopedFD fd(GetSafeFd());
-
- int raw_fd = fd.get();
- target->Share(testingId, fd.get());
- ASSERT_EQ(1U, target->GetMappingSize());
- ASSERT_EQ(target->GetFDAt(0), raw_fd);
- ASSERT_EQ(target->GetIDAt(0), testingId);
-
- target.reset();
-
- ASSERT_TRUE(!VerifyClosed(fd.release()));
-}
-
-TEST_F(FileDescriptorInfoTest, GetMappingWithIDAdjustment) {
- int testingId1 = 42;
- int testingId2 = 43;
- std::unique_ptr<FileDescriptorInfo> target(FileDescriptorInfoImpl::Create());
-
- target->Transfer(testingId1, base::ScopedFD(GetSafeFd()));
- target->Transfer(testingId2, base::ScopedFD(GetSafeFd()));
-
- std::unique_ptr<base::FileHandleMappingVector> mapping =
- target->GetMappingWithIDAdjustment(100);
- ASSERT_EQ((*mapping)[0].second, 142);
- ASSERT_EQ((*mapping)[1].second, 143);
-}
-
-} // namespace content
« no previous file with comments | « content/browser/file_descriptor_info_impl.cc ('k') | content/browser/posix_file_descriptor_info_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698