Chromium Code Reviews

Unified Diff: chrome/browser/metrics/metrics_log_unittest.cc

Issue 2814005: Landing CL http://codereview.chromium.org/2767013/show on behalf of petkov@ch... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_log_unittest.cc
===================================================================
--- chrome/browser/metrics/metrics_log_unittest.cc (revision 49766)
+++ chrome/browser/metrics/metrics_log_unittest.cc (working copy)
@@ -163,6 +163,37 @@
ASSERT_EQ(expected_output, encoded);
}
+#if defined(OS_CHROMEOS)
+TEST(MetricsLogTest, ChromeOSLoadEvent) {
+ std::string expected_output = StringPrintf(
+ "<log clientid=\"bogus client ID\" buildtime=\"123456789\" "
+ "appversion=\"%s\" hardwareclass=\"sample-class\">\n"
+ " <document action=\"load\" docid=\"1\" window=\"3\" loadtime=\"7219\" "
+ "origin=\"link\" session=\"0\" time=\"\"/>\n"
+ "</log>", MetricsLog::GetVersionString().c_str());
+
+ NoTimeMetricsLog log("bogus client ID", 0);
+ log.RecordLoadEvent(3, GURL("http://google.com"), PageTransition::LINK,
+ 1, TimeDelta::FromMilliseconds(7219));
+ log.set_hardware_class("sample-class");
+ log.CloseLog();
+
+ ASSERT_EQ(1, log.num_events());
+
+ int size = log.GetEncodedLogSize();
+ ASSERT_GT(size, 0);
+
+ std::string encoded;
+ // Leave room for the NUL terminator.
+ ASSERT_TRUE(log.GetEncodedLog(WriteInto(&encoded, size + 1), size));
+ TrimWhitespaceASCII(encoded, TRIM_ALL, &encoded);
+ NormalizeBuildtime(&encoded);
+ NormalizeBuildtime(&expected_output);
+
+ ASSERT_EQ(expected_output, encoded);
+}
+#endif // OS_CHROMEOS
+
// Make sure our ID hashes are the same as what we see on the server side.
TEST(MetricsLogTest, CreateHash) {
static const struct {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine