本文整理了Java中android.app.Application.<init>()
方法的一些代码示例,展示了Application.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.<init>()
方法的具体详情如下:
包路径:android.app.Application
类名称:Application
方法名:<init>
暂无
代码示例来源:origin: ACRA/acra
@Test
public void getAttachments() throws Exception {
Uri uri = Uri.parse("content://not-a-valid-content-uri");
List<Uri> result = new DefaultAttachmentProvider().getAttachments(RuntimeEnvironment.application, new CoreConfigurationBuilder(new Application()).setAttachmentUris(uri.toString()).build());
assertThat(result, hasSize(1));
assertEquals(uri, result.get(0));
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(manifest = NONE)
public void getProvider_shouldNotReturnAnyProviderWhenManifestIsNull() {
Application application = new Application();
shadowOf(application).callAttach(RuntimeEnvironment.systemContext);
assertThat(ShadowContentResolver.getProvider(Uri.parse("content://"))).isNull();
}
代码示例来源:origin: robolectric/robolectric
application = new Application();
代码示例来源:origin: robolectric/robolectric
@Test
public void soStaticRefsToLoopersInAppWorksAcrossTests_shouldRetainSameLooperForMainThreadBetweenResetsButGiveItAFreshScheduler() throws Exception {
Looper mainLooper = Looper.getMainLooper();
Scheduler scheduler = shadowOf(mainLooper).getScheduler();
shadowOf(mainLooper).quit = true;
assertThat(ApplicationProvider.getApplicationContext().getMainLooper()).isSameAs(mainLooper);
Scheduler s = new Scheduler();
RuntimeEnvironment.setMasterScheduler(s);
ShadowLooper.resetThreadLoopers();
Application application = new Application();
ReflectionHelpers.callInstanceMethod(
application,
"attach",
ReflectionHelpers.ClassParameter.from(
Context.class,
((Application) ApplicationProvider.getApplicationContext()).getBaseContext()));
assertThat(Looper.getMainLooper()).named("Looper.getMainLooper()").isSameAs(mainLooper);
assertThat(application.getMainLooper()).named("app.getMainLooper()").isSameAs(mainLooper);
assertThat(shadowOf(mainLooper).getScheduler()).named("scheduler").isNotSameAs(scheduler);
assertThat(shadowOf(mainLooper).getScheduler()).named("scheduler").isSameAs(s);
assertThat(shadowOf(mainLooper).hasQuit()).named("quit").isFalse();
}
代码示例来源:origin: typ0520/fastdex
private void createRealApplication(Context context) {
String applicationClass = getOriginApplicationName(context);
if (applicationClass != null) {
Log.d(LOG_TAG, new StringBuilder().append("About to create real application of class name = ").append(applicationClass).toString());
try {
Class realClass = Class.forName(applicationClass);
Constructor constructor = realClass.getConstructor(new Class[0]);
this.realApplication = ((Application) constructor.newInstance(new Object[0]));
Log.v(LOG_TAG, new StringBuilder().append("Created real app instance successfully :").append(this.realApplication).toString());
} catch (Exception e) {
throw new IllegalStateException(e);
}
} else {
this.realApplication = new Application();
}
}
代码示例来源:origin: org.robolectric/robolectric
application = new Application();
代码示例来源:origin: florent37/AndroidUnitTest
@Test
public void testExecute() throws Exception {
// Given
TestObject testObject = new TestObject();
Context context = new Application();
manager.fragmentFields.add(testObject.getClass().getDeclaredField("fragment1"));
manager.fragmentFields.add(testObject.getClass().getDeclaredField("fragment2"));
// When
manager.execute(testObject, context);
//Then
assertThat(testObject.fragment1).isNotNull();
assertThat(testObject.fragment2).isNotNull();
}
代码示例来源:origin: florent37/AndroidUnitTest
@Test
public void testExecute() throws Exception {
// Given
TestObject testObject = new TestObject();
Context context = new Application();
manager.fields.add(testObject.getClass().getDeclaredField("view1"));
manager.fields.add(testObject.getClass().getDeclaredField("view2"));
// When
manager.execute(testObject, context);
//Then
assertThat(testObject.view1).isNotNull();
assertThat(testObject.view2).isNotNull();
}
代码示例来源:origin: uPhyca/GAlette
@Test
public void weaveNestedClass() throws Exception {
// Process classes.
processClass("com.uphyca.galette.GAletteInstrumentationTest$NestedTestClass$InnerClass");
// Load instrumented classes.
NestedTestClass instrumentedObject = new NestedTestClass();
Application app = new Application();
instrumentedObject.attach(app);
// Invoke method.
instrumentedObject.click();
// Verify interactions.
Method method = instrumentedObject.getClass().getDeclaredClasses()[0].getDeclaredMethod("click", new Class[]{});
verify(galette).sendEvent(eq(instrumentedObject.mInner), eq(app), eq(method), eq(new Object[]{}));
}
代码示例来源:origin: florent37/AndroidUnitTest
@Test
public void testExecute() throws Exception {
// Given
TestObject testObject = new TestObject();
Context context = new Application();
manager.contextField = testObject.getClass().getDeclaredField("context");
// When
manager.execute(testObject, context);
//Then
assertThat(testObject.context).isNotNull();
}
代码示例来源:origin: uPhyca/GAlette
@Test
public void weaveSendEvent() throws Exception {
// Process classes.
processClass("com.uphyca.galette.GAletteInstrumentationTest$TestClassForSendEvent");
// Load instrumented classes.
TestClassForSendEvent instrumentedObject = new TestClassForSendEvent();
Application app = new Application();
instrumentedObject.attach(app);
// Invoke method.
instrumentedObject.click();
// Verify interactions.
Method method = instrumentedObject.getClass().getDeclaredMethod("click", new Class[]{});
verify(galette).sendEvent(eq(instrumentedObject), eq(app), eq(method), eq(new Object[]{}));
}
代码示例来源:origin: uPhyca/GAlette
@Test
public void weaveSendScreenView() throws Exception {
// Process classes.
processClass("com.uphyca.galette.GAletteInstrumentationTest$TestClassForSendScreenView");
// Load instrumented classes.
TestClassForSendScreenView instrumentedObject = new TestClassForSendScreenView();
Application app = new Application();
instrumentedObject.attach(app);
// Invoke method.
instrumentedObject.show();
// Verify interactions.
Method method = instrumentedObject.getClass().getDeclaredMethod("show", new Class[]{});
verify(galette).sendScreenView(eq(instrumentedObject), eq(app), eq(method), eq(new Object[]{}));
}
代码示例来源:origin: uPhyca/GAlette
@Test
public void weaveService() throws Exception {
// Process classes.
processClass("com.uphyca.galette.GAletteInstrumentationTest$TestServiceClass");
// Load instrumented classes.
TestServiceClass instrumentedObject = new TestServiceClass();
Application app = new Application();
instrumentedObject.setApplication(app);
// Invoke method.
instrumentedObject.click();
// Verify interactions.
Method method = instrumentedObject.getClass().getDeclaredMethod("click", new Class[]{});
verify(galette).sendEvent(eq(instrumentedObject), eq(app), eq(method), eq(new Object[]{}));
}
代码示例来源:origin: uPhyca/GAlette
@Test
public void weaveSendAppView() throws Exception {
// Process classes.
processClass("com.uphyca.galette.GAletteInstrumentationTest$TestClassForSendAppView");
// Load instrumented classes.
TestClassForSendAppView instrumentedObject = new TestClassForSendAppView();
Application app = new Application();
instrumentedObject.attach(app);
// Invoke method.
instrumentedObject.show();
// Verify interactions.
Method method = instrumentedObject.getClass().getDeclaredMethod("show", new Class[]{});
verify(galette).sendAppView(eq(instrumentedObject), eq(app), eq(method), eq(new Object[]{}));
}
代码示例来源:origin: florent37/AndroidUnitTest
@Test
public void testExecute() throws Exception {
// Given
TestObject testObject = new TestObject();
Context context = new Application();
manager.activityField = testObject.getClass().getDeclaredField("activity");
// When
manager.execute(testObject, context);
//Then
assertThat(testObject.activity).isNotNull();
assertThat(testObject.activity.created).isTrue();
verify(androidUnitTest).setActivityController(any(ActivityController.class));
}
代码示例来源:origin: florent37/AndroidUnitTest
@Test
public void testExecuteState() throws Exception {
// Given
TestObjectState testObject = new TestObjectState();
Context context = new Application();
manager.activityField = testObject.getClass().getDeclaredField("activity");
// When
manager.execute(testObject, context);
//Then
assertThat(testObject.activity).isNotNull();
assertThat(testObject.activity.created).isTrue();
assertThat(testObject.activity.started).isTrue();
assertThat(testObject.activity.resumed).isTrue();
verify(androidUnitTest).setActivityController(any(ActivityController.class));
}
代码示例来源:origin: uPhyca/GAlette
@Test
public void weaveSupportFragment() throws Exception {
// Process classes.
processClass("com.uphyca.galette.GAletteInstrumentationTest$TestSupportFragmentClass");
// Load instrumented classes.
TestSupportFragmentClass instrumentedObject = new TestSupportFragmentClass();
Application app = new Application();
FragmentActivity activity = new FragmentActivity();
activity.attach(app);
instrumentedObject.setActivity(activity);
// Invoke method.
instrumentedObject.click();
// Verify interactions.
Method method = instrumentedObject.getClass().getDeclaredMethod("click", new Class[]{});
verify(galette).sendEvent(eq(instrumentedObject), eq(app), eq(method), eq(new Object[]{}));
}
代码示例来源:origin: uPhyca/GAlette
@Test
public void weaveFragment() throws Exception {
// Process classes.
processClass("com.uphyca.galette.GAletteInstrumentationTest$TestFragmentClass");
// Load instrumented classes.
TestFragmentClass instrumentedObject = new TestFragmentClass();
Application app = new Application();
Activity activity = new Activity();
activity.attach(app);
instrumentedObject.setActivity(activity);
// Invoke method.
instrumentedObject.click();
// Verify interactions.
Method method = instrumentedObject.getClass().getDeclaredMethod("click", new Class[]{});
verify(galette).sendEvent(eq(instrumentedObject), eq(app), eq(method), eq(new Object[]{}));
}
代码示例来源:origin: tmurakami/dexopener
@Test(expected = IllegalStateException.class)
public void should_throw_IllegalStateException_if_the_Application_has_been_created() {
given(instrumentation.getTargetContext()).willReturn(context);
given(context.getApplicationContext()).willReturn(new Application());
DexOpener.install(instrumentation);
}
代码示例来源:origin: com.github.japgolly.android.test/robolectric
public static void resetStaticState() {
ShadowWrangler.getInstance().silence();
Robolectric.application = new Application();
ShadowBitmapFactory.reset();
ShadowDrawable.reset();
ShadowMediaStore.reset();
ShadowLog.reset();
ShadowContext.clearFilesAndCache();
ShadowLooper.resetThreadLoopers();
ShadowDialog.reset();
ShadowContentResolver.reset();
ShadowLocalBroadcastManager.reset();
ShadowMimeTypeMap.reset();
ShadowPowerManager.reset();
ShadowStatFs.reset();
}
内容来源于网络,如有侵权,请联系作者删除!