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

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

Issue 684613002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 <signal.h> 8 #include <signal.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <sys/un.h> 10 #include <sys/un.h>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 ProcessSingletonPosixTest() 65 ProcessSingletonPosixTest()
66 : kill_callbacks_(0), 66 : kill_callbacks_(0),
67 io_thread_(BrowserThread::IO), 67 io_thread_(BrowserThread::IO),
68 wait_event_(true, false), 68 wait_event_(true, false),
69 signal_event_(true, false), 69 signal_event_(true, false),
70 process_singleton_on_thread_(NULL) { 70 process_singleton_on_thread_(NULL) {
71 io_thread_.StartIOThread(); 71 io_thread_.StartIOThread();
72 } 72 }
73 73
74 virtual void SetUp() { 74 void SetUp() override {
75 testing::Test::SetUp(); 75 testing::Test::SetUp();
76 76
77 ProcessSingleton::DisablePromptForTesting(); 77 ProcessSingleton::DisablePromptForTesting();
78 // Put the lock in a temporary directory. Doesn't need to be a 78 // Put the lock in a temporary directory. Doesn't need to be a
79 // full profile to test this code. 79 // full profile to test this code.
80 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 80 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
81 // Use a long directory name to ensure that the socket isn't opened through 81 // Use a long directory name to ensure that the socket isn't opened through
82 // the symlink. 82 // the symlink.
83 user_data_path_ = temp_dir_.path().Append( 83 user_data_path_ = temp_dir_.path().Append(
84 std::string(sizeof(sockaddr_un::sun_path), 'a')); 84 std::string(sizeof(sockaddr_un::sun_path), 'a'));
85 ASSERT_TRUE(CreateDirectory(user_data_path_)); 85 ASSERT_TRUE(CreateDirectory(user_data_path_));
86 86
87 lock_path_ = user_data_path_.Append(chrome::kSingletonLockFilename); 87 lock_path_ = user_data_path_.Append(chrome::kSingletonLockFilename);
88 socket_path_ = user_data_path_.Append(chrome::kSingletonSocketFilename); 88 socket_path_ = user_data_path_.Append(chrome::kSingletonSocketFilename);
89 cookie_path_ = user_data_path_.Append(chrome::kSingletonCookieFilename); 89 cookie_path_ = user_data_path_.Append(chrome::kSingletonCookieFilename);
90 } 90 }
91 91
92 virtual void TearDown() { 92 void TearDown() override {
93 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper( 93 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper(
94 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get())); 94 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()));
95 ASSERT_TRUE(io_helper->Run()); 95 ASSERT_TRUE(io_helper->Run());
96 96
97 // Destruct the ProcessSingleton object before the IO thread so that its 97 // Destruct the ProcessSingleton object before the IO thread so that its
98 // internals are destructed properly. 98 // internals are destructed properly.
99 if (process_singleton_on_thread_) { 99 if (process_singleton_on_thread_) {
100 worker_thread_->message_loop()->PostTask( 100 worker_thread_->message_loop()->PostTask(
101 FROM_HERE, 101 FROM_HERE,
102 base::Bind(&ProcessSingletonPosixTest::DestructProcessSingleton, 102 base::Bind(&ProcessSingletonPosixTest::DestructProcessSingleton,
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // Test that if there is an existing lock file, and it's not locked, we replace 420 // Test that if there is an existing lock file, and it's not locked, we replace
421 // it. 421 // it.
422 TEST_F(ProcessSingletonPosixTest, CreateReplacesOldMacLock) { 422 TEST_F(ProcessSingletonPosixTest, CreateReplacesOldMacLock) {
423 scoped_ptr<TestableProcessSingleton> process_singleton( 423 scoped_ptr<TestableProcessSingleton> process_singleton(
424 CreateProcessSingleton()); 424 CreateProcessSingleton());
425 EXPECT_EQ(0, base::WriteFile(lock_path_, "", 0)); 425 EXPECT_EQ(0, base::WriteFile(lock_path_, "", 0));
426 EXPECT_TRUE(process_singleton->Create()); 426 EXPECT_TRUE(process_singleton->Create());
427 VerifyFiles(); 427 VerifyFiles();
428 } 428 }
429 #endif // defined(OS_MACOSX) 429 #endif // defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698