| OLD | NEW |
| 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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 filterEngine->SetShowNotificationCallback( | 118 filterEngine->SetShowNotificationCallback( |
| 119 std::bind(&NotificationMockWebRequestTest::OnNotification, | 119 std::bind(&NotificationMockWebRequestTest::OnNotification, |
| 120 this, std::placeholders::_1)); | 120 this, std::placeholders::_1)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void OnNotification(const NotificationPtr& notification) | 123 void OnNotification(const NotificationPtr& notification) |
| 124 { | 124 { |
| 125 isNotificationCallbackCalled = true; | 125 isNotificationCallbackCalled = true; |
| 126 ASSERT_TRUE(notification); | 126 ASSERT_TRUE(notification); |
| 127 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_INFORMATION, notification->G
etType()); | 127 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_INFORMATION, notification->G
etType()); |
| 128 EXPECT_EQ("Title", notification->GetTitle()); | 128 EXPECT_EQ("Title", notification->GetTexts().title); |
| 129 EXPECT_EQ("message", notification->GetMessageString()); | 129 EXPECT_EQ("message", notification->GetTexts().message); |
| 130 notification->MarkAsShown(); | 130 notification->MarkAsShown(); |
| 131 } | 131 } |
| 132 }; | 132 }; |
| 133 #endif | 133 #endif |
| 134 } | 134 } |
| 135 | 135 |
| 136 TEST_F(NotificationTest, NoNotifications) | 136 TEST_F(NotificationTest, NoNotifications) |
| 137 { | 137 { |
| 138 EXPECT_FALSE(PeekNotification()); | 138 EXPECT_FALSE(PeekNotification()); |
| 139 } | 139 } |
| 140 | 140 |
| 141 #ifdef NotificationMockWebRequestTest_ENABLED | 141 #ifdef NotificationMockWebRequestTest_ENABLED |
| 142 TEST_F(NotificationMockWebRequestTest, SingleNotification) | 142 TEST_F(NotificationMockWebRequestTest, SingleNotification) |
| 143 { | 143 { |
| 144 AdblockPlus::Sleep(5000/*msec*/); // it's a hack | 144 AdblockPlus::Sleep(5000/*msec*/); // it's a hack |
| 145 EXPECT_TRUE(isNotificationCallbackCalled); | 145 EXPECT_TRUE(isNotificationCallbackCalled); |
| 146 } | 146 } |
| 147 #endif | 147 #endif |
| 148 | 148 |
| 149 TEST_F(NotificationTest, AddNotification) | 149 TEST_F(NotificationTest, AddNotification) |
| 150 { | 150 { |
| 151 AddNotification("{" | 151 AddNotification("{" |
| 152 "type: 'critical'," | 152 "type: 'critical'," |
| 153 "title: 'testTitle'," | 153 "title: 'testTitle'," |
| 154 "message: 'testMessage'," | 154 "message: 'testMessage'," |
| 155 "}"); | 155 "}"); |
| 156 NotificationPtr notification = PeekNotification(); | 156 NotificationPtr notification = PeekNotification(); |
| 157 ASSERT_TRUE(notification); | 157 ASSERT_TRUE(notification); |
| 158 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_CRITICAL, notification->GetType(
)); | 158 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_CRITICAL, notification->GetType(
)); |
| 159 EXPECT_EQ("testTitle", notification->GetTitle()); | 159 EXPECT_EQ("testTitle", notification->GetTexts().title); |
| 160 EXPECT_EQ("testMessage", notification->GetMessageString()); | 160 EXPECT_EQ("testMessage", notification->GetTexts().message); |
| 161 } | 161 } |
| 162 | 162 |
| 163 TEST_F(NotificationTest, FilterByUrl) | 163 TEST_F(NotificationTest, FilterByUrl) |
| 164 { | 164 { |
| 165 AddNotification("{ id: 'no-filter', type: 'critical' }"); | 165 AddNotification("{ id: 'no-filter', type: 'critical' }"); |
| 166 AddNotification("{ id: 'www.com', type: 'information'," | 166 AddNotification("{ id: 'www.com', type: 'information'," |
| 167 "urlFilters:['||www.com$document']" | 167 "urlFilters:['||www.com$document']" |
| 168 "}"); | 168 "}"); |
| 169 AddNotification("{ id: 'www.de', type: 'question'," | 169 AddNotification("{ id: 'www.de', type: 'question'," |
| 170 "urlFilters:['||www.de$document']" | 170 "urlFilters:['||www.de$document']" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 TEST_F(NotificationTest, Links) | 204 TEST_F(NotificationTest, Links) |
| 205 { | 205 { |
| 206 AddNotification("{ id: 'id', links: ['link1', 'link2'] }"); | 206 AddNotification("{ id: 'id', links: ['link1', 'link2'] }"); |
| 207 NotificationPtr notification = PeekNotification(); | 207 NotificationPtr notification = PeekNotification(); |
| 208 ASSERT_TRUE(notification); | 208 ASSERT_TRUE(notification); |
| 209 std::vector<std::string> notificationLinks = notification->GetLinks(); | 209 std::vector<std::string> notificationLinks = notification->GetLinks(); |
| 210 ASSERT_EQ(2, notificationLinks.size()); | 210 ASSERT_EQ(2, notificationLinks.size()); |
| 211 EXPECT_EQ("link1", notificationLinks[0]); | 211 EXPECT_EQ("link1", notificationLinks[0]); |
| 212 EXPECT_EQ("link2", notificationLinks[1]); | 212 EXPECT_EQ("link2", notificationLinks[1]); |
| 213 } | 213 } |
| OLD | NEW |