Opened 3 years ago

Closed 14 months ago

#4231 closed defect (fixed)

Fix unstable FilterEngineTest.testSetRemoveFilterChangeCallback

Reported by: asmirnov Assignee: asmirnov
Priority: P3 Milestone:
Module: Libadblockplus-Android Keywords:
Cc: rjeschke, sergz Blocked By:
Blocking: Platform: Android
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

https://codereview.adblockplus.org/29347315/
https://codereview.adblockplus.org/29424615/

Description

The test should confirm we've unsubscribed callback from events and it stopped being invoked:

@Test
    public void testSetRemoveFilterChangeCallback() throws InterruptedException
    {
        MockFilterChangeCallback mockFilterChangeCallback = new MockFilterChangeCallback(0);

        filterEngine.setFilterChangeCallback(mockFilterChangeCallback);
        filterEngine.getFilter("foo").addToList();
        assertEquals(1, mockFilterChangeCallback.getTimesCalled());

        filterEngine.removeFilterChangeCallback();
        filterEngine.getFilter("foo").removeFromList();
        assertEquals(1, mockFilterChangeCallback.getTimesCalled());
    }

Test log:

07-07 04:12:52.572    3494-3494/? D/AndroidRuntime﹕ >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
07-07 04:12:52.572    3494-3494/? W/linker﹕ libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
07-07 04:12:52.582    3494-3494/? D/AndroidRuntime﹕ CheckJNI is ON
07-07 04:12:52.582    3494-3494/? D/dalvikvm﹕ Trying to load lib libjavacore.so 0x0
07-07 04:12:52.582    3494-3494/? D/dalvikvm﹕ Added shared lib libjavacore.so 0x0
07-07 04:12:52.582    3494-3494/? D/dalvikvm﹕ Trying to load lib libnativehelper.so 0x0
07-07 04:12:52.582    3494-3494/? D/dalvikvm﹕ Added shared lib libnativehelper.so 0x0
07-07 04:12:52.582    3494-3494/? D/dalvikvm﹕ No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
07-07 04:12:52.622    3494-3494/? D/dalvikvm﹕ Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
07-07 04:12:52.652    3494-3494/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
07-07 04:12:52.652    3494-3494/? E/android.os.Debug﹕ failed to load memtrack module: -2
07-07 04:12:52.682    3494-3494/? D/AndroidRuntime﹕ Calling main entry com.android.commands.am.Am
07-07 04:12:52.692    3504-3504/? D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
07-07 04:12:52.692    1275-1529/system_process I/ActivityManager﹕ Force stopping org.adblockplus.libadblockplus.tests appid=10052 user=0: start instr
07-07 04:12:52.722    1275-1529/system_process I/ActivityManager﹕ Start proc org.adblockplus.libadblockplus.tests for added application org.adblockplus.libadblockplus.tests: pid=3504 uid=10052 gids={50052, 3003}
07-07 04:12:52.752    3504-3504/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ GC_FOR_ALLOC freed 340K, 15% free 3281K/3828K, paused 3ms, total 3ms
07-07 04:12:52.762    3504-3504/org.adblockplus.libadblockplus.tests I/System.out﹕ EMMA: collecting runtime coverage data ...
07-07 04:12:52.762    3504-3517/org.adblockplus.libadblockplus.tests I/TestRunner﹕ started: testSetRemoveFilterChangeCallback(org.adblockplus.libadblockplus.tests.FilterEngineTest)
07-07 04:12:52.762    3504-3517/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ Trying to load lib /data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so 0xb0fcd650
07-07 04:12:52.772    3504-3517/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ Added shared lib /data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so 0xb0fcd650
07-07 04:12:52.772    3504-3517/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ Trying to load lib /data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so 0xb0fcd650
07-07 04:12:52.772    3504-3517/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ Shared lib '/data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so' already loaded in same CL 0xb0fcd650
07-07 04:12:52.772    3504-3517/org.adblockplus.libadblockplus.tests I/dalvikvm﹕ threadid=11: recursive native library load attempt (/data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so)
07-07 04:12:52.782    3504-3517/org.adblockplus.libadblockplus.tests D/test﹕ Generated fs path /data/data/org.adblockplus.libadblockplus.tests/cache/f8effa8b-a19c-4008-92e0-6355a8553e4c.fs
07-07 04:12:52.782    3504-3517/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ Trying to load lib /data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so 0xb0fcd650
07-07 04:12:52.782    3504-3517/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ Shared lib '/data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so' already loaded in same CL 0xb0fcd650
07-07 04:12:55.802    3504-3517/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ Trying to load lib /data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so 0xb0fcd650
07-07 04:12:55.802    3504-3517/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ Shared lib '/data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so' already loaded in same CL 0xb0fcd650
07-07 04:12:55.852    3504-3517/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ Trying to load lib /data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so 0xb0fcd650
07-07 04:12:55.852    3504-3517/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ Shared lib '/data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so' already loaded in same CL 0xb0fcd650
07-07 04:12:55.852    3504-3517/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ Trying to load lib /data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so 0xb0fcd650
07-07 04:12:55.852    3504-3517/org.adblockplus.libadblockplus.tests D/dalvikvm﹕ Shared lib '/data/app-lib/org.adblockplus.libadblockplus.tests-2/libadblockplus-jni.so' already loaded in same CL 0xb0fcd650
07-07 04:12:55.862    3504-3517/org.adblockplus.libadblockplus.tests D/callback﹕ filterChangeCallback for action=subscription.added, value=[Subscription]
    url=~user~992840
    defaults=blocking
