summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/metrics/metrics_log.cc2
-rw-r--r--chrome/browser/metrics/metrics_log_unittest.cc22
2 files changed, 13 insertions, 11 deletions
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index 6ddb61e..dd4aa3f 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -64,6 +64,7 @@ MetricsLog::MetricsLog(const std::string& client_id, int session_id)
StartElement("log");
WriteAttribute("clientid", client_id_);
WriteInt64Attribute("buildtime", GetBuildTime());
+ WriteAttribute("appversion", GetVersionString());
DCHECK_GE(result, 0);
}
@@ -509,7 +510,6 @@ void MetricsLog::WriteInstallElement() {
OPEN_ELEMENT_FOR_SCOPE("install");
WriteAttribute("installdate", GetInstallDate());
WriteIntAttribute("buildid", 0); // We're using appversion instead.
- WriteAttribute("appversion", GetVersionString());
}
void MetricsLog::RecordEnvironment(
diff --git a/chrome/browser/metrics/metrics_log_unittest.cc b/chrome/browser/metrics/metrics_log_unittest.cc
index 85d7aaf..4ac4cb8 100644
--- a/chrome/browser/metrics/metrics_log_unittest.cc
+++ b/chrome/browser/metrics/metrics_log_unittest.cc
@@ -39,8 +39,9 @@ static void NormalizeBuildtime(std::string* xml_encoded) {
}
TEST(MetricsLogTest, EmptyRecord) {
- std::string expected_output =
- "<log clientid=\"bogus client ID\" buildtime=\"123456789\"/>";
+ std::string expected_output = StringPrintf(
+ "<log clientid=\"bogus client ID\" buildtime=\"123456789\" "
+ "appversion=\"%s\"/>", MetricsLog::GetVersionString().c_str());
MetricsLog log("bogus client ID", 0);
log.CloseLog();
@@ -73,15 +74,16 @@ class NoTimeMetricsLog : public MetricsLog {
}; // namespace
TEST(MetricsLogTest, WindowEvent) {
- std::string expected_output =
- "<log clientid=\"bogus client ID\" buildtime=\"123456789\">\n"
+ std::string expected_output = StringPrintf(
+ "<log clientid=\"bogus client ID\" buildtime=\"123456789\" "
+ "appversion=\"%s\">\n"
" <window action=\"create\" windowid=\"0\" session=\"0\" time=\"\"/>\n"
" <window action=\"open\" windowid=\"1\" parent=\"0\" "
"session=\"0\" time=\"\"/>\n"
" <window action=\"close\" windowid=\"1\" parent=\"0\" "
"session=\"0\" time=\"\"/>\n"
" <window action=\"destroy\" windowid=\"0\" session=\"0\" time=\"\"/>\n"
- "</log>";
+ "</log>", MetricsLog::GetVersionString().c_str());
NoTimeMetricsLog log("bogus client ID", 0);
log.RecordWindowEvent(MetricsLog::WINDOW_CREATE, 0, -1);
@@ -104,12 +106,12 @@ TEST(MetricsLogTest, WindowEvent) {
}
TEST(MetricsLogTest, LoadEvent) {
- std::string expected_output =
- "<log clientid=\"bogus client ID\" buildtime=\"123456789\">\n"
+ std::string expected_output = StringPrintf(
+ "<log clientid=\"bogus client ID\" buildtime=\"123456789\" "
+ "appversion=\"%s\">\n"
" <document action=\"load\" docid=\"1\" window=\"3\" loadtime=\"7219\" "
- "origin=\"link\" "
- "session=\"0\" time=\"\"/>\n"
- "</log>";
+ "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,