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

Unified Diff: unclean_shutdown_collector_test.cc

Issue 3644007: Crash reporter: collect suspend and resume info from power manager (Closed) Base URL: http://git.chromium.org/git/crash-reporter.git
Patch Set: Reorganized deletions, added unit tests Created 10 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
« unclean_shutdown_collector.cc ('K') | « unclean_shutdown_collector.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: unclean_shutdown_collector_test.cc
diff --git a/unclean_shutdown_collector_test.cc b/unclean_shutdown_collector_test.cc
index 7be52af146db6faaeae8bae48be92aa814f92661..485ae345b037fe6ec3482e438e8ffeb894fbc8e3 100644
--- a/unclean_shutdown_collector_test.cc
+++ b/unclean_shutdown_collector_test.cc
@@ -15,6 +15,8 @@ static int s_crashes = 0;
static bool s_metrics = false;
static const char kTestUnclean[] = "test/unclean";
+static const char kTestSuspended[] = "test/suspended";
+static const char kTestLowBattery[] = "test/low_battery";
kmixter1 2010/11/23 23:18:01 nit: abc order unless there's a specific reason no
void CountCrash() {
++s_crashes;
@@ -34,6 +36,9 @@ class UncleanShutdownCollectorTest : public ::testing::Test {
test_unclean_ = FilePath(kTestUnclean);
collector_.unclean_shutdown_file_ = kTestUnclean;
file_util::Delete(test_unclean_, true);
+ // Set up alternate power manager tracing files as well
+ collector_.powerd_suspended_file_ = FilePath(kTestSuspended);
+ collector_.powerd_low_battery_file_ = FilePath(kTestLowBattery);
}
protected:
void WriteStringToFile(const FilePath &file_path,
@@ -78,6 +83,29 @@ TEST_F(UncleanShutdownCollectorTest, CollectFalse) {
ASSERT_FALSE(collector_.Collect());
}
+TEST_F(UncleanShutdownCollectorTest, CollectDeadBatteryRunningLow) {
+ ASSERT_TRUE(collector_.Enable());
+ ASSERT_TRUE(file_util::PathExists(test_unclean_));
+ file_util::WriteFile(collector_.powerd_low_battery_file_, "", 0);
+ ASSERT_TRUE(collector_.Collect());
kmixter1 2010/11/23 23:18:01 Should return false.
+ ASSERT_FALSE(file_util::PathExists(test_unclean_));
+ ASSERT_FALSE(file_util::PathExists(collector_.powerd_low_battery_file_));
+ ASSERT_NE(std::string::npos,
+ logging_.log().find("Unclean shutdown occurred while running with "
+ "battery critically low"));
kmixter1 2010/11/23 23:18:01 nit: search for ending '.' like you do in the othe
+}
+
+TEST_F(UncleanShutdownCollectorTest, CollectDeadBatterySuspended) {
+ ASSERT_TRUE(collector_.Enable());
+ ASSERT_TRUE(file_util::PathExists(test_unclean_));
+ file_util::WriteFile(collector_.powerd_suspended_file_, "", 0);
+ ASSERT_TRUE(collector_.Collect());
kmixter1 2010/11/23 23:18:01 Should return false.
+ ASSERT_FALSE(file_util::PathExists(test_unclean_));
+ ASSERT_FALSE(file_util::PathExists(collector_.powerd_suspended_file_));
+ ASSERT_NE(std::string::npos,
+ logging_.log().find("Unclean shutdown occurred while suspended."));
kmixter1 2010/11/23 23:18:01 Could you add a check here, above and in CollectFa
+}
+
TEST_F(UncleanShutdownCollectorTest, Disable) {
ASSERT_TRUE(collector_.Enable());
ASSERT_TRUE(file_util::PathExists(test_unclean_));
« unclean_shutdown_collector.cc ('K') | « unclean_shutdown_collector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698