OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/process/process.h" | 5 #include "base/process/process.h" |
6 | 6 |
7 #include "base/process/kill.h" | 7 #include "base/process/kill.h" |
8 #include "base/test/multiprocess_test.h" | 8 #include "base/test/multiprocess_test.h" |
9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 ASSERT_TRUE(process1.IsValid()); | 85 ASSERT_TRUE(process1.IsValid()); |
86 ASSERT_TRUE(process2.IsValid()); | 86 ASSERT_TRUE(process2.IsValid()); |
87 EXPECT_EQ(process1.pid(), process2.pid()); | 87 EXPECT_EQ(process1.pid(), process2.pid()); |
88 EXPECT_TRUE(process1.is_current()); | 88 EXPECT_TRUE(process1.is_current()); |
89 EXPECT_TRUE(process2.is_current()); | 89 EXPECT_TRUE(process2.is_current()); |
90 | 90 |
91 process1.Close(); | 91 process1.Close(); |
92 ASSERT_TRUE(process2.IsValid()); | 92 ASSERT_TRUE(process2.IsValid()); |
93 } | 93 } |
94 | 94 |
| 95 TEST_F(ProcessTest, DeprecatedGetProcessFromHandle) { |
| 96 Process process1(SpawnChild("SimpleChildProcess")); |
| 97 ASSERT_TRUE(process1.IsValid()); |
| 98 |
| 99 Process process2 = Process::DeprecatedGetProcessFromHandle(process1.Handle()); |
| 100 ASSERT_TRUE(process1.IsValid()); |
| 101 ASSERT_TRUE(process2.IsValid()); |
| 102 EXPECT_EQ(process1.pid(), process2.pid()); |
| 103 EXPECT_FALSE(process1.is_current()); |
| 104 EXPECT_FALSE(process2.is_current()); |
| 105 |
| 106 process1.Close(); |
| 107 ASSERT_TRUE(process2.IsValid()); |
| 108 } |
| 109 |
95 MULTIPROCESS_TEST_MAIN(SleepyChildProcess) { | 110 MULTIPROCESS_TEST_MAIN(SleepyChildProcess) { |
96 PlatformThread::Sleep(TestTimeouts::action_max_timeout()); | 111 PlatformThread::Sleep(TestTimeouts::action_max_timeout()); |
97 return 0; | 112 return 0; |
98 } | 113 } |
99 | 114 |
100 TEST_F(ProcessTest, Terminate) { | 115 TEST_F(ProcessTest, Terminate) { |
101 Process process(SpawnChild("SleepyChildProcess")); | 116 Process process(SpawnChild("SleepyChildProcess")); |
102 ASSERT_TRUE(process.IsValid()); | 117 ASSERT_TRUE(process.IsValid()); |
103 | 118 |
104 const int kDummyExitCode = 42; | 119 const int kDummyExitCode = 42; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 EXPECT_FALSE(process.IsProcessBackgrounded()); | 167 EXPECT_FALSE(process.IsProcessBackgrounded()); |
153 #else | 168 #else |
154 process.SetProcessBackgrounded(true); | 169 process.SetProcessBackgrounded(true); |
155 process.SetProcessBackgrounded(false); | 170 process.SetProcessBackgrounded(false); |
156 #endif | 171 #endif |
157 int new_priority = process.GetPriority(); | 172 int new_priority = process.GetPriority(); |
158 EXPECT_EQ(old_priority, new_priority); | 173 EXPECT_EQ(old_priority, new_priority); |
159 } | 174 } |
160 | 175 |
161 } // namespace base | 176 } // namespace base |
OLD | NEW |