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

Unified Diff: user_collector_test.cc

Issue 2868032: Remove source from crash-reporter and crash-dumper as they are no longer necessary. (Closed) Base URL: ssh://git@chromiumos-git//crash.git
Patch Set: Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « user_collector.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: user_collector_test.cc
diff --git a/user_collector_test.cc b/user_collector_test.cc
deleted file mode 100644
index 6398ce707ea7ae362061dc796dc6502a7124624d..0000000000000000000000000000000000000000
--- a/user_collector_test.cc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <gflags/gflags.h>
-#include <gtest/gtest.h>
-
-#include "base/file_util.h"
-#include "crash/system_logging_mock.h"
-#include "crash/user_collector.h"
-
-int s_crashes = 0;
-bool s_metrics = false;
-
-static const char kFilePath[] = "/my/path";
-
-void CountCrash() {
- ++s_crashes;
-}
-
-bool IsMetrics() {
- return s_metrics;
-}
-
-class UserCollectorTest : public ::testing::Test {
- void SetUp() {
- s_crashes = 0;
- collector_.Initialize(CountCrash,
- kFilePath,
- IsMetrics,
- &logging_);
- mkdir("test", 0777);
- collector_.set_core_pattern_file("test/core_pattern");
- }
- protected:
- SystemLoggingMock logging_;
- UserCollector collector_;
-};
-
-TEST_F(UserCollectorTest, EnableOK) {
- std::string contents;
- ASSERT_TRUE(collector_.Enable());
- ASSERT_TRUE(file_util::ReadFileToString(FilePath("test/core_pattern"),
- &contents));
- ASSERT_STREQ(contents.c_str(),
- "|/my/path --signal=%s --pid=%p --exec=%e");
- ASSERT_EQ(s_crashes, 0);
- ASSERT_NE(logging_.log().find("Enabling crash handling"), std::string::npos);
-}
-
-TEST_F(UserCollectorTest, EnableNoFileAccess) {
- collector_.set_core_pattern_file("/does_not_exist");
- ASSERT_FALSE(collector_.Enable());
- ASSERT_EQ(s_crashes, 0);
- ASSERT_NE(logging_.log().find("Enabling crash handling"), std::string::npos);
- ASSERT_NE(logging_.log().find("Unable to write /does_not_exist"),
- std::string::npos);
-}
-
-TEST_F(UserCollectorTest, DisableOK) {
- std::string contents;
- ASSERT_TRUE(collector_.Disable());
- ASSERT_TRUE(file_util::ReadFileToString(FilePath("test/core_pattern"),
- &contents));
- ASSERT_STREQ(contents.c_str(), "core");
- ASSERT_EQ(s_crashes, 0);
- ASSERT_NE(logging_.log().find("Disabling crash handling"),
- std::string::npos);
-}
-
-TEST_F(UserCollectorTest, DisableNoFileAccess) {
- collector_.set_core_pattern_file("/does_not_exist");
- ASSERT_FALSE(collector_.Disable());
- ASSERT_EQ(s_crashes, 0);
- ASSERT_NE(logging_.log().find("Disabling crash handling"), std::string::npos);
- ASSERT_NE(logging_.log().find("Unable to write /does_not_exist"),
- std::string::npos);
-}
-
-
-TEST_F(UserCollectorTest, HandleCrashWithoutMetrics) {
- s_metrics = false;
- collector_.HandleCrash(10, 20, "foobar");
- ASSERT_NE(logging_.log().find(
- "Received crash notification for foobar[20] sig 10"),
- std::string::npos);
- ASSERT_EQ(s_crashes, 0);
-}
-
-TEST_F(UserCollectorTest, HandleCrashWithMetrics) {
- s_metrics = true;
- collector_.HandleCrash(2, 5, "chrome");
- ASSERT_NE(logging_.log().find(
- "Received crash notification for chrome[5] sig 2"),
- std::string::npos);
- ASSERT_EQ(s_crashes, 1);
-}
-
-int main(int argc, char **argv) {
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
« no previous file with comments | « user_collector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698