mirror of
https://github.com/netbirdio/gomobile-tvos-fork.git
synced 2026-05-22 18:43:29 -07:00
bind/java: custom int-keyed hashmap
This removes the last dependency on an Android class in the running gobind code. (Tests still need some work before they will run on the desktop.) Change-Id: I49bfb545d4587c6f430c0938fa1ca4d513b56d77 Reviewed-on: https://go-review.googlesource.com/17252 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
@@ -316,6 +316,42 @@ public class SeqTest extends AndroidTestCase {
|
||||
assertFalse("want obj to be kept live by Go", finalizedAnI);
|
||||
}
|
||||
|
||||
private int countI = 0;
|
||||
|
||||
private class CountI extends Testpkg.I.Stub {
|
||||
public void F() { countI++; }
|
||||
|
||||
public void E() throws Exception {}
|
||||
public Testpkg.I I() { return null; }
|
||||
public Testpkg.S S() { return null; }
|
||||
public String StoString(Testpkg.S s) { return ""; }
|
||||
public long V() { return 0; }
|
||||
public long VE() throws Exception { return 0; }
|
||||
public String String() { return ""; }
|
||||
}
|
||||
|
||||
public void testGoRefMapGrow() {
|
||||
CountI obj = new CountI();
|
||||
Testpkg.Keep(obj);
|
||||
|
||||
// Push active references beyond base map size.
|
||||
for (int i = 0; i < 24; i++) {
|
||||
CountI o = new CountI();
|
||||
Testpkg.CallF(o);
|
||||
if (i%3==0) {
|
||||
Testpkg.Keep(o);
|
||||
}
|
||||
}
|
||||
runGC();
|
||||
for (int i = 0; i < 128; i++) {
|
||||
Testpkg.CallF(new CountI());
|
||||
}
|
||||
|
||||
Testpkg.CallF(obj); // original object needs to work.
|
||||
|
||||
assertEquals(countI, 1+24+128);
|
||||
}
|
||||
|
||||
private void runGC() {
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
|
||||
Reference in New Issue
Block a user