1 // Copyright 2022 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. 4 5 #include "components/metrics/motherboard_metrics_provider.h" 6 7 #include <utility> 8 9 #include "base/functional/bind.h" 10 #include "base/test/bind.h" 11 #include "base/test/task_environment.h" 12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "third_party/metrics_proto/system_profile.pb.h" 14 15 namespace metrics { 16 namespace { 17 18 class TestMotherboardMetricsProvider : public MotherboardMetricsProvider { 19 public: 20 TestMotherboardMetricsProvider() = default; 21 22 TestMotherboardMetricsProvider(const TestMotherboardMetricsProvider&) = delete; 23 TestMotherboardMetricsProvider& operator=( 24 const TestMotherboardMetricsProvider&) = delete; 25 26 ~TestMotherboardMetricsProvider() override = default; 27 28 private: 29 base::test::TaskEnvironment task_environment_; 30 }; 31 32 } // namespace 33 TEST(MotherboardMetricsProviderTest,ProvideSystemProfileMetrics)34TEST(MotherboardMetricsProviderTest, ProvideSystemProfileMetrics) { 35 TestMotherboardMetricsProvider provider; 36 SystemProfileProto system_profile; 37 38 base::RunLoop run_loop; 39 provider.AsyncInit(run_loop.QuitClosure()); 40 run_loop.Run(); 41 42 provider.ProvideSystemProfileMetrics(&system_profile); 43 44 // Verify that the system profile has the motherboard info set. 45 const SystemProfileProto::Hardware& hardware = system_profile.hardware(); 46 ASSERT_TRUE(hardware.has_motherboard()); 47 ASSERT_TRUE(hardware.motherboard().has_manufacturer()); 48 ASSERT_TRUE(hardware.motherboard().has_model()); 49 ASSERT_TRUE(hardware.motherboard().has_bios_manufacturer()); 50 ASSERT_TRUE(hardware.motherboard().has_bios_version()); 51 ASSERT_TRUE(hardware.motherboard().has_bios_type()); 52 } 53 54 } // namespace metrics 55