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

Side by Side Diff: test/Notification.cpp

Issue 29497591: Issue 5180 - remove synchronous WebRequest interface and stop exposing of DefaultWebRequest (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 25, 2017, 2:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/WebRequestJsObject.cpp ('k') | test/WebRequest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 filterEngine->SetShowNotificationCallback( 56 filterEngine->SetShowNotificationCallback(
57 [&retValue](Notification&& notification) { 57 [&retValue](Notification&& notification) {
58 retValue.reset(new Notification(std::move(notification))); 58 retValue.reset(new Notification(std::move(notification)));
59 }); 59 });
60 filterEngine->ShowNextNotification(url); 60 filterEngine->ShowNextNotification(url);
61 filterEngine->RemoveShowNotificationCallback(); 61 filterEngine->RemoveShowNotificationCallback();
62 return retValue; 62 return retValue;
63 } 63 }
64 }; 64 };
65 65
66 class MockWebRequest : public WebRequest 66 class MockWebRequest : public IWebRequest
67 { 67 {
68 public: 68 public:
69 std::string responseText; 69 std::string responseText;
70 explicit MockWebRequest(const std::string& notification) 70 explicit MockWebRequest(const std::string& notification)
71 : responseText(notification) 71 : responseText(notification)
72 { 72 {
73 } 73 }
74 ServerResponse GET(const std::string& url, 74 void GET(const std::string& url, const HeaderList& requestHeaders,
75 const HeaderList& requestHeaders) const 75 const GetCallback& getCallback) override
76 { 76 {
77 if (url.find("/notification.json") == std::string::npos) 77 if (url.find("/notification.json") == std::string::npos)
78 { 78 {
79 return ServerResponse(); 79 return;
80 } 80 }
81 ServerResponse serverResponse; 81 ServerResponse serverResponse;
82 serverResponse.status = IWebRequest::NS_OK; 82 serverResponse.status = IWebRequest::NS_OK;
83 serverResponse.responseStatus = 200; 83 serverResponse.responseStatus = 200;
84 serverResponse.responseText = responseText; 84 serverResponse.responseText = responseText;
85 return serverResponse; 85 getCallback(serverResponse);
86 } 86 }
87 }; 87 };
88 88
89 #ifdef NotificationMockWebRequestTest_ENABLED 89 #ifdef NotificationMockWebRequestTest_ENABLED
90 class NotificationMockWebRequestTest : public BaseJsTest 90 class NotificationMockWebRequestTest : public BaseJsTest
91 { 91 {
92 protected: 92 protected:
93 FilterEnginePtr filterEngine; 93 FilterEnginePtr filterEngine;
94 bool isNotificationCallbackCalled; 94 bool isNotificationCallbackCalled;
95 void SetUp() 95 void SetUp()
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 TEST_F(NotificationTest, Links) 196 TEST_F(NotificationTest, Links)
197 { 197 {
198 AddNotification("{ id: 'id', links: ['link1', 'link2'] }"); 198 AddNotification("{ id: 'id', links: ['link1', 'link2'] }");
199 auto notification = PeekNotification(); 199 auto notification = PeekNotification();
200 ASSERT_TRUE(notification); 200 ASSERT_TRUE(notification);
201 std::vector<std::string> notificationLinks = notification->GetLinks(); 201 std::vector<std::string> notificationLinks = notification->GetLinks();
202 ASSERT_EQ(2u, notificationLinks.size()); 202 ASSERT_EQ(2u, notificationLinks.size());
203 EXPECT_EQ("link1", notificationLinks[0]); 203 EXPECT_EQ("link1", notificationLinks[0]);
204 EXPECT_EQ("link2", notificationLinks[1]); 204 EXPECT_EQ("link2", notificationLinks[1]);
205 } 205 }
OLDNEW
« no previous file with comments | « src/WebRequestJsObject.cpp ('k') | test/WebRequest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld