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

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

Issue 2735005: Merge 49197 - Submitting CL http://codereview.chromium.org/2324001 on behalf ... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/418/src/
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 | « chrome/browser/metrics/metrics_log.cc ('k') | chrome/browser/metrics/metrics_service.h » ('j') | 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 49204)
+++ chrome/browser/metrics/metrics_log_unittest.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -50,13 +50,40 @@
ASSERT_GT(size, 0);
std::string encoded;
- ASSERT_TRUE(log.GetEncodedLog(WriteInto(&encoded, size), size));
+ // 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);
}
+#if defined(OS_CHROMEOS)
+TEST(MetricsLogTest, ChromeOSEmptyRecord) {
+ std::string expected_output = StringPrintf(
+ "<log clientid=\"bogus client ID\" buildtime=\"123456789\" "
+ "appversion=\"%s\" hardwareclass=\"sample-class\"/>",
+ MetricsLog::GetVersionString().c_str());
+
+ MetricsLog log("bogus client ID", 0);
+ log.set_hardware_class("sample-class");
+ log.CloseLog();
+
+ 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
+
namespace {
class NoTimeMetricsLog : public MetricsLog {
@@ -98,7 +125,9 @@
ASSERT_GT(size, 0);
std::string encoded;
- ASSERT_TRUE(log.GetEncodedLog(WriteInto(&encoded, size), size));
+ // 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);
@@ -125,7 +154,9 @@
ASSERT_GT(size, 0);
std::string encoded;
- ASSERT_TRUE(log.GetEncodedLog(WriteInto(&encoded, size), size));
+ // 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);
« no previous file with comments | « chrome/browser/metrics/metrics_log.cc ('k') | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698