Search in sources :

Example 56 with Application

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();
    }
}
Also used : ActivityLaunchMetrics(com.frogermcs.androiddevmetrics.internal.metrics.ActivityLaunchMetrics) Application(android.app.Application)

Example 57 with Application

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);
}
Also used : TinyCoach(com.codemonkeylabs.fpslibrary.ui.TinyCoach) Application(android.app.Application)

Example 58 with Application

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);
}
Also used : Activity(android.app.Activity) Application(android.app.Application) Test(org.junit.Test)

Example 59 with Application

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;
}
Also used : File(java.io.File) Application(android.app.Application)

Example 60 with Application

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);
}
Also used : Activity(android.app.Activity) Application(android.app.Application) Test(org.junit.Test)

Aggregations

Application (android.app.Application)123 Test (org.junit.Test)26 Context (android.content.Context)24 Activity (android.app.Activity)22 ApplicationInfo (android.content.pm.ApplicationInfo)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)11 File (java.io.File)10 MvpPresenter (com.hannesdorfmann.mosby3.mvp.MvpPresenter)8 Before (org.junit.Before)8 MvpView (com.hannesdorfmann.mosby3.mvp.MvpView)7 ShadowApplication (org.robolectric.shadows.ShadowApplication)7 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)6 PrintWriter (java.io.PrintWriter)6 Date (java.util.Date)6 PackageInfo (android.content.pm.PackageInfo)5 PackageManager (android.content.pm.PackageManager)5 RemoteException (android.os.RemoteException)5 AbsoluteSizeSpan (android.text.style.AbsoluteSizeSpan)5 BackgroundColorSpan (android.text.style.BackgroundColorSpan)5 CharacterStyle (android.text.style.CharacterStyle)5