Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: adblock-android-tests/src/org/adblockplus/libadblockplus/BaseFilterEngineTest.java

Issue 29819555: Fix libadblockplus-android tests
Patch Set: Added missing files, removed a whitespace Created Aug. 16, 2018, 12:27 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 package org.adblockplus.libadblockplus;
anton 2018/08/24 12:25:03 Why is it moved from `tests` package? Same about a
René Jeschke 2018/08/27 20:02:14 Yes, it was intentionally. Those four classes don'
19
20 import android.os.SystemClock;
21
22 import java.util.List;
23
24 public abstract class BaseFilterEngineTest extends BaseJsEngineTest
25 {
26 protected final static int UPDATE_SUBSCRIPTIONS_WAIT_DELAY_MS = 5 * 1000;
27 protected final static int UPDATE_SUBSCRIPTIONS_WAIT_CHUNKS = 50;
28
29 @Override
30 protected void setUp() throws Exception
31 {
32 super.setUp();
33 this.setupFilterEngine();
34 }
35
36 protected int getUpdateRequestCount()
37 {
38 return 0;
39 }
40
41 protected int updateSubscriptions()
42 {
43 return updateSubscriptions(false);
44 }
45
46 protected int updateSubscriptions(boolean noWait)
47 {
48 final int init = getUpdateRequestCount();
49
50 List<Subscription> subscriptions = filterEngine.getListedSubscriptions();
51 final int num = subscriptions.size();
52 for (final Subscription s : subscriptions)
53 {
54 try
55 {
56 s.updateFilters();
57 }
58 finally
59 {
60 s.dispose();
61 }
62 }
63
64 if (!noWait)
65 {
66 for (int i = 0; i < UPDATE_SUBSCRIPTIONS_WAIT_CHUNKS; i++)
67 {
68 if (getUpdateRequestCount() - init >= num)
69 {
70 break;
71 }
72 SystemClock.sleep(UPDATE_SUBSCRIPTIONS_WAIT_DELAY_MS / UPDATE_SUBSCRIPTI ONS_WAIT_CHUNKS);
73 }
74 }
75
76 return num;
77 }
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld