OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <errno.h> | 5 #include <errno.h> |
6 #include <fcntl.h> | 6 #include <fcntl.h> |
7 #include <sys/file.h> | 7 #include <sys/file.h> |
8 | 8 |
9 #include "chrome/browser/process_singleton.h" | 9 #include "chrome/browser/process_singleton.h" |
10 | 10 |
11 #include "base/eintr_wrapper.h" | 11 #include "base/eintr_wrapper.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
16 #include "chrome/test/testing_profile.h" | 16 #include "chrome/test/testing_profile.h" |
17 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 class ProcessSingletonMacTest : public PlatformTest { | 21 class ProcessSingletonMacTest : public PlatformTest { |
22 public: | 22 public: |
23 virtual void SetUp() { | 23 virtual void SetUp() { |
24 PlatformTest::SetUp(); | 24 PlatformTest::SetUp(); |
25 | 25 |
26 // Put the lock in a temporary directory. Doesn't need to be a | 26 // Put the lock in a temporary directory. Doesn't need to be a |
27 // full profile to test this code. | 27 // full profile to test this code. |
28 temp_dir_.CreateUniqueTempDir(); | 28 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
29 ASSERT_TRUE(temp_dir_.IsValid()); | |
30 lock_path_ = temp_dir_.path().Append(chrome::kSingletonLockFilename); | 29 lock_path_ = temp_dir_.path().Append(chrome::kSingletonLockFilename); |
31 } | 30 } |
32 | 31 |
33 virtual void TearDown() { | 32 virtual void TearDown() { |
34 PlatformTest::TearDown(); | 33 PlatformTest::TearDown(); |
35 | 34 |
36 // Verify that the lock was released. | 35 // Verify that the lock was released. |
37 EXPECT_FALSE(IsLocked()); | 36 EXPECT_FALSE(IsLocked()); |
38 } | 37 } |
39 | 38 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 ps2.Cleanup(); | 139 ps2.Cleanup(); |
141 EXPECT_FALSE(IsLocked()); | 140 EXPECT_FALSE(IsLocked()); |
142 } | 141 } |
143 | 142 |
144 // TODO(shess): Test that the lock is released when the process dies. | 143 // TODO(shess): Test that the lock is released when the process dies. |
145 // DEATH_TEST? I don't know. If the code to communicate between | 144 // DEATH_TEST? I don't know. If the code to communicate between |
146 // browser processes is ever written, this all would need to be tested | 145 // browser processes is ever written, this all would need to be tested |
147 // more like the other platforms, in which case it would be easy. | 146 // more like the other platforms, in which case it would be easy. |
148 | 147 |
149 } // namespace | 148 } // namespace |
OLD | NEW |