| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/notifications/notification_platform_bridge_linux.h" | 5 #include "chrome/browser/notifications/notification_platform_bridge_linux.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 notification_.set_image(image); | 54 notification_.set_image(image); |
| 55 return *this; | 55 return *this; |
| 56 } | 56 } |
| 57 | 57 |
| 58 NotificationBuilder& SetItems( | 58 NotificationBuilder& SetItems( |
| 59 const std::vector<message_center::NotificationItem>& items) { | 59 const std::vector<message_center::NotificationItem>& items) { |
| 60 notification_.set_items(items); | 60 notification_.set_items(items); |
| 61 return *this; | 61 return *this; |
| 62 } | 62 } |
| 63 | 63 |
| 64 NotificationBuilder& SetMessage(const base::string16& message) { |
| 65 notification_.set_message(message); |
| 66 return *this; |
| 67 } |
| 68 |
| 64 NotificationBuilder& SetNeverTimeout(bool never_timeout) { | 69 NotificationBuilder& SetNeverTimeout(bool never_timeout) { |
| 65 notification_.set_never_timeout(never_timeout); | 70 notification_.set_never_timeout(never_timeout); |
| 66 return *this; | 71 return *this; |
| 67 } | 72 } |
| 68 | 73 |
| 74 NotificationBuilder& SetOriginUrl(const GURL& origin_url) { |
| 75 notification_.set_origin_url(origin_url); |
| 76 return *this; |
| 77 } |
| 78 |
| 69 NotificationBuilder& SetProgress(int progress) { | 79 NotificationBuilder& SetProgress(int progress) { |
| 70 notification_.set_progress(progress); | 80 notification_.set_progress(progress); |
| 71 return *this; | 81 return *this; |
| 72 } | 82 } |
| 73 | 83 |
| 74 NotificationBuilder& SetTitle(const base::string16& title) { | 84 NotificationBuilder& SetTitle(const base::string16& title) { |
| 75 notification_.set_title(title); | 85 notification_.set_title(title); |
| 76 return *this; | 86 return *this; |
| 77 } | 87 } |
| 78 | 88 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 mock_bus_.get(), kFreedesktopNotificationsName, | 221 mock_bus_.get(), kFreedesktopNotificationsName, |
| 212 dbus::ObjectPath(kFreedesktopNotificationsPath)); | 222 dbus::ObjectPath(kFreedesktopNotificationsPath)); |
| 213 | 223 |
| 214 EXPECT_CALL(*mock_bus_.get(), | 224 EXPECT_CALL(*mock_bus_.get(), |
| 215 GetObjectProxy(kFreedesktopNotificationsName, | 225 GetObjectProxy(kFreedesktopNotificationsName, |
| 216 dbus::ObjectPath(kFreedesktopNotificationsPath))) | 226 dbus::ObjectPath(kFreedesktopNotificationsPath))) |
| 217 .WillOnce(Return(mock_notification_proxy_.get())); | 227 .WillOnce(Return(mock_notification_proxy_.get())); |
| 218 | 228 |
| 219 EXPECT_CALL(*mock_notification_proxy_.get(), | 229 EXPECT_CALL(*mock_notification_proxy_.get(), |
| 220 MockCallMethodAndBlock(Calls("GetCapabilities"), _)) | 230 MockCallMethodAndBlock(Calls("GetCapabilities"), _)) |
| 221 .WillOnce( | 231 .WillOnce(OnGetCapabilities(std::vector<std::string>{ |
| 222 OnGetCapabilities(std::vector<std::string>{"body", "body-images"})); | 232 "body", "body-hyperlinks", "body-images", "body-markup"})); |
| 223 | 233 |
| 224 EXPECT_CALL(*mock_notification_proxy_.get(), | 234 EXPECT_CALL(*mock_notification_proxy_.get(), |
| 225 MockCallMethodAndBlock(Calls("GetServerInformation"), _)) | 235 MockCallMethodAndBlock(Calls("GetServerInformation"), _)) |
| 226 .WillOnce(OnGetServerInformation("1.2")); | 236 .WillOnce(OnGetServerInformation("1.2")); |
| 227 | 237 |
| 228 EXPECT_CALL( | 238 EXPECT_CALL( |
| 229 *mock_notification_proxy_.get(), | 239 *mock_notification_proxy_.get(), |
| 230 ConnectToSignal(kFreedesktopNotificationsName, "ActionInvoked", _, _)) | 240 ConnectToSignal(kFreedesktopNotificationsName, "ActionInvoked", _, _)) |
| 231 .WillOnce(RegisterSignalCallback(&action_invoked_callback_)); | 241 .WillOnce(RegisterSignalCallback(&action_invoked_callback_)); |
| 232 | 242 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 .SetProgress(42) | 314 .SetProgress(42) |
| 305 .SetTitle(base::UTF8ToUTF16("The Title")) | 315 .SetTitle(base::UTF8ToUTF16("The Title")) |
| 306 .GetResult()); | 316 .GetResult()); |
| 307 } | 317 } |
| 308 | 318 |
| 309 TEST_F(NotificationPlatformBridgeLinuxTest, NotificationListItemsInBody) { | 319 TEST_F(NotificationPlatformBridgeLinuxTest, NotificationListItemsInBody) { |
| 310 EXPECT_CALL(*mock_notification_proxy_.get(), | 320 EXPECT_CALL(*mock_notification_proxy_.get(), |
| 311 MockCallMethodAndBlock(Calls("Notify"), _)) | 321 MockCallMethodAndBlock(Calls("Notify"), _)) |
| 312 .WillOnce(OnNotify( | 322 .WillOnce(OnNotify( |
| 313 [](const NotificationRequest& request) { | 323 [](const NotificationRequest& request) { |
| 314 EXPECT_EQ("abc - 123\ndef - 456", request.body); | 324 EXPECT_EQ("<b>abc</b> 123\n<b>def</b> 456", request.body); |
| 315 }, | 325 }, |
| 316 1)); | 326 1)); |
| 317 | 327 |
| 318 CreateNotificationBridgeLinux(); | 328 CreateNotificationBridgeLinux(); |
| 319 notification_bridge_linux_->Display( | 329 notification_bridge_linux_->Display( |
| 320 NotificationCommon::PERSISTENT, "", "", false, | 330 NotificationCommon::PERSISTENT, "", "", false, |
| 321 NotificationBuilder("") | 331 NotificationBuilder("") |
| 322 .SetType(message_center::NOTIFICATION_TYPE_MULTIPLE) | 332 .SetType(message_center::NOTIFICATION_TYPE_MULTIPLE) |
| 323 .SetItems(std::vector<message_center::NotificationItem>{ | 333 .SetItems(std::vector<message_center::NotificationItem>{ |
| 324 {base::UTF8ToUTF16("abc"), base::UTF8ToUTF16("123")}, | 334 {base::UTF8ToUTF16("abc"), base::UTF8ToUTF16("123")}, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 1)); | 393 1)); |
| 384 | 394 |
| 385 CreateNotificationBridgeLinux(); | 395 CreateNotificationBridgeLinux(); |
| 386 notification_bridge_linux_->Display( | 396 notification_bridge_linux_->Display( |
| 387 NotificationCommon::PERSISTENT, "", "", false, | 397 NotificationCommon::PERSISTENT, "", "", false, |
| 388 NotificationBuilder("") | 398 NotificationBuilder("") |
| 389 .SetType(message_center::NOTIFICATION_TYPE_IMAGE) | 399 .SetType(message_center::NOTIFICATION_TYPE_IMAGE) |
| 390 .SetImage(original_image) | 400 .SetImage(original_image) |
| 391 .GetResult()); | 401 .GetResult()); |
| 392 } | 402 } |
| 403 |
| 404 TEST_F(NotificationPlatformBridgeLinuxTest, NotificationAttribution) { |
| 405 EXPECT_CALL(*mock_notification_proxy_.get(), |
| 406 MockCallMethodAndBlock(Calls("Notify"), _)) |
| 407 .WillOnce(OnNotify( |
| 408 [](const NotificationRequest& request) { |
| 409 EXPECT_EQ( |
| 410 "<a href=\"https%3A//google.com/" |
| 411 "search%3Fq=test&ie=UTF8\">google.com</a>\nBody text", |
| 412 request.body); |
| 413 }, |
| 414 1)); |
| 415 |
| 416 CreateNotificationBridgeLinux(); |
| 417 notification_bridge_linux_->Display( |
| 418 NotificationCommon::PERSISTENT, "", "", false, |
| 419 NotificationBuilder("") |
| 420 .SetMessage(base::ASCIIToUTF16("Body text")) |
| 421 .SetOriginUrl(GURL("https://google.com/search?q=test&ie=UTF8")) |
| 422 .GetResult()); |
| 423 } |
| OLD | NEW |