| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chrome_webusb_browser_client.h" | 5 #include "chrome/browser/chrome_webusb_browser_client.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/webusb/webusb_detector.h" | 10 #include "components/webusb/webusb_detector.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 device_client_.mock_usb_service().AddDevice(device); | 74 device_client_.mock_usb_service().AddDevice(device); |
| 75 | 75 |
| 76 message_center::MessageCenter* message_center = | 76 message_center::MessageCenter* message_center = |
| 77 message_center::MessageCenter::Get(); | 77 message_center::MessageCenter::Get(); |
| 78 ASSERT_TRUE(message_center != nullptr); | 78 ASSERT_TRUE(message_center != nullptr); |
| 79 | 79 |
| 80 message_center::Notification* notification = | 80 message_center::Notification* notification = |
| 81 message_center->FindVisibleNotificationById(guid); | 81 message_center->FindVisibleNotificationById(guid); |
| 82 ASSERT_TRUE(notification != nullptr); | 82 ASSERT_TRUE(notification != nullptr); |
| 83 | 83 |
| 84 base::string16 expected_title = base::ASCIIToUTF16("Google Product A"); | 84 base::string16 expected_title = |
| 85 base::ASCIIToUTF16("Google Product A detected"); |
| 85 EXPECT_EQ(expected_title, notification->title()); | 86 EXPECT_EQ(expected_title, notification->title()); |
| 86 | 87 |
| 87 base::string16 expected_message = | 88 base::string16 expected_message = |
| 88 base::ASCIIToUTF16("Click here to visit this page"); | 89 base::ASCIIToUTF16("Go to www.google.com/A to connect."); |
| 89 EXPECT_EQ(expected_message, notification->message()); | 90 EXPECT_EQ(expected_message, notification->message()); |
| 90 | 91 |
| 91 EXPECT_TRUE(notification->delegate() != nullptr); | 92 EXPECT_TRUE(notification->delegate() != nullptr); |
| 92 | 93 |
| 93 device_client_.mock_usb_service().RemoveDevice(device); | 94 device_client_.mock_usb_service().RemoveDevice(device); |
| 94 | 95 |
| 95 // device is removed, so notification should be removed from the | 96 // device is removed, so notification should be removed from the |
| 96 // message_center too | 97 // message_center too |
| 97 EXPECT_EQ(nullptr, message_center->FindVisibleNotificationById(guid)); | 98 EXPECT_EQ(nullptr, message_center->FindVisibleNotificationById(guid)); |
| 98 } | 99 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 device_client_.mock_usb_service().AddDevice(device_2); | 189 device_client_.mock_usb_service().AddDevice(device_2); |
| 189 device_client_.mock_usb_service().AddDevice(device_3); | 190 device_client_.mock_usb_service().AddDevice(device_3); |
| 190 | 191 |
| 191 message_center::MessageCenter* message_center = | 192 message_center::MessageCenter* message_center = |
| 192 message_center::MessageCenter::Get(); | 193 message_center::MessageCenter::Get(); |
| 193 ASSERT_TRUE(message_center != nullptr); | 194 ASSERT_TRUE(message_center != nullptr); |
| 194 | 195 |
| 195 message_center::Notification* notification_1 = | 196 message_center::Notification* notification_1 = |
| 196 message_center->FindVisibleNotificationById(guid_1); | 197 message_center->FindVisibleNotificationById(guid_1); |
| 197 ASSERT_TRUE(notification_1 != nullptr); | 198 ASSERT_TRUE(notification_1 != nullptr); |
| 198 base::string16 expected_title_1 = base::ASCIIToUTF16("Google Product A"); | 199 base::string16 expected_title_1 = |
| 200 base::ASCIIToUTF16("Google Product A detected"); |
| 199 EXPECT_EQ(expected_title_1, notification_1->title()); | 201 EXPECT_EQ(expected_title_1, notification_1->title()); |
| 202 base::string16 expected_message_1 = |
| 203 base::ASCIIToUTF16("Go to www.google.com/A to connect."); |
| 204 EXPECT_EQ(expected_message_1, notification_1->message()); |
| 200 | 205 |
| 201 message_center::Notification* notification_2 = | 206 message_center::Notification* notification_2 = |
| 202 message_center->FindVisibleNotificationById(guid_2); | 207 message_center->FindVisibleNotificationById(guid_2); |
| 203 ASSERT_TRUE(notification_2 != nullptr); | 208 ASSERT_TRUE(notification_2 != nullptr); |
| 204 base::string16 expected_title_2 = base::ASCIIToUTF16("Google Product B"); | 209 base::string16 expected_title_2 = |
| 210 base::ASCIIToUTF16("Google Product B detected"); |
| 205 EXPECT_EQ(expected_title_2, notification_2->title()); | 211 EXPECT_EQ(expected_title_2, notification_2->title()); |
| 212 base::string16 expected_message_2 = |
| 213 base::ASCIIToUTF16("Go to www.google.com/B to connect."); |
| 214 EXPECT_EQ(expected_message_2, notification_2->message()); |
| 206 | 215 |
| 207 message_center::Notification* notification_3 = | 216 message_center::Notification* notification_3 = |
| 208 message_center->FindVisibleNotificationById(guid_3); | 217 message_center->FindVisibleNotificationById(guid_3); |
| 209 ASSERT_TRUE(notification_3 != nullptr); | 218 ASSERT_TRUE(notification_3 != nullptr); |
| 210 base::string16 expected_title_3 = base::ASCIIToUTF16("Google Product C"); | 219 base::string16 expected_title_3 = |
| 220 base::ASCIIToUTF16("Google Product C detected"); |
| 211 EXPECT_EQ(expected_title_3, notification_3->title()); | 221 EXPECT_EQ(expected_title_3, notification_3->title()); |
| 212 | 222 base::string16 expected_message_3 = |
| 213 base::string16 expected_message = | 223 base::ASCIIToUTF16("Go to www.google.com/C to connect."); |
| 214 base::ASCIIToUTF16("Click here to visit this page"); | 224 EXPECT_EQ(expected_message_3, notification_3->message()); |
| 215 EXPECT_EQ(expected_message, notification_1->message()); | |
| 216 EXPECT_EQ(expected_message, notification_2->message()); | |
| 217 EXPECT_EQ(expected_message, notification_3->message()); | |
| 218 | 225 |
| 219 EXPECT_TRUE(notification_1->delegate() != nullptr); | 226 EXPECT_TRUE(notification_1->delegate() != nullptr); |
| 220 EXPECT_TRUE(notification_2->delegate() != nullptr); | 227 EXPECT_TRUE(notification_2->delegate() != nullptr); |
| 221 EXPECT_TRUE(notification_3->delegate() != nullptr); | 228 EXPECT_TRUE(notification_3->delegate() != nullptr); |
| 222 | 229 |
| 223 device_client_.mock_usb_service().RemoveDevice(device_1); | 230 device_client_.mock_usb_service().RemoveDevice(device_1); |
| 224 device_client_.mock_usb_service().RemoveDevice(device_2); | 231 device_client_.mock_usb_service().RemoveDevice(device_2); |
| 225 device_client_.mock_usb_service().RemoveDevice(device_3); | 232 device_client_.mock_usb_service().RemoveDevice(device_3); |
| 226 | 233 |
| 227 // devices are removed, so notifications should be removed from the | 234 // devices are removed, so notifications should be removed from the |
| 228 // message_center too | 235 // message_center too |
| 229 EXPECT_EQ(nullptr, message_center->FindVisibleNotificationById(guid_1)); | 236 EXPECT_EQ(nullptr, message_center->FindVisibleNotificationById(guid_1)); |
| 230 EXPECT_EQ(nullptr, message_center->FindVisibleNotificationById(guid_2)); | 237 EXPECT_EQ(nullptr, message_center->FindVisibleNotificationById(guid_2)); |
| 231 EXPECT_EQ(nullptr, message_center->FindVisibleNotificationById(guid_3)); | 238 EXPECT_EQ(nullptr, message_center->FindVisibleNotificationById(guid_3)); |
| 232 } | 239 } |
| OLD | NEW |