| Index: test/Notification.cpp | 
| =================================================================== | 
| --- a/test/Notification.cpp | 
| +++ b/test/Notification.cpp | 
| @@ -43,32 +43,27 @@ | 
| void AddNotification(const std::string& notification) | 
| { | 
| jsEngine->Evaluate("(function()" | 
| "{" | 
| "require('notification').Notification.addNotification(" + notification + ");" | 
| "})();"); | 
| } | 
| - NotificationPtr PeekNotification(const std::string& url = std::string()) | 
| + std::unique_ptr<Notification> PeekNotification(const std::string& url = std::string()) | 
| { | 
| - NotificationPtr retValue; | 
| - filterEngine->SetShowNotificationCallback(std::bind( | 
| - &NotificationTest::NotificationAvailableCallback, | 
| - std::placeholders::_1, std::ref(retValue))); | 
| + std::unique_ptr<Notification> retValue; | 
| + filterEngine->SetShowNotificationCallback( | 
| + [&retValue](Notification& notification) { | 
| + retValue.reset(new Notification(std::move(notification))); | 
| + }); | 
| filterEngine->ShowNextNotification(url); | 
| filterEngine->RemoveShowNotificationCallback(); | 
| return retValue; | 
| } | 
| - | 
| - static void NotificationAvailableCallback(const NotificationPtr& src, NotificationPtr& dst) | 
| - { | 
| - EXPECT_TRUE(src); | 
| - dst = src; | 
| - } | 
| }; | 
| class MockWebRequest : public WebRequest | 
| { | 
| public: | 
| std::string responseText; | 
| explicit MockWebRequest(const std::string& notification) | 
| : responseText(notification) | 
| @@ -109,30 +104,25 @@ | 
| "\"en-US\": \"message\"" | 
| "}," | 
| "\"title\": \"Title\"" | 
| "}]" | 
| "}"; | 
| jsEngine->SetWebRequest(std::shared_ptr<MockWebRequest>( | 
| new MockWebRequest(responseJsonText))); | 
| jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem())); | 
| - filterEngine.reset(new FilterEngine(jsEngine)); | 
| + filterEngine = FilterEngine::Create(jsEngine); | 
| filterEngine->SetShowNotificationCallback( | 
| - std::bind(&NotificationMockWebRequestTest::OnNotification, | 
| - this, std::placeholders::_1)); | 
| - } | 
| - | 
| - void OnNotification(const NotificationPtr& notification) | 
| - { | 
| - isNotificationCallbackCalled = true; | 
| - ASSERT_TRUE(notification); | 
| - EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_INFORMATION, notification->GetType()); | 
| - EXPECT_EQ("Title", notification->GetTexts().title); | 
| - EXPECT_EQ("message", notification->GetTexts().message); | 
| - notification->MarkAsShown(); | 
| + [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()); | 
| @@ -148,66 +138,66 @@ | 
| TEST_F(NotificationTest, AddNotification) | 
| { | 
| AddNotification("{" | 
| "type: 'critical'," | 
| "title: 'testTitle'," | 
| "message: 'testMessage'," | 
| "}"); | 
| - NotificationPtr notification = PeekNotification(); | 
| + auto notification = PeekNotification(); | 
| ASSERT_TRUE(notification); | 
| EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_CRITICAL, notification->GetType()); | 
| EXPECT_EQ("testTitle", notification->GetTexts().title); | 
| EXPECT_EQ("testMessage", notification->GetTexts().message); | 
| } | 
| TEST_F(NotificationTest, FilterByUrl) | 
| { | 
| AddNotification("{ id: 'no-filter', type: 'critical' }"); | 
| AddNotification("{ id: 'www.com', type: 'information'," | 
| "urlFilters:['||www.com$document']" | 
| "}"); | 
| AddNotification("{ id: 'www.de', type: 'question'," | 
| "urlFilters:['||www.de$document']" | 
| "}"); | 
| - NotificationPtr notification = PeekNotification(); | 
| + auto notification = PeekNotification(); | 
| ASSERT_TRUE(notification); | 
| EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_CRITICAL, notification->GetType()); | 
| notification = PeekNotification("http://www.de"); | 
| ASSERT_TRUE(notification); | 
| EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_QUESTION, notification->GetType()); | 
| notification = PeekNotification("http://www.com"); | 
| ASSERT_TRUE(notification); | 
| EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_INFORMATION, notification->GetType()); | 
| } | 
| TEST_F(NotificationTest, MarkAsShown) | 
| { | 
| AddNotification("{ id: 'id', type: 'question' }"); | 
| EXPECT_TRUE(PeekNotification()); | 
| - NotificationPtr notification = PeekNotification(); | 
| + auto notification = PeekNotification(); | 
| ASSERT_TRUE(notification); | 
| notification->MarkAsShown(); | 
| EXPECT_FALSE(PeekNotification()); | 
| } | 
| TEST_F(NotificationTest, NoLinks) | 
| { | 
| AddNotification("{ id: 'id'}"); | 
| - NotificationPtr notification = PeekNotification(); | 
| + auto notification = PeekNotification(); | 
| ASSERT_TRUE(notification); | 
| EXPECT_EQ(0u, notification->GetLinks().size()); | 
| } | 
| TEST_F(NotificationTest, Links) | 
| { | 
| AddNotification("{ id: 'id', links: ['link1', 'link2'] }"); | 
| - NotificationPtr notification = PeekNotification(); | 
| + auto notification = PeekNotification(); | 
| ASSERT_TRUE(notification); | 
| std::vector<std::string> notificationLinks = notification->GetLinks(); | 
| ASSERT_EQ(2u, notificationLinks.size()); | 
| EXPECT_EQ("link1", notificationLinks[0]); | 
| EXPECT_EQ("link2", notificationLinks[1]); | 
| } |