07-07 04:12:55.862    3504-3525/org.adblockplus.libadblockplus.tests D/callback﹕ filterChangeCallback for action=subscription.downloading, value=[Subscription]
    url=https://easylist-downloads.adblockplus.org/easylist.txt
    title=EasyList
    homepage=https://easylist.adblockplus.org/
07-07 04:12:55.882    3504-3517/org.adblockplus.libadblockplus.tests W/FileSystemHelper﹕ Deleting file /data/data/org.adblockplus.libadblockplus.tests/cache/f8effa8b-a19c-4008-92e0-6355a8553e4c.fs/patterns.ini
07-07 04:12:55.882    3504-3517/org.adblockplus.libadblockplus.tests W/FileSystemHelper﹕ Deleting file /data/data/org.adblockplus.libadblockplus.tests/cache/f8effa8b-a19c-4008-92e0-6355a8553e4c.fs/patterns-backup1.ini
07-07 04:12:55.882    3504-3517/org.adblockplus.libadblockplus.tests W/FileSystemHelper﹕ Deleting directory /data/data/org.adblockplus.libadblockplus.tests/cache/f8effa8b-a19c-4008-92e0-6355a8553e4c.fs
07-07 04:12:55.882    3504-3517/org.adblockplus.libadblockplus.tests I/TestRunner﹕ failed: testSetRemoveFilterChangeCallback(org.adblockplus.libadblockplus.tests.FilterEngineTest)
07-07 04:12:55.882    3504-3517/org.adblockplus.libadblockplus.tests I/TestRunner﹕ ----- begin exception -----
07-07 04:12:55.882    3504-3517/org.adblockplus.libadblockplus.tests I/TestRunner﹕ junit.framework.AssertionFailedError: expected:<1> but was:<2>
            at junit.framework.Assert.fail(Assert.java:50)
            at junit.framework.Assert.failNotEquals(Assert.java:287)
            at junit.framework.Assert.assertEquals(Assert.java:67)
            at junit.framework.Assert.assertEquals(Assert.java:199)
            at junit.framework.Assert.assertEquals(Assert.java:205)
            at org.adblockplus.libadblockplus.tests.FilterEngineTest.testSetRemoveFilterChangeCallback(FilterEngineTest.java:333)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at junit.framework.TestCase.runTest(TestCase.java:168)
            at junit.framework.TestCase.runBare(TestCase.java:134)
            at junit.framework.TestResult$1.protect(TestResult.java:115)
            at junit.framework.TestResult.runProtected(TestResult.java:133)
            at junit.framework.TestResult.run(TestResult.java:118)
            at junit.framework.TestCase.run(TestCase.java:124)
            at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
            at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
            at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
            at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
07-07 04:12:55.882    3504-3517/org.adblockplus.libadblockplus.tests I/TestRunner﹕ ----- end exception -----
07-07 04:12:55.882    3504-3517/org.adblockplus.libadblockplus.tests I/TestRunner﹕ finished: testSetRemoveFilterChangeCallback(org.adblockplus.libadblockplus.tests.FilterEngineTest)
07-07 04:12:55.902    3504-3539/org.adblockplus.libadblockplus.tests D/callback﹕ filterChangeCallback for action=save, value=undefined
07-07 04:12:55.902    3494-3494/? D/AndroidRuntime﹕ Shutting down VM
07-07 04:12:55.902    3494-3500/? D/jdwp﹕ Got wake-up signal, bailing out of select
07-07 04:12:55.902    3494-3500/? D/dalvikvm﹕ Debugger has detached; object registry had 1 entries
07-07 04:12:56.112    1275-1286/system_process I/ActivityManager﹕ Force stopping org.adblockplus.libadblockplus.tests appid=10052 user=0: finished inst
07-07 04:12:56.112    1275-1286/system_process I/ActivityManager﹕ Killing 3504:org.adblockplus.libadblockplus.tests/u0a52 (adj 0): stop org.adblockplus.libadblockplus.tests
07-07 04:13:05.032    1275-1290/system_process D/dalvikvm﹕ GC_FOR_ALLOC freed 825K, 49% free 6199K/12104K, paused 10ms, total 11ms
07-07 04:15:01.004    1275-1345/system_process D/ConnectivityService﹕ Sampling interval elapsed, updating statistics ..
07-07 04:15:01.004    1275-1345/system_process D/ConnectivityService﹕ Done.
07-07 04:15:01.004    1275-1345/system_process D/ConnectivityService﹕ Setting timer for 720seconds

However we're getting another events (except subscription) and we should take it into account (modify test most likely)even though sometimes the test succeeds. Similar c++ test: https://hg.adblockplus.org/libadblockplus/file/tip/test/FilterEngine.cpp#l439

Change History (4)

comment:1 Changed 3 years ago by asmirnov

  • Owner set to asmirnov

comment:2 Changed 3 years ago by asmirnov

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:3 Changed 3 years ago by asmirnov

  • Review URL(s) modified (diff)

comment:4 Changed 14 months ago by asmirnov

  • Resolution set to fixed
  • Status changed from reviewing to closed
Note: See TracTickets for help on using tickets.