log_decoder_unittest.cc 1007 B

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