Commit a40f1f0c authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Add marketing_name to SystemDataProvider::GetSystemInfo

This change adds the marketing name to the SystemInfo struct so that it
can be displayed in the UI.

Bug: 1128204
Change-Id: I61fdab68aa61701cfe9c6a1bc7a23b712aeec1a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2491989Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820924}
parent 2e8a3d68
......@@ -46,6 +46,11 @@ void PopulateBoardName(const healthd::SystemInfo& system_info,
out_system_info.board_name = product_name.value();
}
void PopulateMarketingName(const healthd::SystemInfo& system_info,
mojom::SystemInfo& out_system_info) {
out_system_info.marketing_name = system_info.marketing_name;
}
void PopulateCpuInfo(const healthd::CpuInfo& cpu_info,
mojom::SystemInfo& out_system_info) {
const PhysicalCpuInfos& physical_cpus = cpu_info.physical_cpus;
......@@ -257,6 +262,7 @@ void SystemDataProvider::OnSystemInfoProbeResponse(
diagnostics::GetSystemInfo(*info_ptr);
if (system_info_ptr) {
PopulateBoardName(*system_info_ptr, *system_info.get());
PopulateMarketingName(*system_info_ptr, *system_info.get());
PopulateVersionInfo(*system_info_ptr, *system_info.get());
} else {
LOG(ERROR)
......
......@@ -56,6 +56,7 @@ void SetProbeTelemetryInfoResponse(
}
void SetCrosHealthdSystemInfoResponse(const std::string& board_name,
const std::string& marketing_name,
const std::string& cpu_model,
uint32_t total_memory_kib,
uint16_t cpu_threads_count,
......@@ -67,6 +68,7 @@ void SetCrosHealthdSystemInfoResponse(const std::string& board_name,
auto os_version_info = cros_healthd::mojom::OsVersion::New();
os_version_info->release_milestone = milestone_version;
system_info->os_version = std::move(os_version_info);
system_info->marketing_name = marketing_name;
// Battery info
auto battery_info =
......@@ -403,6 +405,7 @@ class SystemDataProviderTest : public testing::Test {
TEST_F(SystemDataProviderTest, GetSystemInfo) {
const std::string expected_board_name = "board_name";
const std::string expected_marketing_name = "marketing_name";
const std::string expected_cpu_model = "cpu_model";
const uint32_t expected_total_memory_kib = 1234;
const uint16_t expected_cpu_threads_count = 5678;
......@@ -410,15 +413,16 @@ TEST_F(SystemDataProviderTest, GetSystemInfo) {
const std::string expected_milestone_version = "M99";
SetCrosHealthdSystemInfoResponse(
expected_board_name, expected_cpu_model, expected_total_memory_kib,
expected_cpu_threads_count, expected_has_battery,
expected_milestone_version);
expected_board_name, expected_marketing_name, expected_cpu_model,
expected_total_memory_kib, expected_cpu_threads_count,
expected_has_battery, expected_milestone_version);
base::RunLoop run_loop;
system_data_provider_->GetSystemInfo(
base::BindLambdaForTesting([&](mojom::SystemInfoPtr ptr) {
ASSERT_TRUE(ptr);
EXPECT_EQ(expected_board_name, ptr->board_name);
EXPECT_EQ(expected_marketing_name, ptr->marketing_name);
EXPECT_EQ(expected_cpu_model, ptr->cpu_model_name);
EXPECT_EQ(expected_total_memory_kib, ptr->total_memory_kib);
EXPECT_EQ(expected_cpu_threads_count, ptr->cpu_threads_count);
......@@ -433,6 +437,7 @@ TEST_F(SystemDataProviderTest, GetSystemInfo) {
TEST_F(SystemDataProviderTest, NoBattery) {
const std::string expected_board_name = "board_name";
const std::string expected_marketing_name = "marketing_name";
const std::string expected_cpu_model = "cpu_model";
const uint32_t expected_total_memory_kib = 1234;
const uint16_t expected_cpu_threads_count = 5678;
......@@ -440,15 +445,16 @@ TEST_F(SystemDataProviderTest, NoBattery) {
const std::string expected_milestone_version = "M99";
SetCrosHealthdSystemInfoResponse(
expected_board_name, expected_cpu_model, expected_total_memory_kib,
expected_cpu_threads_count, expected_has_battery,
expected_milestone_version);
expected_board_name, expected_marketing_name, expected_cpu_model,
expected_total_memory_kib, expected_cpu_threads_count,
expected_has_battery, expected_milestone_version);
base::RunLoop run_loop;
system_data_provider_->GetSystemInfo(
base::BindLambdaForTesting([&](mojom::SystemInfoPtr ptr) {
ASSERT_TRUE(ptr);
EXPECT_EQ(expected_board_name, ptr->board_name);
EXPECT_EQ(expected_marketing_name, ptr->marketing_name);
EXPECT_EQ(expected_cpu_model, ptr->cpu_model_name);
EXPECT_EQ(expected_total_memory_kib, ptr->total_memory_kib);
EXPECT_EQ(expected_cpu_threads_count, ptr->cpu_threads_count);
......
......@@ -19,6 +19,7 @@ struct VersionInfo {
// Contains a snapshot of static system information.
struct SystemInfo {
string board_name;
string marketing_name;
string cpu_model_name;
uint32 total_memory_kib;
uint16 cpu_threads_count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment