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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // a process. The calls to SetProcessBackground should be noops then. | 169 // a process. The calls to SetProcessBackground should be noops then. |
170 TEST_F(ProcessTest, SetProcessBackgrounded) { | 170 TEST_F(ProcessTest, SetProcessBackgrounded) { |
171 Process process(SpawnChild("SimpleChildProcess")); | 171 Process process(SpawnChild("SimpleChildProcess")); |
172 int old_priority = process.GetPriority(); | 172 int old_priority = process.GetPriority(); |
173 #if defined(OS_WIN) | 173 #if defined(OS_WIN) |
174 EXPECT_TRUE(process.SetProcessBackgrounded(true)); | 174 EXPECT_TRUE(process.SetProcessBackgrounded(true)); |
175 EXPECT_TRUE(process.IsProcessBackgrounded()); | 175 EXPECT_TRUE(process.IsProcessBackgrounded()); |
176 EXPECT_TRUE(process.SetProcessBackgrounded(false)); | 176 EXPECT_TRUE(process.SetProcessBackgrounded(false)); |
177 EXPECT_FALSE(process.IsProcessBackgrounded()); | 177 EXPECT_FALSE(process.IsProcessBackgrounded()); |
178 #else | 178 #else |
179 process.SetProcessBackgrounded(true); | 179 if (process.CanBackgroundProcesses()) { |
180 process.SetProcessBackgrounded(false); | 180 process.SetProcessBackgrounded(true); |
| 181 process.SetProcessBackgrounded(false); |
| 182 } |
181 #endif | 183 #endif |
182 int new_priority = process.GetPriority(); | 184 int new_priority = process.GetPriority(); |
183 EXPECT_EQ(old_priority, new_priority); | 185 EXPECT_EQ(old_priority, new_priority); |
184 } | 186 } |
185 | 187 |
186 // Same as SetProcessBackgrounded but to this very process. It uses | 188 // Same as SetProcessBackgrounded but to this very process. It uses |
187 // a different code path at least for Windows. | 189 // a different code path at least for Windows. |
188 TEST_F(ProcessTest, SetProcessBackgroundedSelf) { | 190 TEST_F(ProcessTest, SetProcessBackgroundedSelf) { |
189 Process process = Process::Current(); | 191 Process process = Process::Current(); |
190 int old_priority = process.GetPriority(); | 192 int old_priority = process.GetPriority(); |
191 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
192 EXPECT_TRUE(process.SetProcessBackgrounded(true)); | 194 EXPECT_TRUE(process.SetProcessBackgrounded(true)); |
193 EXPECT_TRUE(process.IsProcessBackgrounded()); | 195 EXPECT_TRUE(process.IsProcessBackgrounded()); |
194 EXPECT_TRUE(process.SetProcessBackgrounded(false)); | 196 EXPECT_TRUE(process.SetProcessBackgrounded(false)); |
195 EXPECT_FALSE(process.IsProcessBackgrounded()); | 197 EXPECT_FALSE(process.IsProcessBackgrounded()); |
196 #else | 198 #else |
197 process.SetProcessBackgrounded(true); | 199 process.SetProcessBackgrounded(true); |
198 process.SetProcessBackgrounded(false); | 200 process.SetProcessBackgrounded(false); |
199 #endif | 201 #endif |
200 int new_priority = process.GetPriority(); | 202 int new_priority = process.GetPriority(); |
201 EXPECT_EQ(old_priority, new_priority); | 203 EXPECT_EQ(old_priority, new_priority); |
202 } | 204 } |
203 | 205 |
204 } // namespace base | 206 } // namespace base |
OLD | NEW |