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

Delta Between Two Patch Sets: test/Notification.cpp

Issue 29525558: Issue 5506 - Fix notification test (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Created Aug. 23, 2017, 4:59 p.m.
Right Patch Set: addressed review comment Created Aug. 23, 2017, 7:53 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 | « no previous file | 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-present eyeo GmbH 3 * Copyright (C) 2006-present 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include "BaseJsTest.h" 18 #include "BaseJsTest.h"
19 19
20 using namespace AdblockPlus; 20 using namespace AdblockPlus;
21
22 // This define enables NotificationMockWebRequestTest but to run it
23 // one need to set INITIAL_DELAY to about 2000 msec in notification.js.
24 //#define NotificationMockWebRequestTest_ENABLED
sergei 2017/08/23 18:00:12 Could you please also remove this define and move
hub 2017/08/23 19:21:56 Done.
25 21
26 namespace 22 namespace
27 { 23 {
28 class NotificationTest : public BaseJsTest 24 class NotificationTest : public BaseJsTest
29 { 25 {
30 protected: 26 protected:
31 void SetUp() 27 void SetUp()
32 { 28 {
33 LazyFileSystem* fileSystem; 29 LazyFileSystem* fileSystem;
34 ThrowingPlatformCreationParameters platformParams; 30 ThrowingPlatformCreationParameters platformParams;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 return; 73 return;
78 } 74 }
79 ServerResponse serverResponse; 75 ServerResponse serverResponse;
80 serverResponse.status = IWebRequest::NS_OK; 76 serverResponse.status = IWebRequest::NS_OK;
81 serverResponse.responseStatus = 200; 77 serverResponse.responseStatus = 200;
82 serverResponse.responseText = responseText; 78 serverResponse.responseText = responseText;
83 getCallback(serverResponse); 79 getCallback(serverResponse);
84 } 80 }
85 }; 81 };
86 82
83
84 // To run this test one needs to set INITIAL_DELAY to about 2000 msec
85 // in notification.js.
87 class NotificationMockWebRequestTest : public BaseJsTest 86 class NotificationMockWebRequestTest : public BaseJsTest
88 { 87 {
89 protected: 88 protected:
90 bool isNotificationCallbackCalled; 89 bool isNotificationCallbackCalled;
91 void SetUp() 90 void SetUp()
92 { 91 {
93 BaseJsTest::SetUp();
sergei 2017/08/23 18:00:12 Since platform is created below could you please r
hub 2017/08/23 19:21:56 Done.
94 isNotificationCallbackCalled = false; 92 isNotificationCallbackCalled = false;
95 const char* responseJsonText = "{" 93 const char* responseJsonText = "{"
96 "\"notifications\": [{" 94 "\"notifications\": [{"
97 "\"id\": \"some id\"," 95 "\"id\": \"some id\","
98 "\"type\": \"information\"," 96 "\"type\": \"information\","
99 "\"message\": {" 97 "\"message\": {"
100 "\"en-US\": \"message\"" 98 "\"en-US\": \"message\""
101 "}," 99 "},"
102 "\"title\": \"Title\"" 100 "\"title\": \"Title\""
103 "}]" 101 "}]"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 TEST_F(NotificationTest, Links) 188 TEST_F(NotificationTest, Links)
191 { 189 {
192 AddNotification("{ id: 'id', links: ['link1', 'link2'] }"); 190 AddNotification("{ id: 'id', links: ['link1', 'link2'] }");
193 auto notification = PeekNotification(); 191 auto notification = PeekNotification();
194 ASSERT_TRUE(notification); 192 ASSERT_TRUE(notification);
195 std::vector<std::string> notificationLinks = notification->GetLinks(); 193 std::vector<std::string> notificationLinks = notification->GetLinks();
196 ASSERT_EQ(2u, notificationLinks.size()); 194 ASSERT_EQ(2u, notificationLinks.size());
197 EXPECT_EQ("link1", notificationLinks[0]); 195 EXPECT_EQ("link1", notificationLinks[0]);
198 EXPECT_EQ("link2", notificationLinks[1]); 196 EXPECT_EQ("link2", notificationLinks[1]);
199 } 197 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld