From 9ea846d4a9c0afb928acc3ef57e8477c301fa05a Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 25 Feb 2016 15:51:01 +0100 Subject: [PATCH] mobile/bind: make sure the Java SeqTest has a valid context On some Android devices (my HTC One S running Android 4.1.1), SeqTest failed the testAssets test because the LoadJNI hack to locate a valid context fails. Instead, make testAssets set up a valid context acquired from InstrumentTestCase. Change-Id: If6e11173dbacff45eb6cb0f409f56cbd88186e30 Reviewed-on: https://go-review.googlesource.com/19896 Reviewed-by: David Crawshaw --- bind/java/SeqTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bind/java/SeqTest.java b/bind/java/SeqTest.java index 381e6cb..3b047ee 100644 --- a/bind/java/SeqTest.java +++ b/bind/java/SeqTest.java @@ -4,7 +4,7 @@ package go; -import android.test.AndroidTestCase; +import android.test.InstrumentationTestCase; import android.test.MoreAsserts; import java.util.Arrays; @@ -12,7 +12,7 @@ import java.util.Random; import go.testpkg.Testpkg; -public class SeqTest extends AndroidTestCase { +public class SeqTest extends InstrumentationTestCase { public SeqTest() { } @@ -61,6 +61,8 @@ public class SeqTest extends AndroidTestCase { } public void testAssets() { + // Make sure that a valid context is set before reading assets + Seq.setContext(getInstrumentation().getContext()); String want = "Hello, Assets.\n"; String got = Testpkg.ReadAsset(); assertEquals("Asset read", want, got);