Update DeviceType cpp enum
(First patch for Bug 1358151)
Introduced new cpp enums to describe the device type; OsType and
FormFactor.
1. Enum OsType.
2. Enum FormFactor, defines device type; desktop, phone, tablet.
Callers and tests of DeviceInfo are updated to populate the new types.
The old DeviceType enum is kept as it is for backward compatibility.
This change is needed as the old DeviceType enum is missing entries.
There should be no behavioral changes.
Bug: 1358151
Change-Id: I1d50e02ae1a593ff65dafb69afe446b14f6ab2ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3899073
Reviewed-by: Rushan Suleymanov <[email protected]>
Reviewed-by: Elly Fong-Jones <[email protected]>
Reviewed-by: Maksim Moskvitin <[email protected]>
Commit-Queue: Jood Hajeer <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1051739}
diff --git a/chrome/browser/sharing/sharing_utils_unittest.cc b/chrome/browser/sharing/sharing_utils_unittest.cc
index 931aadb..0427c05 100644
--- a/chrome/browser/sharing/sharing_utils_unittest.cc
+++ b/chrome/browser/sharing/sharing_utils_unittest.cc
@@ -137,52 +137,70 @@
TEST_F(SharingUtilsTest, GetDevicePlatform) {
EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
- sync_pb::SyncEnums_DeviceType_TYPE_CROS)),
+ sync_pb::SyncEnums_DeviceType_TYPE_CROS,
+ syncer::DeviceInfo::OsType::kChromeOsAsh,
+ syncer::DeviceInfo::FormFactor::kDesktop)),
SharingDevicePlatform::kChromeOS);
EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
- sync_pb::SyncEnums_DeviceType_TYPE_LINUX)),
+ sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
+ syncer::DeviceInfo::OsType::kLinux,
+ syncer::DeviceInfo::FormFactor::kDesktop)),
SharingDevicePlatform::kLinux);
EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
- sync_pb::SyncEnums_DeviceType_TYPE_MAC)),
+ sync_pb::SyncEnums_DeviceType_TYPE_MAC,
+ syncer::DeviceInfo::OsType::kMac,
+ syncer::DeviceInfo::FormFactor::kDesktop)),
SharingDevicePlatform::kMac);
EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
- sync_pb::SyncEnums_DeviceType_TYPE_WIN)),
+ sync_pb::SyncEnums_DeviceType_TYPE_WIN,
+ syncer::DeviceInfo::OsType::kWindows,
+ syncer::DeviceInfo::FormFactor::kDesktop)),
SharingDevicePlatform::kWindows);
EXPECT_EQ(
GetDevicePlatform(*CreateFakeDeviceInfo(
kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
- sync_pb::SyncEnums_DeviceType_TYPE_PHONE, "Apple Inc.", "iPhone 50")),
+ sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
+ syncer::DeviceInfo::OsType::kIOS,
+ syncer::DeviceInfo::FormFactor::kPhone, "Apple Inc.", "iPhone 50")),
SharingDevicePlatform::kIOS);
EXPECT_EQ(
GetDevicePlatform(*CreateFakeDeviceInfo(
kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
- sync_pb::SyncEnums_DeviceType_TYPE_TABLET, "Apple Inc.", "iPad 99")),
+ sync_pb::SyncEnums_DeviceType_TYPE_TABLET,
+ syncer::DeviceInfo::OsType::kIOS,
+ syncer::DeviceInfo::FormFactor::kTablet, "Apple Inc.", "iPad 99")),
SharingDevicePlatform::kIOS);
- EXPECT_EQ(
- GetDevicePlatform(*CreateFakeDeviceInfo(
- kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
- sync_pb::SyncEnums_DeviceType_TYPE_PHONE, "Google", "Pixel 777")),
- SharingDevicePlatform::kAndroid);
- EXPECT_EQ(
- GetDevicePlatform(*CreateFakeDeviceInfo(
- kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
- sync_pb::SyncEnums_DeviceType_TYPE_TABLET, "Google", "Pixel Z")),
- SharingDevicePlatform::kAndroid);
-
EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
- sync_pb::SyncEnums_DeviceType_TYPE_UNSET)),
+ sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
+ syncer::DeviceInfo::OsType::kAndroid,
+ syncer::DeviceInfo::FormFactor::kPhone, "Google", "Pixel 777")),
+ SharingDevicePlatform::kAndroid);
+ EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
+ kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
+ sync_pb::SyncEnums_DeviceType_TYPE_TABLET,
+ syncer::DeviceInfo::OsType::kAndroid,
+ syncer::DeviceInfo::FormFactor::kTablet, "Google", "Pixel Z")),
+ SharingDevicePlatform::kAndroid);
+
+ EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
+ kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
+ sync_pb::SyncEnums_DeviceType_TYPE_UNSET,
+ syncer::DeviceInfo::OsType::kUnknown,
+ syncer::DeviceInfo::FormFactor::kUnknown)),
SharingDevicePlatform::kUnknown);
EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
- sync_pb::SyncEnums_DeviceType_TYPE_OTHER)),
+ sync_pb::SyncEnums_DeviceType_TYPE_OTHER,
+ syncer::DeviceInfo::OsType::kUnknown,
+ syncer::DeviceInfo::FormFactor::kUnknown)),
SharingDevicePlatform::kUnknown);
}