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

Side by Side Diff: base/system_monitor/system_monitor_unittest.cc

Issue 7529003: Make base::MessageLoops have names at construction time (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add name argument to MessageLoop Created 9 years, 4 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/system_monitor/system_monitor.h" 5 #include "base/system_monitor/system_monitor.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace base { 8 namespace base {
9 9
10 class PowerTest : public SystemMonitor::PowerObserver { 10 class PowerTest : public SystemMonitor::PowerObserver {
(...skipping 28 matching lines...) Expand all
39 bool battery_; // Do we currently think we're on battery power. 39 bool battery_; // Do we currently think we're on battery power.
40 int power_state_changes_; // Count of OnPowerStateChange notifications. 40 int power_state_changes_; // Count of OnPowerStateChange notifications.
41 int suspends_; // Count of OnSuspend notifications. 41 int suspends_; // Count of OnSuspend notifications.
42 int resumes_; // Count of OnResume notifications. 42 int resumes_; // Count of OnResume notifications.
43 }; 43 };
44 44
45 TEST(SystemMonitor, PowerNotifications) { 45 TEST(SystemMonitor, PowerNotifications) {
46 const int kObservers = 5; 46 const int kObservers = 5;
47 47
48 // Initialize a message loop for this to run on. 48 // Initialize a message loop for this to run on.
49 MessageLoop loop; 49 MessageLoop loop("SystemMonitor");
50 50
51 #if defined(OS_MACOSX) 51 #if defined(OS_MACOSX)
52 SystemMonitor::AllocateSystemIOPorts(); 52 SystemMonitor::AllocateSystemIOPorts();
53 #endif 53 #endif
54 54
55 SystemMonitor system_monitor; 55 SystemMonitor system_monitor;
56 PowerTest test[kObservers]; 56 PowerTest test[kObservers];
57 for (int index = 0; index < kObservers; ++index) 57 for (int index = 0; index < kObservers; ++index)
58 system_monitor.AddObserver(&test[index]); 58 system_monitor.AddObserver(&test[index]);
59 59
(...skipping 24 matching lines...) Expand all
84 loop.RunAllPending(); 84 loop.RunAllPending();
85 EXPECT_EQ(test[0].resumes(), 1); 85 EXPECT_EQ(test[0].resumes(), 1);
86 86
87 // Send a duplicate resume notification. This should be suppressed. 87 // Send a duplicate resume notification. This should be suppressed.
88 system_monitor.ProcessPowerMessage(SystemMonitor::RESUME_EVENT); 88 system_monitor.ProcessPowerMessage(SystemMonitor::RESUME_EVENT);
89 loop.RunAllPending(); 89 loop.RunAllPending();
90 EXPECT_EQ(test[0].resumes(), 1); 90 EXPECT_EQ(test[0].resumes(), 1);
91 } 91 }
92 92
93 } // namespace base 93 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698