| Index: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/NotificationTest.java |
| =================================================================== |
| --- a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/NotificationTest.java |
| +++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/NotificationTest.java |
| @@ -12,30 +12,23 @@ |
| * GNU General Public License for more details. |
| * |
| * You should have received a copy of the GNU General Public License |
| * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| */ |
| package org.adblockplus.libadblockplus.tests; |
| -import android.util.Log; |
| import org.adblockplus.libadblockplus.FilterEngine; |
| -import org.adblockplus.libadblockplus.HeaderEntry; |
| -import org.adblockplus.libadblockplus.LazyLogSystem; |
| import org.adblockplus.libadblockplus.LazyWebRequest; |
| import org.adblockplus.libadblockplus.Notification; |
| -import org.adblockplus.libadblockplus.ServerResponse; |
| import org.adblockplus.libadblockplus.ShowNotificationCallback; |
| -import org.adblockplus.libadblockplus.WebRequest; |
| import org.junit.Test; |
| -import java.util.List; |
| - |
| public class NotificationTest extends BaseJsTest { |
| protected FilterEngine filterEngine; |
| @Override |
| protected void setUp() throws Exception { |
| super.setUp(); |
| @@ -61,57 +54,29 @@ |
| public Notification getRetValue() |
| { |
| return retValue; |
| } |
| @Override |
| public void showNotificationCallback(Notification notification) |
| { |
| - Log.d(TAG, this + " received [" + notification + "]"); |
| retValue = notification; |
| } |
| } |
| protected Notification peekNotification(String url) throws InterruptedException |
| { |
| - Log.d(TAG, "Start peek"); |
| - |
| LocalShowNotificationCallback callback = new LocalShowNotificationCallback(); |
| - Log.d(TAG, "set callback " + callback); |
| filterEngine.setShowNotificationCallback(callback); |
| filterEngine.showNextNotification(url); |
| filterEngine.removeShowNotificationCallback(); |
| - Log.d(TAG, "removed callback"); |
| return callback.getRetValue(); |
| } |
| - private class MockWebRequest extends WebRequest |
| - { |
| - private String responseText; |
| - |
| - public MockWebRequest(String responseText) |
| - { |
| - this.responseText = responseText; |
| - } |
| - |
| - @Override |
| - public ServerResponse httpGET(String url, List<HeaderEntry> headers) |
| - { |
| - if (url.indexOf("/notification.json") < 0) |
| - return new ServerResponse(); |
| - |
| - ServerResponse response = new ServerResponse(); |
| - response.setStatus(ServerResponse.NsStatus.OK); |
| - response.setResponseStatus(200); |
| - response.setResponse(responseText); |
| - return response; |
| - } |
| - } |
| - |
| @Test |
| public void testNoNotifications() throws InterruptedException |
| { |
| assertNull(peekNotification("")); |
| } |
| @Test |
| public void testAddNotification() throws InterruptedException |
| @@ -147,17 +112,17 @@ |
| notification = peekNotification("http://www.com"); |
| assertNotNull(notification); |
| assertEquals(Notification.Type.INFORMATION, notification.getType()); |
| } |
| @Test |
| public void testMarkAsShown() throws InterruptedException |
| { |
| - addNotification("{ type: 'question' }"); |
| + addNotification("{ id: 'id', type: 'information' }"); |
| assertNotNull(peekNotification("")); |
| Notification notification = peekNotification(""); |
| assertNotNull(notification); |
| Thread.sleep(1000); |
| notification.markAsShown(); |