| 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 19 matching lines...) Expand all Loading... |
| 30 class NotificationTest : public BaseJsTest | 30 class NotificationTest : public BaseJsTest |
| 31 { | 31 { |
| 32 protected: | 32 protected: |
| 33 FilterEnginePtr filterEngine; | 33 FilterEnginePtr filterEngine; |
| 34 void SetUp() override | 34 void SetUp() override |
| 35 { | 35 { |
| 36 BaseJsTest::SetUp(); | 36 BaseJsTest::SetUp(); |
| 37 jsEngine->SetFileSystem(FileSystemPtr(new LazyFileSystem())); | 37 jsEngine->SetFileSystem(FileSystemPtr(new LazyFileSystem())); |
| 38 jsEngine->SetWebRequest(WebRequestPtr(new LazyWebRequest())); | 38 jsEngine->SetWebRequest(WebRequestPtr(new LazyWebRequest())); |
| 39 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem())); | 39 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem())); |
| 40 filterEngine = std::tr1::make_shared<FilterEngine>(jsEngine); | 40 filterEngine.reset(new FilterEngine(jsEngine)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void AddNotification(const std::string& notification) | 43 void AddNotification(const std::string& notification) |
| 44 { | 44 { |
| 45 jsEngine->Evaluate("(function()" | 45 jsEngine->Evaluate("(function()" |
| 46 "{" | 46 "{" |
| 47 "require('notification').Notification.addNotification(" + notification +
");" | 47 "require('notification').Notification.addNotification(" + notification +
");" |
| 48 "})();"); | 48 "})();"); |
| 49 } | 49 } |
| 50 }; | 50 }; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 #ifdef NotificationMockWebRequestTest_ENABLED | 75 #ifdef NotificationMockWebRequestTest_ENABLED |
| 76 class NotificationMockWebRequestTest : public BaseJsTest | 76 class NotificationMockWebRequestTest : public BaseJsTest |
| 77 { | 77 { |
| 78 protected: | 78 protected: |
| 79 FilterEnginePtr filterEngine; | 79 FilterEnginePtr filterEngine; |
| 80 void SetUp() override | 80 void SetUp() override |
| 81 { | 81 { |
| 82 BaseJsTest::SetUp(); | 82 BaseJsTest::SetUp(); |
| 83 jsEngine->SetFileSystem(std::tr1::make_shared<LazyFileSystem>()); | 83 jsEngine->SetFileSystem( |
| 84 std::tr1::shared_ptr<LazyFileSystem>(new LazyFileSystem())); |
| 84 const char* responseJsonText = "{" | 85 const char* responseJsonText = "{" |
| 85 "\"notifications\": [{" | 86 "\"notifications\": [{" |
| 86 "\"id\": \"some id\"," | 87 "\"id\": \"some id\"," |
| 87 "\"type\": \"information\"," | 88 "\"type\": \"information\"," |
| 88 "\"message\": {" | 89 "\"message\": {" |
| 89 "\"en-US\": \"message\"" | 90 "\"en-US\": \"message\"" |
| 90 "}," | 91 "}," |
| 91 "\"title\": \"Title\"" | 92 "\"title\": \"Title\"" |
| 92 "}]" | 93 "}]" |
| 93 "}"; | 94 "}"; |
| 94 jsEngine->SetWebRequest(std::tr1::make_shared<MockWebRequest>(responseJson
Text)); | 95 jsEngine->SetWebRequest(std::tr1::shared_ptr<MockWebRequest>( |
| 96 new MockWebRequest(responseJsonText))); |
| 95 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem())); | 97 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem())); |
| 96 filterEngine = std::tr1::make_shared<FilterEngine>(jsEngine); | 98 filterEngine.reset(new FilterEngine(jsEngine)); |
| 97 } | 99 } |
| 98 }; | 100 }; |
| 99 #endif | 101 #endif |
| 100 } | 102 } |
| 101 | 103 |
| 102 TEST_F(NotificationTest, NoNotifications) | 104 TEST_F(NotificationTest, NoNotifications) |
| 103 { | 105 { |
| 104 NotificationPtr notification = filterEngine->GetNextNotificationToShow(); | 106 NotificationPtr notification = filterEngine->GetNextNotificationToShow(); |
| 105 EXPECT_EQ(NULL, notification.get()); | 107 EXPECT_EQ(NULL, notification.get()); |
| 106 } | 108 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 161 |
| 160 TEST_F(NotificationTest, MarkAsShown) | 162 TEST_F(NotificationTest, MarkAsShown) |
| 161 { | 163 { |
| 162 AddNotification("{ id: 'id', type: 'question' }"); | 164 AddNotification("{ id: 'id', type: 'question' }"); |
| 163 NotificationPtr notification = filterEngine->GetNextNotificationToShow(); | 165 NotificationPtr notification = filterEngine->GetNextNotificationToShow(); |
| 164 EXPECT_TRUE(notification); | 166 EXPECT_TRUE(notification); |
| 165 notification = filterEngine->GetNextNotificationToShow(); | 167 notification = filterEngine->GetNextNotificationToShow(); |
| 166 ASSERT_TRUE(notification); | 168 ASSERT_TRUE(notification); |
| 167 notification->MarkAsShown(); | 169 notification->MarkAsShown(); |
| 168 EXPECT_EQ(NULL, filterEngine->GetNextNotificationToShow().get()); | 170 EXPECT_EQ(NULL, filterEngine->GetNextNotificationToShow().get()); |
| 169 } | 171 } |
| OLD | NEW |