summaryrefslogtreecommitdiff
path: root/chromium/components/metrics/log_decoder_unittest.cc
blob: 2657c85ee4caf6d3d57875880a994db91309cc3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/metrics/log_decoder.h"

#include <string>

#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/metrics_proto/chrome_user_metrics_extension.pb.h"
#include "third_party/zlib/google/compression_utils.h"

namespace metrics {

TEST(LogDecoderTest, DecodeLogDataToProto) {
  ChromeUserMetricsExtension uma_log1;
  uma_log1.mutable_system_profile()->set_application_locale("fr");

  std::string log_data1;
  ASSERT_TRUE(uma_log1.SerializeToString(&log_data1));
  std::string compressed_log_data;
  ASSERT_TRUE(compression::GzipCompress(log_data1, &compressed_log_data));

  ChromeUserMetricsExtension uma_log2;
  EXPECT_TRUE(DecodeLogDataToProto(compressed_log_data, &uma_log2));

  std::string log_data2;
  uma_log2.SerializeToString(&log_data2);
  EXPECT_EQ(log_data1, log_data2);
}

}  // namespace metrics