package com.etsy.android.perf; import android.app.Instrumentation; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.LargeTest; import com.etsy.android.BOEApplication; import com.etsy.android.test.rules.EtsyAccountRule; import com.etsy.android.test.rules.EtsyConfigRule; import com.etsy.android.test.EtsyFunctionalTestTimer; import org.junit.ClassRule; import org.junit.Test; import org.junit.Before; import org.junit.runner.RunWith; import static junit.framework.Assert.assertNotNull; /** * A test to measure the time it takes for the application to start up */ @RunWith(AndroidJUnit4.class) @LargeTest public class ApplicationLaunchTests { @ClassRule public static EtsyConfigRule mConfigRule = new EtsyConfigRule(); @ClassRule public static EtsyAccountRule mAccountRule = EtsyAccountRule.noAccount(); @Before public void setup() { } @Test public void testApplicationStartupTime_signedOut() throws IllegalAccessException, ClassNotFoundException, InstantiationException { EtsyFunctionalTestTimer appLaunchTimer = EtsyFunctionalTestTimer.time(PerfConstants.APP_LAUNCH_TIME); final BOEApplication application = (BOEApplication) Instrumentation.newApplication(BOEApplication.class, InstrumentationRegistry.getTargetContext()); assertNotNull(application); InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { application.onCreate(); } }); appLaunchTimer.stop(); } }