Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 assertEquals(Filter.Type.ELEMHIDE, filter3.getType()); | 44 assertEquals(Filter.Type.ELEMHIDE, filter3.getType()); |
45 Filter filter4 = filterEngine.getFilter("example.com#@#foo"); | 45 Filter filter4 = filterEngine.getFilter("example.com#@#foo"); |
46 assertEquals(Filter.Type.ELEMHIDE_EXCEPTION, filter4.getType()); | 46 assertEquals(Filter.Type.ELEMHIDE_EXCEPTION, filter4.getType()); |
47 Filter filter5 = filterEngine.getFilter(" foo "); | 47 Filter filter5 = filterEngine.getFilter(" foo "); |
48 assertEquals(filter1, filter5); | 48 assertEquals(filter1, filter5); |
49 } | 49 } |
50 | 50 |
51 @Test | 51 @Test |
52 public void testAddRemoveFilters() | 52 public void testAddRemoveFilters() |
53 { | 53 { |
54 while (filterEngine.getListedFilters().size() > 0) | 54 this.removeListedSubscriptions(); |
55 { | |
56 int prev = filterEngine.getListedFilters().size(); | |
anton
2018/08/24 12:25:04
Can you please explain what's happening here?
Is i
René Jeschke
2018/08/27 20:02:15
There was a change in the way subscriptions work i
| |
57 filterEngine.getListedFilters().get(0).removeFromList(); | |
58 if (prev == filterEngine.getListedFilters().size()) | |
59 { | |
60 Log.e(TAG, "Failed to clear listed filters."); | |
61 } | |
62 } | |
63 | 55 |
64 assertEquals(0, filterEngine.getListedFilters().size()); | 56 assertEquals(0, filterEngine.getListedFilters().size()); |
65 Filter filter = filterEngine.getFilter("foo"); | 57 Filter filter = filterEngine.getFilter("foo"); |
66 assertEquals(0, filterEngine.getListedFilters().size()); | 58 assertEquals(0, filterEngine.getListedFilters().size()); |
67 assertFalse(filter.isListed()); | 59 assertFalse(filter.isListed()); |
68 | 60 |
69 filter.addToList(); | 61 filter.addToList(); |
70 assertEquals(1, filterEngine.getListedFilters().size()); | 62 assertEquals(1, filterEngine.getListedFilters().size()); |
71 assertEquals(filter, filterEngine.getListedFilters().get(0)); | 63 assertEquals(filter, filterEngine.getListedFilters().get(0)); |
72 assertTrue(filter.isListed()); | 64 assertTrue(filter.isListed()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 filterEngine.setFilterChangeCallback(callback); | 109 filterEngine.setFilterChangeCallback(callback); |
118 subscription.setDisabled(false); | 110 subscription.setDisabled(false); |
119 assertEquals(1, callback.getTimesCalled()); | 111 assertEquals(1, callback.getTimesCalled()); |
120 assertFalse(subscription.isDisabled()); | 112 assertFalse(subscription.isDisabled()); |
121 filterEngine.removeFilterChangeCallback(); | 113 filterEngine.removeFilterChangeCallback(); |
122 } | 114 } |
123 | 115 |
124 @Test | 116 @Test |
125 public void testAddRemoveSubscriptions() | 117 public void testAddRemoveSubscriptions() |
126 { | 118 { |
127 while (filterEngine.getListedSubscriptions().size() > 0) | 119 this.removeListedSubscriptions(); |
anton
2018/08/24 12:25:04
copy-paste from above. Can you create separate fun
René Jeschke
2018/08/27 20:02:15
Done.
| |
128 { | |
129 int prev = filterEngine.getListedSubscriptions().size(); | |
130 filterEngine.getListedSubscriptions().get(0).removeFromList(); | |
131 if (prev == filterEngine.getListedSubscriptions().size()) | |
132 { | |
133 Log.e(TAG, "Failed to clear listed subscriptions."); | |
134 break; | |
135 } | |
136 } | |
137 | 120 |
138 assertEquals(0, filterEngine.getListedSubscriptions().size()); | 121 assertEquals(0, filterEngine.getListedSubscriptions().size()); |
139 Subscription subscription = filterEngine.getSubscription("foo"); | 122 Subscription subscription = filterEngine.getSubscription("foo"); |
140 assertEquals(0, filterEngine.getListedSubscriptions().size()); | 123 assertEquals(0, filterEngine.getListedSubscriptions().size()); |
141 assertFalse(subscription.isListed()); | 124 assertFalse(subscription.isListed()); |
142 subscription.addToList(); | 125 subscription.addToList(); |
143 assertEquals(1, filterEngine.getListedSubscriptions().size()); | 126 assertEquals(1, filterEngine.getListedSubscriptions().size()); |
144 assertEquals(subscription, filterEngine.getListedSubscriptions().get(0)); | 127 assertEquals(subscription, filterEngine.getListedSubscriptions().get(0)); |
145 assertTrue(subscription.isListed()); | 128 assertTrue(subscription.isListed()); |
146 subscription.addToList(); | 129 subscription.addToList(); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
528 listedSubscriptions = filterEngine.getListedSubscriptions(); | 511 listedSubscriptions = filterEngine.getListedSubscriptions(); |
529 for (Subscription eachSubscription : listedSubscriptions) | 512 for (Subscription eachSubscription : listedSubscriptions) |
530 { | 513 { |
531 if (eachSubscription.isAcceptableAds()) | 514 if (eachSubscription.isAcceptableAds()) |
532 { | 515 { |
533 assertFalse(eachSubscription.isDisabled()); | 516 assertFalse(eachSubscription.isDisabled()); |
534 } | 517 } |
535 } | 518 } |
536 } | 519 } |
537 } | 520 } |
LEFT | RIGHT |