@Override public Context getContext() { return base.getContext(); }
/** Can be overridden to customize the failure string message. */ protected @NonNull String buildLeakDetectedMessage( @NonNull List<InstrumentationLeakResults.Result> detectedLeaks) { StringBuilder failureMessage = new StringBuilder(); failureMessage.append( "Test failed because memory leaks were detected, see leak traces below.\n"); failureMessage.append(SEPARATOR); Context context = getInstrumentation().getContext(); for (InstrumentationLeakResults.Result detectedLeak : detectedLeaks) { failureMessage.append( LeakCanary.leakInfo(context, detectedLeak.heapDump, detectedLeak.analysisResult, true)); failureMessage.append(SEPARATOR); } return failureMessage.toString(); } }
@Before public void setUp() { final Context context = InstrumentationRegistry.getInstrumentation().getContext(); rootView = LayoutInflater.from(context).inflate(R.layout.attrributes, null, false); }
public CardScannerTester(CardIOActivity scanActivity, int currentFrameOrientation) { super(scanActivity, currentFrameOrientation); useCamera = false; mScanAllowed = false; mHandler = new Handler(); try { Bitmap bitmap = BitmapFactory.decodeStream(getInstrumentation().getContext().getAssets() .open("test_card_images/" + sCardAssetName)); mFrame = getNV21FormattedImage(bitmap.getWidth(), bitmap.getHeight(), bitmap); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Creates and returns TextView objects based on WebElements * * @return an ArrayList with TextViews */ private ArrayList <TextView> createAndReturnTextViewsFromWebElements(boolean javaScriptWasExecuted){ ArrayList<TextView> webElementsAsTextViews = new ArrayList<TextView>(); if(javaScriptWasExecuted){ for(WebElement webElement : webElementCreator.getWebElementsFromWebViews()){ if(isWebElementSufficientlyShown(webElement)){ RobotiumTextView textView = new RobotiumTextView(inst.getContext(), webElement.getText(), webElement.getLocationX(), webElement.getLocationY()); webElementsAsTextViews.add(textView); } } } return webElementsAsTextViews; }
public XmlPullParser createParser(int res) throws Exception { InputStream stream = getInstrumentation().getContext().getResources().openRawResource(res); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser parser = factory.newPullParser(); parser.setInput(stream, null); parser.next(); return parser; }
public XmlPullParser createParser(int res) throws Exception { InputStream stream = getInstrumentation().getContext().getResources().openRawResource(res); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser parser = factory.newPullParser(); parser.setInput(stream, null); parser.next(); return parser; }
public XmlPullParser createParser(int res) throws Exception { InputStream stream = getInstrumentation().getContext().getResources().openRawResource(res); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser parser = factory.newPullParser(); parser.setInput(stream, null); parser.next(); return parser; }
@Test public void gifDrawableCreatedFromInputStream() throws Exception { final AssetFileDescriptor assetFileDescriptor = InstrumentationRegistry.getInstrumentation() .getContext().getResources().openRawResourceFd(R.raw.test); final byte[] buffer = new byte[(int) assetFileDescriptor.getDeclaredLength()]; final FileInputStream inputStream = assetFileDescriptor.createInputStream(); final int bufferedByteCount = inputStream.read(buffer); inputStream.close(); assetFileDescriptor.close(); assertThat(bufferedByteCount).isEqualTo(buffer.length); final InputStream responseStream = new ByteArrayInputStream(buffer); final GifDrawable gifDrawable = new GifDrawable(responseStream); assertThat(gifDrawable.getError()).isEqualTo(GifError.NO_ERROR); assertThat(gifDrawable.getIntrinsicWidth()).isEqualTo(278); assertThat(gifDrawable.getIntrinsicHeight()).isEqualTo(183); } }
@Test public void allocationByteCountIsConsistent() throws Exception { final Resources resources = InstrumentationRegistry.getInstrumentation().getContext().getResources(); final GifDrawable drawable = new GifDrawable(resources, R.raw.test); final GifAnimationMetaData metaData = new GifAnimationMetaData(resources, R.raw.test); assertThat(drawable.getFrameByteCount() + metaData.getAllocationByteCount()).isEqualTo(drawable.getAllocationByteCount()); assertThat(metaData.getDrawableAllocationByteCount(null, 1)).isEqualTo(drawable.getAllocationByteCount()); assertThat(metaData.getDrawableAllocationByteCount(drawable, 1)).isEqualTo(drawable.getAllocationByteCount()); } }
@Test public void useAppContext() { // Context of the app under test. Context appContext = InstrumentationRegistry.getInstrumentation().getContext(); assertEquals("com.folioreader.android.sample", appContext.getPackageName()); } }
@Before public void setUpList() { list = new ArrayList<>(); list.addAll(Arrays.asList(one, two, three, four, five)); questTypeOrderList = new QuestTypeOrderList( getInstrumentation().getContext().getSharedPreferences("Test", Context.MODE_PRIVATE), new QuestTypeRegistry(list)); questTypeOrderList.clear(); }
@Before public void setUp() throws Exception { testContext = InstrumentationRegistry.getInstrumentation().getContext(); PDFBoxResourceLoader.init(testContext); TARGETTESTDIR = android.os.Environment.getExternalStorageDirectory() + "/Download/pdfbox-test-output/merge/"; new File(TARGETTESTDIR).mkdirs(); if (!new File(TARGETTESTDIR).exists()) { throw new IOException("could not create output directory"); } }
@Before public void setUp() { testContext = InstrumentationRegistry.getInstrumentation().getContext(); PDFBoxResourceLoader.init(testContext); testResultsDir = new File(android.os.Environment.getExternalStorageDirectory() + "/Download/pdfbox-test-output/graphics/"); testResultsDir.mkdirs(); }
@Before public void setUp() { testContext = InstrumentationRegistry.getInstrumentation().getContext(); PDFBoxResourceLoader.init(testContext); testResultsDir = new File(android.os.Environment.getExternalStorageDirectory() + "/Download/pdfbox-test-output/graphics/"); testResultsDir.mkdirs(); }
public void testCheckForUpdate() throws Exception { KodiUpdater mKodiUpdater = new KodiUpdater(this.getInstrumentation().getContext()); mKodiUpdater.checkForUpdate(true); assertNotNull("Latest version should not be null", mKodiUpdater.getLatestVersion()); } }
@Override protected void setUp() throws Exception { trackId = MockData.mockTrack(getInstrumentation().getContext()); Intent i = new Intent(); i.putExtra(Schema.COL_TRACK_ID, trackId); setActivityIntent(i); }
@Before public void setUp() throws IOException { testContext = InstrumentationRegistry.getInstrumentation().getContext(); PDFBoxResourceLoader.init(testContext); }
@Test(expected=NameNotFoundException.class) public void testNameNotFoundException () throws Exception { ManifestMetadata metadata = ManifestMetadata.get (InstrumentationRegistry.getInstrumentation ().getContext ()); metadata.getValue ("foo", String.class); }
public void testJsonToAndFrom() throws IOException, JSONException { CalendarQueryResultsStorage inputs1 = provider.loadResults(getInstrumentation().getContext(), org.andstatus.todoagenda.tests.R.raw.birthday); JSONObject jsonOutput = inputs1.toJson(provider.getContext(), provider.getWidgetId()); CalendarQueryResultsStorage inputs2 = CalendarQueryResultsStorage.fromJson(provider.getContext(), jsonOutput); assertEquals(inputs1, inputs2); } }