Created
July 29, 2011 09:04
-
-
Save turugina/1113481 to your computer and use it in GitHub Desktop.
Get asset on test package with ServiceTestCase. (Android)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.content.res.AssetManager; | |
import android.test.ServiceTestCase; | |
import com.example.android.HogeService; | |
public class HogeTest extends ServiceTestCase<HogeService> | |
{ | |
private Context getTestContext() throws Exception | |
{ | |
return (Context)getClass().getMethod("getTestContext").invoke(this); | |
} | |
public void testHoge() throws Exception | |
{ | |
AssetManager am = getTestContext().getResources().getAssets(); | |
java.io.InputStream is = am.open("hoge.txt"); | |
try { | |
// hogehoge | |
} | |
finally { | |
is.close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment