OLD | NEW |
1 // Copyright (c) 2009 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 #include "base/file_descriptor_shuffle.h" | 5 #include "base/file_descriptor_shuffle.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 using base::InjectiveMultimap; | |
9 using base::InjectionArc; | |
10 using base::PerformInjectiveMultimap; | |
11 using base::InjectionDelegate; | |
12 | |
13 namespace { | 8 namespace { |
14 typedef testing::Test FileDescriptorShuffleTest; | |
15 } | |
16 | 9 |
17 // 'Duplicated' file descriptors start at this number | 10 // 'Duplicated' file descriptors start at this number |
18 static const int kDuplicateBase = 1000; | 11 const int kDuplicateBase = 1000; |
| 12 |
| 13 } // namespace |
| 14 |
| 15 namespace base { |
19 | 16 |
20 struct Action { | 17 struct Action { |
21 enum Type { | 18 enum Type { |
22 CLOSE, | 19 CLOSE, |
23 MOVE, | 20 MOVE, |
24 DUPLICATE, | 21 DUPLICATE, |
25 }; | 22 }; |
26 | 23 |
27 Action(Type in_type, int in_fd1, int in_fd2 = -1) | 24 Action(Type in_type, int in_fd1, int in_fd2 = -1) |
28 : type(in_type), | 25 : type(in_type), |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 EXPECT_TRUE(PerformInjectiveMultimap(map, &failing)); | 277 EXPECT_TRUE(PerformInjectiveMultimap(map, &failing)); |
281 } | 278 } |
282 | 279 |
283 TEST(FileDescriptorShuffleTest, Simple1WithFailure) { | 280 TEST(FileDescriptorShuffleTest, Simple1WithFailure) { |
284 InjectiveMultimap map; | 281 InjectiveMultimap map; |
285 FailingDelegate failing; | 282 FailingDelegate failing; |
286 map.push_back(InjectionArc(0, 1, false)); | 283 map.push_back(InjectionArc(0, 1, false)); |
287 | 284 |
288 EXPECT_FALSE(PerformInjectiveMultimap(map, &failing)); | 285 EXPECT_FALSE(PerformInjectiveMultimap(map, &failing)); |
289 } | 286 } |
| 287 |
| 288 } // namespace base |
OLD | NEW |