diff options
author | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-16 18:15:00 +0000 |
---|---|---|
committer | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-16 18:15:00 +0000 |
commit | 4eb4799f5889c414331aca32a4f0595a36ab8765 (patch) | |
tree | d041d03d411005803e8f901c9f03f69627e5d906 /chrome/browser/metrics | |
parent | 3d8bea6aecc94233557df4ca1456d255f61169bd (diff) | |
download | chromium_src-4eb4799f5889c414331aca32a4f0595a36ab8765.zip chromium_src-4eb4799f5889c414331aca32a4f0595a36ab8765.tar.gz chromium_src-4eb4799f5889c414331aca32a4f0595a36ab8765.tar.bz2 |
Landing CL http://codereview.chromium.org/2767013/show on behalf of petkov@chromium.org:
Add one more Chrome OS hardware class MetricsLog unit tests.
Since the hardware class attribute is added to the XML when the log is
closed, it's important to test for its presence in the encoded string
when the log contains some events. The existing unit test covers only
the case when the log is empty.
BUG=none
TEST=ran unit tests
Review URL: http://codereview.chromium.org/2814005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49980 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/metrics')
-rw-r--r-- | chrome/browser/metrics/metrics_log_unittest.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/chrome/browser/metrics/metrics_log_unittest.cc b/chrome/browser/metrics/metrics_log_unittest.cc index f7f64ae..27c84c6 100644 --- a/chrome/browser/metrics/metrics_log_unittest.cc +++ b/chrome/browser/metrics/metrics_log_unittest.cc @@ -163,6 +163,37 @@ TEST(MetricsLogTest, LoadEvent) { 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 { |