Upload upstream chromium 85.0.4183.84
[platform/framework/web/chromium-efl.git] / components / metrics / entropy_state_provider_unittest.cc
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
5 #include "components/metrics/entropy_state_provider.h"
6
7 #include "components/metrics/metrics_pref_names.h"
8 #include "components/metrics/metrics_service.h"
9 #include "components/prefs/testing_pref_service.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/metrics_proto/system_profile.pb.h"
12
13 namespace metrics {
14
15 class EntropyStateProviderTest : public testing::Test {
16  public:
17   EntropyStateProviderTest() {
18     MetricsService::RegisterPrefs(prefs_.registry());
19   }
20
21   EntropyStateProviderTest(const EntropyStateProviderTest&) = delete;
22   EntropyStateProviderTest& operator=(const EntropyStateProviderTest&) = delete;
23
24  protected:
25   TestingPrefServiceSimple prefs_;
26 };
27
28 TEST_F(EntropyStateProviderTest, PopulateBothLowEntropySource) {
29   const int new_low_source = 1234;
30   const int old_low_source = 5678;
31   prefs_.SetInteger(prefs::kMetricsLowEntropySource, new_low_source);
32   prefs_.SetInteger(prefs::kMetricsOldLowEntropySource, old_low_source);
33
34   EntropyStateProvider provider(&prefs_);
35   SystemProfileProto system_profile;
36
37   provider.ProvideSystemProfileMetrics(&system_profile);
38
39   EXPECT_EQ(new_low_source, system_profile.low_entropy_source());
40   EXPECT_EQ(old_low_source, system_profile.old_low_entropy_source());
41 }
42
43 }  // namespace metrics