Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: test/Notification.cpp

Issue 29419629: Issue 5164 - Remove NotificationPtr (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Fix test, reconsolidate lambdas as per review Created April 21, 2017, 6:37 p.m.
Right Patch Set: Call the inherited assignment operator properly Created April 24, 2017, 8:16 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/Notification.cpp ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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](const Notification& notification) { 55 [&retValue](Notification& notification) {
56 retValue.reset(new Notification(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 {
66 public: 66 public:
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 auto notification = PeekNotification(); 163 auto notification = PeekNotification();
164 ASSERT_TRUE(notification); 164 ASSERT_TRUE(notification);
165 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_CRITICAL, notification->GetType( )); 165 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_CRITICAL, notification->GetType( ));
166 166
167 notification = PeekNotification("http://www.de"); 167 notification = PeekNotification("http://www.de");
168 ASSERT_TRUE(notification); 168 ASSERT_TRUE(notification);
169 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_QUESTION, notification->GetType( )); 169 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_QUESTION, notification->GetType( ));
170 170
171 notification = PeekNotification("http://www.com"); 171 notification = PeekNotification("http://www.com");
172 EXPECT_TRUE(notification); 172 ASSERT_TRUE(notification);
sergei 2017/04/24 08:20:28 Here should be assert.
hub 2017/04/24 13:55:00 Acknowledged.
173 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_INFORMATION, notification->GetTy pe()); 173 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_INFORMATION, notification->GetTy pe());
174 } 174 }
175 175
176 TEST_F(NotificationTest, MarkAsShown) 176 TEST_F(NotificationTest, MarkAsShown)
177 { 177 {
178 AddNotification("{ id: 'id', type: 'question' }"); 178 AddNotification("{ id: 'id', type: 'question' }");
179 EXPECT_TRUE(PeekNotification()); 179 EXPECT_TRUE(PeekNotification());
180 auto notification = PeekNotification(); 180 auto notification = PeekNotification();
181 ASSERT_TRUE(notification);
181 notification->MarkAsShown(); 182 notification->MarkAsShown();
182 EXPECT_FALSE(PeekNotification()); 183 EXPECT_FALSE(PeekNotification());
183 } 184 }
184 185
185 TEST_F(NotificationTest, NoLinks) 186 TEST_F(NotificationTest, NoLinks)
186 { 187 {
187 AddNotification("{ id: 'id'}"); 188 AddNotification("{ id: 'id'}");
188 auto notification = PeekNotification(); 189 auto notification = PeekNotification();
189 ASSERT_TRUE(notification); 190 ASSERT_TRUE(notification);
190 EXPECT_EQ(0u, notification->GetLinks().size()); 191 EXPECT_EQ(0u, notification->GetLinks().size());
191 } 192 }
192 193
193 TEST_F(NotificationTest, Links) 194 TEST_F(NotificationTest, Links)
194 { 195 {
195 AddNotification("{ id: 'id', links: ['link1', 'link2'] }"); 196 AddNotification("{ id: 'id', links: ['link1', 'link2'] }");
196 auto notification = PeekNotification(); 197 auto notification = PeekNotification();
197 ASSERT_TRUE(notification); 198 ASSERT_TRUE(notification);
198 std::vector<std::string> notificationLinks = notification->GetLinks(); 199 std::vector<std::string> notificationLinks = notification->GetLinks();
199 ASSERT_EQ(2u, notificationLinks.size()); 200 ASSERT_EQ(2u, notificationLinks.size());
200 EXPECT_EQ("link1", notificationLinks[0]); 201 EXPECT_EQ("link1", notificationLinks[0]);
201 EXPECT_EQ("link2", notificationLinks[1]); 202 EXPECT_EQ("link2", notificationLinks[1]);
202 } 203 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld