use of android.app.Application in project AndroidDevMetrics by frogermcs.
the class AndroidDevMetrics method setupMetrics.
private void setupMetrics() {
Dagger2GraphAnalyzer.setEnabled(enableDagger2Metrics);
InitManager.getInstance().initializedMetrics.clear();
ActivityLifecycleAnalyzer.setEnabled(true);
if (enableAcitivtyMetrics) {
MethodsTracingManager.getInstance().init(context);
ActivityLaunchMetrics activityLaunchMetrics = ActivityLaunchMetrics.getInstance();
((Application) context.getApplicationContext()).registerActivityLifecycleCallbacks(activityLaunchMetrics);
ChoreographerMetrics.getInstance().setMaxFpsForFrameDrop(maxFpsForFrameDrop);
ChoreographerMetrics.getInstance().setIntervalMillis(intervalMillis);
ChoreographerMetrics.getInstance().start();
}
if (showNotification) {
showNotification();
}
}
use of android.app.Application in project TinyDancer by friendlyrobotnyc.
the class TinyDancerBuilder method show.
// PUBLIC BUILDER METHODS
/**
* show fps meter, this regisers the frame callback that
* collects the fps info and pushes it to the ui
* @param context
*/
public void show(Context context) {
if (overlayPermRequest(context)) {
//once permission is granted then you must call show() again
return;
}
//are we running? if so, call tinyCoach.show() and return
if (tinyCoach != null) {
tinyCoach.show();
return;
}
// set device's frame rate info into the config
setFrameRate(context);
// create the presenter that updates the view
tinyCoach = new TinyCoach((Application) context.getApplicationContext(), fpsConfig);
// create our choreographer callback and register it
fpsFrameCallback = new FPSFrameCallback(fpsConfig, tinyCoach);
Choreographer.getInstance().postFrameCallback(fpsFrameCallback);
//set activity background/foreground listener
Foreground.init((Application) context.getApplicationContext()).addListener(foregroundListener);
}
use of android.app.Application in project iosched by google.
the class AndroidUnitTest method dummyUnitTestWithMockito.
@Test
public void dummyUnitTestWithMockito() {
Activity activity = mock(Activity.class);
assertThat(activity, notNullValue());
Application app = mock(Application.class);
when(activity.getApplication()).thenReturn(app);
assertThat(app, is(equalTo(activity.getApplication())));
verify(activity).getApplication();
verifyNoMoreInteractions(activity);
}
use of android.app.Application in project greenDAO by greenrobot.
the class PerformanceTest method getBenchFile.
private File getBenchFile(String name) {
File dir = Environment.getExternalStorageDirectory();
File file = new File(dir, name);
if (dir == null || !dir.canWrite()) {
Application app = createApplication(Application.class);
File appFile = new File(app.getFilesDir(), name);
DaoLog.d("Using file " + appFile.getAbsolutePath() + ", (cannot write to " + file.getAbsolutePath() + ")");
file = appFile;
}
return file;
}
use of android.app.Application in project android-testing-templates by googlesamples.
the class LocalUnitTest method mockFinalMethod.
@Test
public void mockFinalMethod() {
Activity activity = mock(Activity.class);
Application app = mock(Application.class);
when(activity.getApplication()).thenReturn(app);
assertThat(app, is(equalTo(activity.getApplication())));
verify(activity).getApplication();
verifyNoMoreInteractions(activity);
}
Aggregations