Skip to content
Snippets Groups Projects
Commit 4eb4799f authored by zelidrag@chromium.org's avatar zelidrag@chromium.org
Browse files

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
parent 3d8bea6a
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment