1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/metrics/log_decoder.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/metrics_proto/chrome_user_metrics_extension.pb.h"
11 #include "third_party/zlib/google/compression_utils.h"
15 TEST(LogDecoderTest, DecodeLogDataToProto) {
16 ChromeUserMetricsExtension uma_log1;
17 uma_log1.mutable_system_profile()->set_application_locale("fr");
19 std::string log_data1;
20 ASSERT_TRUE(uma_log1.SerializeToString(&log_data1));
21 std::string compressed_log_data;
22 ASSERT_TRUE(compression::GzipCompress(log_data1, &compressed_log_data));
24 ChromeUserMetricsExtension uma_log2;
25 EXPECT_TRUE(DecodeLogDataToProto(compressed_log_data, &uma_log2));
27 std::string log_data2;
28 uma_log2.SerializeToString(&log_data2);
29 EXPECT_EQ(log_data1, log_data2);
32 } // namespace metrics