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

Unified Diff: chrome/common/metrics/metrics_log_manager_unittest.cc

Issue 9474041: Upload UMA data using protocol buffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix crash in test Created 8 years, 10 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
Index: chrome/common/metrics/metrics_log_manager_unittest.cc
diff --git a/chrome/common/metrics/metrics_log_manager_unittest.cc b/chrome/common/metrics/metrics_log_manager_unittest.cc
index 0373186b16c1e6d130456ff26de90ee24a6fa35e..43b2071a42266766ecff47d0ac0d6633b1c3e72b 100644
--- a/chrome/common/metrics/metrics_log_manager_unittest.cc
+++ b/chrome/common/metrics/metrics_log_manager_unittest.cc
@@ -2,27 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
+#include <utility>
+#include <vector>
+
#include "chrome/common/metrics/metrics_log_base.h"
#include "chrome/common/metrics/metrics_log_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <string>
-#include <vector>
+typedef MetricsLogManager::SerializedLog SerializedLog;
namespace {
+
class MetricsLogManagerTest : public testing::Test {
};
// Dummy serializer that just stores logs in memory.
class DummyLogSerializer : public MetricsLogManager::LogSerializer {
public:
- virtual void SerializeLogs(const std::vector<std::string>& logs,
+ virtual void SerializeLogs(const std::vector<SerializedLog>& logs,
MetricsLogManager::LogType log_type) {
persisted_logs_[log_type] = logs;
}
virtual void DeserializeLogs(MetricsLogManager::LogType log_type,
- std::vector<std::string>* logs) {
+ std::vector<SerializedLog>* logs) {
ASSERT_NE(static_cast<void*>(NULL), logs);
*logs = persisted_logs_[log_type];
}
@@ -33,9 +37,10 @@ class DummyLogSerializer : public MetricsLogManager::LogSerializer {
}
// In-memory "persitent storage".
- std::vector<std::string> persisted_logs_[2];
+ std::vector<SerializedLog> persisted_logs_[2];
};
-}; // namespace
+
+} // namespace
TEST(MetricsLogManagerTest, StandardFlow) {
MetricsLogManager log_manager;
@@ -109,8 +114,8 @@ TEST(MetricsLogManagerTest, InterjectedLog) {
}
TEST(MetricsLogManagerTest, StoreAndLoad) {
- std::vector<std::string> initial_logs;
- std::vector<std::string> ongoing_logs;
+ std::vector<SerializedLog> initial_logs;
+ std::vector<SerializedLog> ongoing_logs;
// Set up some in-progress logging in a scoped log manager simulating the
// leadup to quitting, then persist as would be done on quit.
@@ -119,7 +124,8 @@ TEST(MetricsLogManagerTest, StoreAndLoad) {
DummyLogSerializer* serializer = new DummyLogSerializer;
log_manager.set_log_serializer(serializer);
// Simulate a log having already been unsent from a previous session.
- serializer->persisted_logs_[MetricsLogManager::ONGOING_LOG].push_back("a");
+ SerializedLog log = {"xml", "proto"};
+ serializer->persisted_logs_[MetricsLogManager::ONGOING_LOG].push_back(log);
EXPECT_FALSE(log_manager.has_unsent_logs());
log_manager.LoadPersistedUnsentLogs();
EXPECT_TRUE(log_manager.has_unsent_logs());

Powered by Google App Engine
This is Rietveld 408576698