| Index: test/Notification.cpp |
| =================================================================== |
| --- a/test/Notification.cpp |
| +++ b/test/Notification.cpp |
| @@ -14,20 +14,16 @@ |
| * You should have received a copy of the GNU General Public License |
| * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| */ |
| #include "BaseJsTest.h" |
| using namespace AdblockPlus; |
| -// This define enables NotificationMockWebRequestTest but to run it |
| -// one need to set INITIAL_DELAY to about 2000 msec in notification.js. |
|
sergei
2017/08/23 19:27:22
What about moving of the comment, it's essential t
hub
2017/08/23 19:54:05
Oops. Done.
|
| -//#define NotificationMockWebRequestTest_ENABLED |
| - |
| namespace |
| { |
| class NotificationTest : public BaseJsTest |
| { |
| protected: |
| void SetUp() |
| { |
| LazyFileSystem* fileSystem; |
| @@ -79,66 +75,62 @@ |
| 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(); |
| 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'," |
| "}"); |