| 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..a1126a2af8f384586dd141a79a88e45845b7f67f 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>
|
| -
|
| 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,
|
| - MetricsLogManager::LogType log_type) {
|
| + virtual void SerializeLogs(
|
| + const std::vector<std::pair<std::string, std::string> >& logs,
|
| + MetricsLogManager::LogType log_type) {
|
| persisted_logs_[log_type] = logs;
|
| }
|
|
|
| - virtual void DeserializeLogs(MetricsLogManager::LogType log_type,
|
| - std::vector<std::string>* logs) {
|
| + virtual void DeserializeLogs(
|
| + MetricsLogManager::LogType log_type,
|
| + std::vector<std::pair<std::string, std::string> >* 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<std::pair<std::string, std::string> > persisted_logs_[2];
|
| };
|
| -}; // namespace
|
| +
|
| +} // namespace
|
|
|
| TEST(MetricsLogManagerTest, StandardFlow) {
|
| MetricsLogManager log_manager;
|
| @@ -54,7 +59,8 @@ TEST(MetricsLogManagerTest, StandardFlow) {
|
| log_manager.StageCurrentLogForUpload();
|
| EXPECT_EQ(NULL, log_manager.current_log());
|
| EXPECT_TRUE(log_manager.has_staged_log());
|
| - EXPECT_FALSE(log_manager.staged_log_text().empty());
|
| + EXPECT_FALSE(log_manager.staged_log_text_xml().empty());
|
| + EXPECT_FALSE(log_manager.staged_log_text_proto().empty());
|
|
|
| MetricsLogBase* second_log = new MetricsLogBase("id", 0, "version");
|
| log_manager.BeginLoggingWithLog(second_log);
|
| @@ -64,7 +70,8 @@ TEST(MetricsLogManagerTest, StandardFlow) {
|
| log_manager.DiscardStagedLog();
|
| EXPECT_EQ(second_log, log_manager.current_log());
|
| EXPECT_FALSE(log_manager.has_staged_log());
|
| - EXPECT_TRUE(log_manager.staged_log_text().empty());
|
| + EXPECT_TRUE(log_manager.staged_log_text_xml().empty());
|
| + EXPECT_TRUE(log_manager.staged_log_text_proto().empty());
|
|
|
| EXPECT_FALSE(log_manager.has_unsent_logs());
|
| }
|
| @@ -109,8 +116,8 @@ TEST(MetricsLogManagerTest, InterjectedLog) {
|
| }
|
|
|
| TEST(MetricsLogManagerTest, StoreAndLoad) {
|
| - std::vector<std::string> initial_logs;
|
| - std::vector<std::string> ongoing_logs;
|
| + std::vector<std::pair<std::string, std::string> > initial_logs;
|
| + std::vector<std::pair<std::string, std::string> > 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 +126,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");
|
| + serializer->persisted_logs_[MetricsLogManager::ONGOING_LOG].push_back(
|
| + std::make_pair("xml", "proto"));
|
| EXPECT_FALSE(log_manager.has_unsent_logs());
|
| log_manager.LoadPersistedUnsentLogs();
|
| EXPECT_TRUE(log_manager.has_unsent_logs());
|
|
|