Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/browser/notifications/notification_platform_bridge_linux_unittest.cc

Issue 2876603004: Linux native notifications: Add attribution (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 new MockNotificationDelegate(id)) {} 46 new MockNotificationDelegate(id)) {}
47 47
48 Notification GetResult() { return notification_; } 48 Notification GetResult() { return notification_; }
49 49
50 NotificationBuilder& SetItems( 50 NotificationBuilder& SetItems(
51 const std::vector<message_center::NotificationItem>& items) { 51 const std::vector<message_center::NotificationItem>& items) {
52 notification_.set_items(items); 52 notification_.set_items(items);
53 return *this; 53 return *this;
54 } 54 }
55 55
56 NotificationBuilder& SetMessage(const base::string16& message) {
57 notification_.set_message(message);
58 return *this;
59 }
60
56 NotificationBuilder& SetNeverTimeout(bool never_timeout) { 61 NotificationBuilder& SetNeverTimeout(bool never_timeout) {
57 notification_.set_never_timeout(never_timeout); 62 notification_.set_never_timeout(never_timeout);
58 return *this; 63 return *this;
59 } 64 }
60 65
66 NotificationBuilder& SetOriginUrl(const GURL& origin_url) {
67 notification_.set_origin_url(origin_url);
68 return *this;
69 }
70
61 NotificationBuilder& SetProgress(int progress) { 71 NotificationBuilder& SetProgress(int progress) {
62 notification_.set_progress(progress); 72 notification_.set_progress(progress);
63 return *this; 73 return *this;
64 } 74 }
65 75
66 NotificationBuilder& SetTitle(const base::string16& title) { 76 NotificationBuilder& SetTitle(const base::string16& title) {
67 notification_.set_title(title); 77 notification_.set_title(title);
68 return *this; 78 return *this;
69 } 79 }
70 80
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 2)); 332 2));
323 333
324 CreateNotificationBridgeLinux(); 334 CreateNotificationBridgeLinux();
325 notification_bridge_linux_->Display( 335 notification_bridge_linux_->Display(
326 NotificationCommon::PERSISTENT, "", "", false, 336 NotificationCommon::PERSISTENT, "", "", false,
327 NotificationBuilder("1").SetNeverTimeout(false).GetResult()); 337 NotificationBuilder("1").SetNeverTimeout(false).GetResult());
328 notification_bridge_linux_->Display( 338 notification_bridge_linux_->Display(
329 NotificationCommon::PERSISTENT, "", "", false, 339 NotificationCommon::PERSISTENT, "", "", false,
330 NotificationBuilder("2").SetNeverTimeout(true).GetResult()); 340 NotificationBuilder("2").SetNeverTimeout(true).GetResult());
331 } 341 }
342
343 TEST_F(NotificationPlatformBridgeLinuxTest, NotificationAttribution) {
344 EXPECT_CALL(*mock_notification_proxy_.get(),
345 MockCallMethodAndBlock(Calls("Notify"), _))
346 .WillOnce(OnNotify(
347 [](const NotificationRequest& request) {
348 EXPECT_EQ("Body text\ngoogle.com", request.body);
349 },
350 1));
351
352 CreateNotificationBridgeLinux();
353 notification_bridge_linux_->Display(
354 NotificationCommon::PERSISTENT, "", "", false,
355 NotificationBuilder("")
356 .SetMessage(base::UTF8ToUTF16("Body text"))
357 .SetOriginUrl(GURL("https://google.com/"))
358 .GetResult());
359 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698