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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 1)); | 392 1)); |
383 | 393 |
384 CreateNotificationBridgeLinux(); | 394 CreateNotificationBridgeLinux(); |
385 notification_bridge_linux_->Display( | 395 notification_bridge_linux_->Display( |
386 NotificationCommon::PERSISTENT, "", "", false, | 396 NotificationCommon::PERSISTENT, "", "", false, |
387 NotificationBuilder("") | 397 NotificationBuilder("") |
388 .SetType(message_center::NOTIFICATION_TYPE_IMAGE) | 398 .SetType(message_center::NOTIFICATION_TYPE_IMAGE) |
389 .SetImage(original_image) | 399 .SetImage(original_image) |
390 .GetResult()); | 400 .GetResult()); |
391 } | 401 } |
402 | |
403 TEST_F(NotificationPlatformBridgeLinuxTest, NotificationAttribution) { | |
404 EXPECT_CALL(*mock_notification_proxy_.get(), | |
405 MockCallMethodAndBlock(Calls("Notify"), _)) | |
406 .WillOnce(OnNotify( | |
407 [](const NotificationRequest& request) { | |
408 EXPECT_EQ("Body text\ngoogle.com", request.body); | |
409 }, | |
410 1)); | |
411 | |
412 CreateNotificationBridgeLinux(); | |
413 notification_bridge_linux_->Display( | |
414 NotificationCommon::PERSISTENT, "", "", false, | |
415 NotificationBuilder("") | |
416 .SetMessage(base::UTF8ToUTF16("Body text")) | |
Lei Zhang
2017/05/15 22:19:59
ACIIToUTF16() when you know it's ASCII.
Tom (Use chromium acct)
2017/05/16 04:43:34
Done.
| |
417 .SetOriginUrl(GURL("https://google.com/")) | |
Lei Zhang
2017/05/15 22:19:59
I'm not sure what guarantees the notification subs
Tom (Use chromium acct)
2017/05/16 04:43:34
Done. (maybe)
| |
418 .GetResult()); | |
419 } | |
OLD | NEW |