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

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

Issue 6142009: Upating the app, ceee, chrome, ipc, media, and net directories to use the correct lock.h file. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Unified patch updating all references to the new base/synchronization/lock.h Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/mach_broker_mac.cc ('k') | chrome/browser/net/chrome_net_log.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/mach_broker_mac.h" 5 #include "chrome/browser/mach_broker_mac.h"
6 6
7 #include "base/lock.h" 7 #include "base/synchronization/lock.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 class MachBrokerTest : public testing::Test { 10 class MachBrokerTest : public testing::Test {
11 public: 11 public:
12 // Helper function to acquire/release locks and call |PlaceholderForPid()|. 12 // Helper function to acquire/release locks and call |PlaceholderForPid()|.
13 void AddPlaceholderForPid(base::ProcessHandle pid) { 13 void AddPlaceholderForPid(base::ProcessHandle pid) {
14 AutoLock lock(broker_.GetLock()); 14 base::AutoLock lock(broker_.GetLock());
15 broker_.AddPlaceholderForPid(pid); 15 broker_.AddPlaceholderForPid(pid);
16 } 16 }
17 17
18 // Helper function to acquire/release locks and call |FinalizePid()|. 18 // Helper function to acquire/release locks and call |FinalizePid()|.
19 void FinalizePid(base::ProcessHandle pid, 19 void FinalizePid(base::ProcessHandle pid,
20 const MachBroker::MachInfo& mach_info) { 20 const MachBroker::MachInfo& mach_info) {
21 AutoLock lock(broker_.GetLock()); 21 base::AutoLock lock(broker_.GetLock());
22 broker_.FinalizePid(pid, mach_info); 22 broker_.FinalizePid(pid, mach_info);
23 } 23 }
24 24
25 protected: 25 protected:
26 MachBroker broker_; 26 MachBroker broker_;
27 }; 27 };
28 28
29 TEST_F(MachBrokerTest, Locks) { 29 TEST_F(MachBrokerTest, Locks) {
30 // Acquire and release the locks. Nothing bad should happen. 30 // Acquire and release the locks. Nothing bad should happen.
31 AutoLock lock(broker_.GetLock()); 31 base::AutoLock lock(broker_.GetLock());
32 } 32 }
33 33
34 TEST_F(MachBrokerTest, AddPlaceholderAndFinalize) { 34 TEST_F(MachBrokerTest, AddPlaceholderAndFinalize) {
35 // Add a placeholder for PID 1. 35 // Add a placeholder for PID 1.
36 AddPlaceholderForPid(1); 36 AddPlaceholderForPid(1);
37 EXPECT_EQ(0u, broker_.TaskForPid(1)); 37 EXPECT_EQ(0u, broker_.TaskForPid(1));
38 38
39 // Finalize PID 1. 39 // Finalize PID 1.
40 FinalizePid(1, MachBroker::MachInfo().SetTask(100u)); 40 FinalizePid(1, MachBroker::MachInfo().SetTask(100u));
41 EXPECT_EQ(100u, broker_.TaskForPid(1)); 41 EXPECT_EQ(100u, broker_.TaskForPid(1));
42 42
43 // Should be no entry for PID 2. 43 // Should be no entry for PID 2.
44 EXPECT_EQ(0u, broker_.TaskForPid(2)); 44 EXPECT_EQ(0u, broker_.TaskForPid(2));
45 } 45 }
46 46
47 TEST_F(MachBrokerTest, Invalidate) { 47 TEST_F(MachBrokerTest, Invalidate) {
48 AddPlaceholderForPid(1); 48 AddPlaceholderForPid(1);
49 FinalizePid(1, MachBroker::MachInfo().SetTask(100u)); 49 FinalizePid(1, MachBroker::MachInfo().SetTask(100u));
50 50
51 EXPECT_EQ(100u, broker_.TaskForPid(1)); 51 EXPECT_EQ(100u, broker_.TaskForPid(1));
52 broker_.InvalidatePid(1u); 52 broker_.InvalidatePid(1u);
53 EXPECT_EQ(0u, broker_.TaskForPid(1)); 53 EXPECT_EQ(0u, broker_.TaskForPid(1));
54 } 54 }
55 55
56 TEST_F(MachBrokerTest, FinalizeUnknownPid) { 56 TEST_F(MachBrokerTest, FinalizeUnknownPid) {
57 // Finalizing an entry for an unknown pid should not add it to the map. 57 // Finalizing an entry for an unknown pid should not add it to the map.
58 FinalizePid(1u, MachBroker::MachInfo().SetTask(100u)); 58 FinalizePid(1u, MachBroker::MachInfo().SetTask(100u));
59 EXPECT_EQ(0u, broker_.TaskForPid(1u)); 59 EXPECT_EQ(0u, broker_.TaskForPid(1u));
60 } 60 }
OLDNEW
« no previous file with comments | « chrome/browser/mach_broker_mac.cc ('k') | chrome/browser/net/chrome_net_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698