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

Side by Side Diff: chrome/browser/process_singleton_posix_unittest.cc

Issue 2797293002: Use ScopedTaskEnvironment instead of MessageLoop in chrome unit tests. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/process_singleton.h" 5 #include "chrome/browser/process_singleton.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <limits.h> 8 #include <limits.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <stddef.h> 10 #include <stddef.h>
11 #include <sys/types.h> 11 #include <sys/types.h>
12 #include <sys/un.h> 12 #include <sys/un.h>
13 #include <sys/wait.h> 13 #include <sys/wait.h>
14 #include <unistd.h> 14 #include <unistd.h>
15 15
16 #include <memory> 16 #include <memory>
17 #include <string> 17 #include <string>
18 #include <vector> 18 #include <vector>
19 19
20 #include "base/bind.h" 20 #include "base/bind.h"
21 #include "base/command_line.h" 21 #include "base/command_line.h"
22 #include "base/files/file_path.h" 22 #include "base/files/file_path.h"
23 #include "base/files/file_util.h" 23 #include "base/files/file_util.h"
24 #include "base/files/scoped_temp_dir.h" 24 #include "base/files/scoped_temp_dir.h"
25 #include "base/location.h" 25 #include "base/location.h"
26 #include "base/posix/eintr_wrapper.h" 26 #include "base/posix/eintr_wrapper.h"
27 #include "base/single_thread_task_runner.h" 27 #include "base/single_thread_task_runner.h"
28 #include "base/strings/stringprintf.h" 28 #include "base/strings/stringprintf.h"
29 #include "base/synchronization/waitable_event.h" 29 #include "base/synchronization/waitable_event.h"
30 #include "base/test/scoped_task_environment.h"
30 #include "base/test/test_timeouts.h" 31 #include "base/test/test_timeouts.h"
31 #include "base/test/thread_test_helper.h" 32 #include "base/test/thread_test_helper.h"
32 #include "base/threading/thread.h" 33 #include "base/threading/thread.h"
33 #include "build/build_config.h" 34 #include "build/build_config.h"
34 #include "chrome/common/chrome_constants.h" 35 #include "chrome/common/chrome_constants.h"
35 #include "content/public/test/test_browser_thread.h" 36 #include "content/public/test/test_browser_thread.h"
36 #include "net/base/network_interfaces.h" 37 #include "net/base/network_interfaces.h"
37 #include "testing/gtest/include/gtest/gtest.h" 38 #include "testing/gtest/include/gtest/gtest.h"
38 39
39 using content::BrowserThread; 40 using content::BrowserThread;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 251
251 void DestructProcessSingleton() { 252 void DestructProcessSingleton() {
252 ASSERT_TRUE(process_singleton_on_thread_); 253 ASSERT_TRUE(process_singleton_on_thread_);
253 delete process_singleton_on_thread_; 254 delete process_singleton_on_thread_;
254 } 255 }
255 256
256 void KillCallback(int pid) { 257 void KillCallback(int pid) {
257 kill_callbacks_++; 258 kill_callbacks_++;
258 } 259 }
259 260
260 base::MessageLoop message_loop_; 261 base::test::ScopedTaskEnvironment scoped_task_environment_;
261 content::TestBrowserThread io_thread_; 262 content::TestBrowserThread io_thread_;
262 base::ScopedTempDir temp_dir_; 263 base::ScopedTempDir temp_dir_;
263 base::WaitableEvent wait_event_; 264 base::WaitableEvent wait_event_;
264 base::WaitableEvent signal_event_; 265 base::WaitableEvent signal_event_;
265 266
266 std::unique_ptr<base::Thread> worker_thread_; 267 std::unique_ptr<base::Thread> worker_thread_;
267 TestableProcessSingleton* process_singleton_on_thread_; 268 TestableProcessSingleton* process_singleton_on_thread_;
268 }; 269 };
269 270
270 } // namespace 271 } // namespace
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // Test that if there is an existing lock file, and it's not locked, we replace 428 // Test that if there is an existing lock file, and it's not locked, we replace
428 // it. 429 // it.
429 TEST_F(ProcessSingletonPosixTest, CreateReplacesOldMacLock) { 430 TEST_F(ProcessSingletonPosixTest, CreateReplacesOldMacLock) {
430 std::unique_ptr<TestableProcessSingleton> process_singleton( 431 std::unique_ptr<TestableProcessSingleton> process_singleton(
431 CreateProcessSingleton()); 432 CreateProcessSingleton());
432 EXPECT_EQ(0, base::WriteFile(lock_path_, "", 0)); 433 EXPECT_EQ(0, base::WriteFile(lock_path_, "", 0));
433 EXPECT_TRUE(process_singleton->Create()); 434 EXPECT_TRUE(process_singleton->Create());
434 VerifyFiles(); 435 VerifyFiles();
435 } 436 }
436 #endif // defined(OS_MACOSX) 437 #endif // defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698