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

Unified Diff: app/system_monitor_unittest.cc

Issue 431008: Make SystemMonitor not a Singleton and move it out of base (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: fix ChromeFrame build Created 11 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 side-by-side diff with in-line comments
Download patch
Index: app/system_monitor_unittest.cc
diff --git a/base/system_monitor_unittest.cc b/app/system_monitor_unittest.cc
similarity index 75%
rename from base/system_monitor_unittest.cc
rename to app/system_monitor_unittest.cc
index 7ba3a6b4f8590b23a588d83733d99f59ea925551..5b107aa03d45e7ea5950b288b37de3a0cc235451 100644
--- a/base/system_monitor_unittest.cc
+++ b/app/system_monitor_unittest.cc
@@ -2,16 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/system_monitor.h"
+#include "app/system_monitor.h"
#include "testing/gtest/include/gtest/gtest.h"
-class PowerTest : public base::SystemMonitor::PowerObserver {
+class PowerTest : public SystemMonitor::PowerObserver {
public:
PowerTest()
: battery_(false),
power_state_changes_(0),
suspends_(0),
- resumes_(0) {};
+ resumes_(0) {
+ }
// PowerObserver callbacks.
void OnPowerStateChange(bool on_battery_power) {
@@ -47,40 +48,40 @@ TEST(SystemMonitor, PowerNotifications) {
// Initialize time() since it registers as a SystemMonitor observer.
base::Time now = base::Time::Now();
- base::SystemMonitor* system_monitor = base::SystemMonitor::Get();
+ SystemMonitor system_monitor;
PowerTest test[kObservers];
for (int index = 0; index < kObservers; ++index)
- system_monitor->AddObserver(&test[index]);
+ system_monitor.AddObserver(&test[index]);
// Send a bunch of power changes. Since the battery power hasn't
// actually changed, we shouldn't get notifications.
for (int index = 0; index < 5; index++) {
- system_monitor->ProcessPowerMessage(base::SystemMonitor::POWER_STATE_EVENT);
+ system_monitor.ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT);
EXPECT_EQ(test[0].power_state_changes(), 0);
}
// Sending resume when not suspended should have no effect.
- system_monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
+ system_monitor.ProcessPowerMessage(SystemMonitor::RESUME_EVENT);
loop.RunAllPending();
EXPECT_EQ(test[0].resumes(), 0);
// Pretend we suspended.
- system_monitor->ProcessPowerMessage(base::SystemMonitor::SUSPEND_EVENT);
+ system_monitor.ProcessPowerMessage(SystemMonitor::SUSPEND_EVENT);
loop.RunAllPending();
EXPECT_EQ(test[0].suspends(), 1);
// Send a second suspend notification. This should be suppressed.
- system_monitor->ProcessPowerMessage(base::SystemMonitor::SUSPEND_EVENT);
+ system_monitor.ProcessPowerMessage(SystemMonitor::SUSPEND_EVENT);
loop.RunAllPending();
EXPECT_EQ(test[0].suspends(), 1);
// Pretend we were awakened.
- system_monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
+ system_monitor.ProcessPowerMessage(SystemMonitor::RESUME_EVENT);
loop.RunAllPending();
EXPECT_EQ(test[0].resumes(), 1);
// Send a duplicate resume notification. This should be suppressed.
- system_monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
+ system_monitor.ProcessPowerMessage(SystemMonitor::RESUME_EVENT);
loop.RunAllPending();
EXPECT_EQ(test[0].resumes(), 1);
}

Powered by Google App Engine
This is Rietveld 408576698