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

Unified Diff: chrome/browser/chromeos/external_metrics_unittest.cc

Issue 6077013: Add support for collecting non-Chrome crash stats in Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/external_metrics.cc ('k') | chrome/browser/metrics/metrics_log.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/external_metrics_unittest.cc
===================================================================
--- chrome/browser/chromeos/external_metrics_unittest.cc (revision 71358)
+++ chrome/browser/chromeos/external_metrics_unittest.cc (working copy)
@@ -87,6 +87,12 @@
}
}
+ // Sends a crash message.
+ int expect_count = nhist;
+ SendMessage(path, "crash", "user");
+ external_metrics->CollectEvents();
+ CheckMessage("crash", "user", ++expect_count);
+
// Sends a message that's too large.
char b[MAXLENGTH + 100];
for (i = 0; i < MAXLENGTH + 99; i++) {
@@ -94,35 +100,36 @@
}
b[i] = '\0';
SendMessage(path, b, "yyy");
+ // Expect logged errors about bad message size.
external_metrics->CollectEvents();
- EXPECT_EQ(received_count, nhist);
+ EXPECT_EQ(expect_count, received_count);
// Sends a malformed message (first string is not null-terminated).
i = 100 + sizeof(i);
int fd = open(path, O_CREAT | O_WRONLY, 0666);
EXPECT_GT(fd, 0);
- EXPECT_EQ(write(fd, &i, sizeof(i)), static_cast<int>(sizeof(i)));
- EXPECT_EQ(write(fd, b, i), i);
- EXPECT_EQ(close(fd), 0);
+ EXPECT_EQ(static_cast<int>(sizeof(i)), write(fd, &i, sizeof(i)));
+ EXPECT_EQ(i, write(fd, b, i));
+ EXPECT_EQ(0, close(fd));
external_metrics->CollectEvents();
- EXPECT_EQ(received_count, nhist);
+ EXPECT_EQ(expect_count, received_count);
// Sends a malformed message (second string is not null-terminated).
b[50] = '\0';
fd = open(path, O_CREAT | O_WRONLY, 0666);
EXPECT_GT(fd, 0);
- EXPECT_EQ(write(fd, &i, sizeof(i)), static_cast<int>(sizeof(i)));
- EXPECT_EQ(write(fd, b, i), i);
- EXPECT_EQ(close(fd), 0);
+ EXPECT_EQ(static_cast<int>(sizeof(i)), write(fd, &i, sizeof(i)));
+ EXPECT_EQ(i, write(fd, b, i));
+ EXPECT_EQ(0, close(fd));
external_metrics->CollectEvents();
- EXPECT_EQ(received_count, nhist);
+ EXPECT_EQ(expect_count, received_count);
// Checks that we survive when file doesn't exist.
- EXPECT_EQ(unlink(path), 0);
+ EXPECT_EQ(0, unlink(path));
external_metrics->CollectEvents();
- EXPECT_EQ(received_count, nhist);
+ EXPECT_EQ(expect_count, received_count);
}
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/external_metrics.cc ('k') | chrome/browser/metrics/metrics_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698