[go: nahoru, domu]

Add a notification for billboard devices.

If the board does not support thunderbolt and a device that does not
have alt-mode is connected, it will be resolved as a billboard device.
This notification will tell the user that the device is not supported.

Screenshot: https://screenshot.googleplex.com/A8jh8usYPNtQQe3

Bug: 1177187
Test: ash_unittests
Change-Id: I0a05a71a6d0653c1c0bdea81334e83bf65df16d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2984005
Commit-Queue: Anton Swifton <swifton@google.com>
Reviewed-by: Achuith Bhandarkar <achuith@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Jimmy Gong <jimmyxgong@chromium.org>
Reviewed-by: Ahmed Mehfooz <amehfooz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#908159}
diff --git a/ash/system/pcie_peripheral/pcie_peripheral_notification_controller_unittest.cc b/ash/system/pcie_peripheral/pcie_peripheral_notification_controller_unittest.cc
index 14114d0..e5351cce 100644
--- a/ash/system/pcie_peripheral/pcie_peripheral_notification_controller_unittest.cc
+++ b/ash/system/pcie_peripheral/pcie_peripheral_notification_controller_unittest.cc
@@ -34,6 +34,8 @@
     "cros_pcie_peripheral_guest_mode_not_supported_notifcation_id";
 const char kPciePeripheralDeviceBlockedNotificationId[] =
     "cros_pcie_peripheral_device_blocked_notifcation_id";
+const char kPciePeripheralBillboardDeviceNotificationId[] =
+    "cros_pcie_peripheral_billboard_device_notifcation_id";
 const char kLearnMoreHelpUrl[] =
     "https://www.support.google.com/chromebook?p=connect_thblt_usb4_accy";
 
@@ -89,6 +91,11 @@
         kPciePeripheralDeviceBlockedNotificationId);
   }
 
+  message_center::Notification* GetBillboardDeviceNotification() {
+    return MessageCenter::Get()->FindVisibleNotificationById(
+        kPciePeripheralBillboardDeviceNotificationId);
+  }
+
   int GetNumOsPrivacySettingsOpened() {
     return GetSystemTrayClient()->show_os_settings_privacy_and_security_count();
   }
@@ -153,7 +160,7 @@
   controller()->NotifyGuestModeNotification(/*is_thunderbolt_only=*/true);
   EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount());
 
-  // Click on the notification and expect the Learn More page to page to appear.
+  // Click on the notification and expect the Learn More page to appear.
   EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
       .WillOnce([](const GURL& url, bool from_user_interaction) {
         EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
@@ -179,7 +186,7 @@
   controller()->NotifyGuestModeNotification(/*is_thunderbolt_only=*/false);
   EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount());
 
-  // Click on the notification and expect the Learn More page to page to appear.
+  // Click on the notification and expect the Learn More page to appear.
   EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
       .WillOnce([](const GURL& url, bool from_user_interaction) {
         EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
@@ -203,7 +210,7 @@
   // This notification has no buttons.
   EXPECT_EQ(0u, notification->buttons().size());
 
-  // Click on the notification and expect the Learn More page to page to appear.
+  // Click on the notification and expect the Learn More page to appear.
   EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
       .WillOnce([](const GURL& url, bool from_user_interaction) {
         EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
@@ -214,6 +221,34 @@
   EXPECT_EQ(0u, MessageCenter::Get()->NotificationCount());
 }
 
+TEST_F(PciePeripheralNotificationControllerTest, BillboardDeviceNotification) {
+  EXPECT_EQ(0u, MessageCenter::Get()->NotificationCount());
+  EXPECT_EQ(3, GetPrefNotificationCount());
+
+  controller()->NotifyBillboardDevice();
+  EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount());
+
+  message_center::Notification* notification = GetBillboardDeviceNotification();
+  ASSERT_TRUE(notification);
+
+  // This notification has no buttons.
+  EXPECT_EQ(0u, notification->buttons().size());
+
+  controller()->NotifyBillboardDevice();
+  EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount());
+
+  // Click on the notification and expect the Learn More page to appear.
+  EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
+      .WillOnce([](const GURL& url, bool from_user_interaction) {
+        EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
+        EXPECT_TRUE(from_user_interaction);
+      });
+  MessageCenter::Get()->ClickOnNotification(
+      kPciePeripheralBillboardDeviceNotificationId);
+  EXPECT_EQ(0u, MessageCenter::Get()->NotificationCount());
+  EXPECT_EQ(3, GetPrefNotificationCount());
+}
+
 TEST_F(PciePeripheralNotificationControllerTest,
        LimitedPerformanceNotificationLearnMoreClick) {
   EXPECT_EQ(0u, MessageCenter::Get()->NotificationCount());