| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 jsEngine->Evaluate("(function()" | 45 jsEngine->Evaluate("(function()" |
| 46 "{" | 46 "{" |
| 47 "require('notification').Notification.addNotification(" + notification +
");" | 47 "require('notification').Notification.addNotification(" + notification +
");" |
| 48 "})();"); | 48 "})();"); |
| 49 } | 49 } |
| 50 | 50 |
| 51 std::unique_ptr<Notification> PeekNotification(const std::string& url = std:
:string()) | 51 std::unique_ptr<Notification> PeekNotification(const std::string& url = std:
:string()) |
| 52 { | 52 { |
| 53 std::unique_ptr<Notification> retValue; | 53 std::unique_ptr<Notification> retValue; |
| 54 filterEngine->SetShowNotificationCallback( | 54 filterEngine->SetShowNotificationCallback( |
| 55 [&retValue](Notification& notification) { | 55 [&retValue](Notification&& notification) { |
| 56 retValue.reset(new Notification(std::move(notification))); | 56 retValue.reset(new Notification(std::move(notification))); |
| 57 }); | 57 }); |
| 58 filterEngine->ShowNextNotification(url); | 58 filterEngine->ShowNextNotification(url); |
| 59 filterEngine->RemoveShowNotificationCallback(); | 59 filterEngine->RemoveShowNotificationCallback(); |
| 60 return retValue; | 60 return retValue; |
| 61 } | 61 } |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 class MockWebRequest : public WebRequest | 64 class MockWebRequest : public WebRequest |
| 65 { | 65 { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 "\"en-US\": \"message\"" | 104 "\"en-US\": \"message\"" |
| 105 "}," | 105 "}," |
| 106 "\"title\": \"Title\"" | 106 "\"title\": \"Title\"" |
| 107 "}]" | 107 "}]" |
| 108 "}"; | 108 "}"; |
| 109 jsEngine->SetWebRequest(std::shared_ptr<MockWebRequest>( | 109 jsEngine->SetWebRequest(std::shared_ptr<MockWebRequest>( |
| 110 new MockWebRequest(responseJsonText))); | 110 new MockWebRequest(responseJsonText))); |
| 111 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem())); | 111 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem())); |
| 112 filterEngine = FilterEngine::Create(jsEngine); | 112 filterEngine = FilterEngine::Create(jsEngine); |
| 113 filterEngine->SetShowNotificationCallback( | 113 filterEngine->SetShowNotificationCallback( |
| 114 [this](Notification& notification) { | 114 [this](Notification&& notification) { |
| 115 isNotificationCallbackCalled = true; | 115 isNotificationCallbackCalled = true; |
| 116 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_INFORMATION, notificatio
n.GetType()); | 116 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_INFORMATION, notificatio
n.GetType()); |
| 117 EXPECT_EQ("Title", notification.GetTexts().title); | 117 EXPECT_EQ("Title", notification.GetTexts().title); |
| 118 EXPECT_EQ("message", notification.GetTexts().message); | 118 EXPECT_EQ("message", notification.GetTexts().message); |
| 119 notification.MarkAsShown(); | 119 notification.MarkAsShown(); |
| 120 }); | 120 }); |
| 121 } | 121 } |
| 122 }; | 122 }; |
| 123 #endif | 123 #endif |
| 124 } | 124 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 TEST_F(NotificationTest, Links) | 194 TEST_F(NotificationTest, Links) |
| 195 { | 195 { |
| 196 AddNotification("{ id: 'id', links: ['link1', 'link2'] }"); | 196 AddNotification("{ id: 'id', links: ['link1', 'link2'] }"); |
| 197 auto notification = PeekNotification(); | 197 auto notification = PeekNotification(); |
| 198 ASSERT_TRUE(notification); | 198 ASSERT_TRUE(notification); |
| 199 std::vector<std::string> notificationLinks = notification->GetLinks(); | 199 std::vector<std::string> notificationLinks = notification->GetLinks(); |
| 200 ASSERT_EQ(2u, notificationLinks.size()); | 200 ASSERT_EQ(2u, notificationLinks.size()); |
| 201 EXPECT_EQ("link1", notificationLinks[0]); | 201 EXPECT_EQ("link1", notificationLinks[0]); |
| 202 EXPECT_EQ("link2", notificationLinks[1]); | 202 EXPECT_EQ("link2", notificationLinks[1]); |
| 203 } | 203 } |
| OLD | NEW |