public void __constructor__(Context baseContext, int themesres) { super.__constructor__(baseContext); } }
/** * Implements Android's {@code PackageManager}. * * @return a {@code RobolectricPackageManager} */ @Implementation public PackageManager getPackageManager() { return realContextWrapper == getApplicationContext() ? packageManager : getApplicationContext().getPackageManager(); }
@Implementation public AssetManager getAssets() { return getResources().getAssets(); }
/** * Return (without consuming) the next {@code Intent} on the started services stack. * * @return the next started {@code Intent} for a service */ public Intent peekNextStartedService() { return getShadowApplication().peekNextStartedService(); }
@SuppressWarnings("rawtypes") private Drawable getInnerRClassDrawable( int drawableResourceId, String suffix, Class returnClass ) { ShadowContextWrapper shadowApp = Robolectric.shadowOf( Robolectric.application ); Class rClass = shadowApp.getResourceLoader().getLocalRClass(); // Check to make sure there is actually an R Class, if not // return just a BitmapDrawable if ( rClass == null ) { return null; } // Load the Inner Class for interrogation Class animClass = null; try { animClass = Class.forName( rClass.getCanonicalName() + suffix ); } catch ( ClassNotFoundException e ) { return null; } // Try to find the passed in resource ID try { for ( Field field : animClass.getDeclaredFields() ) { if ( field.getInt( animClass ) == drawableResourceId ) { return ( Drawable ) returnClass.newInstance(); } } } catch ( Exception e ) { } return null; }
@Override public boolean matchesSafely(Context actualContext) { if (expectedIntent == null) { message = "null intent (did you mean to expect null?)"; return false; } String expected = expectedIntent.toString(); message = "to start " + expected + ", but "; Intent actualStartedIntent = shadowOf((ContextWrapper) actualContext).getNextStartedActivity(); if (actualStartedIntent == null) { message += "didn't start anything"; return false; } ShadowIntent shadowIntent = shadowOf(actualStartedIntent); boolean intentsMatch = shadowOf(expectedIntent).realIntentEquals(shadowIntent); if (!intentsMatch) { message += "started " + actualStartedIntent; } return intentsMatch; }
message = "to start " + expected + ", but "; Intent actualStartedIntent = shadowOf((ContextWrapper) actualContext).getNextStartedService();
/** * Non-Android accessor that delegates to the application to consume and return the next {@code Intent} on the * started services stack. * * @return the next started {@code Intent} for a service */ public Intent getNextStartedService() { return getShadowApplication().getNextStartedService(); }
@Implementation public String getPackageName() { return realContextWrapper == getApplicationContext() ? packageName : getApplicationContext().getPackageName(); }
/** * Non-Android accessor that delegates to the application to consume and return the next {@code Intent} on the * started activities stack. * * @return the next started {@code Intent} for an activity */ public Intent getNextStartedActivity() { return getShadowApplication().getNextStartedActivity(); }
@Implementation public Resources.Theme getTheme() { return getResources().newTheme(); }
@Implementation public Object getSystemService(String name) { return getApplicationContext().getSystemService(name); }
/** * Non-Android accessor that delegates to the application to return (without consuming) the next {@code Intent} on * the started activities stack. * * @return the next started {@code Intent} for an activity */ public Intent peekNextStartedActivity() { return getShadowApplication().peekNextStartedActivity(); }
@Implementation public void sendBroadcast(Intent intent) { getApplicationContext().sendBroadcast(intent); }
/** * Non-Android accessor that delegates to the application to return the next {@code Intent} to stop * a service (irrespective of if the service was running) * * @return {@code Intent} for the next service requested to be stopped */ public Intent getNextStoppedService() { return getShadowApplication().getNextStoppedService(); }
@Implementation public ComponentName startService(Intent service) { return getApplicationContext().startService(service); }
/** * Non-android accessor that delefates to the application to clear the stack of started * service intents. */ public void clearStartedServices() { getShadowApplication().clearStartedServices(); }
@Implementation public void unregisterReceiver(BroadcastReceiver broadcastReceiver) { getApplicationContext().unregisterReceiver(broadcastReceiver); }
@Implementation public Looper getMainLooper() { return getShadowApplication().getMainLooper(); }
@Implementation public Resources getResources() { return getApplicationContext().getResources(); }