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

Unified Diff: test/Notification.cpp

Issue 29525558: Issue 5506 - Fix notification test (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Created Aug. 23, 2017, 4:59 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/Notification.cpp
===================================================================
--- a/test/Notification.cpp
+++ b/test/Notification.cpp
@@ -79,66 +79,63 @@
ServerResponse serverResponse;
serverResponse.status = IWebRequest::NS_OK;
serverResponse.responseStatus = 200;
serverResponse.responseText = responseText;
getCallback(serverResponse);
}
};
-#ifdef NotificationMockWebRequestTest_ENABLED
class NotificationMockWebRequestTest : public BaseJsTest
{
protected:
bool isNotificationCallbackCalled;
void SetUp()
{
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.
isNotificationCallbackCalled = false;
- jsEngine->SetFileSystem(
- std::shared_ptr<LazyFileSystem>(new LazyFileSystem()));
const char* responseJsonText = "{"
"\"notifications\": [{"
"\"id\": \"some id\","
"\"type\": \"information\","
"\"message\": {"
"\"en-US\": \"message\""
"},"
"\"title\": \"Title\""
"}]"
"}";
- jsEngine->SetWebRequest(std::shared_ptr<MockWebRequest>(
- new MockWebRequest(responseJsonText)));
- jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem()));
- filterEngine = FilterEngine::Create(jsEngine);
- filterEngine->SetShowNotificationCallback(
+
+ ThrowingPlatformCreationParameters platformParams;
+ platformParams.fileSystem.reset(new LazyFileSystem());
+ platformParams.webRequest.reset(new MockWebRequest(responseJsonText));
+ platform.reset(new Platform(std::move(platformParams)));
+
+ auto& filterEngine = platform->GetFilterEngine();
+ filterEngine.SetShowNotificationCallback(
[this](Notification&& notification) {
isNotificationCallbackCalled = true;
EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_INFORMATION, notification.GetType());
EXPECT_EQ("Title", notification.GetTexts().title);
EXPECT_EQ("message", notification.GetTexts().message);
notification.MarkAsShown();
});
}
};
-#endif
}
TEST_F(NotificationTest, NoNotifications)
{
EXPECT_FALSE(PeekNotification());
}
-#ifdef NotificationMockWebRequestTest_ENABLED
-TEST_F(NotificationMockWebRequestTest, SingleNotification)
+TEST_F(NotificationMockWebRequestTest, DISABLED_SingleNotification)
{
AdblockPlus::Sleep(5000/*msec*/); // it's a hack
EXPECT_TRUE(isNotificationCallbackCalled);
}
-#endif
TEST_F(NotificationTest, AddNotification)
{
AddNotification("{"
"type: 'critical',"
"title: 'testTitle',"
"message: 'testMessage',"
"}");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld