本文整理汇总了Java中android.test.mock.MockApplication类的典型用法代码示例。如果您正苦于以下问题:Java MockApplication类的具体用法?Java MockApplication怎么用?Java MockApplication使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MockApplication类属于android.test.mock包,在下文中一共展示了MockApplication类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setApplication
import android.test.mock.MockApplication; //导入依赖的package包/类
@Override
public void setApplication(Application application) {
if (application instanceof MockApplication) {
boolean meetsGuiceRequirements = false;
try {
meetsGuiceRequirements = application.getPackageManager() != null;
meetsGuiceRequirements = meetsGuiceRequirements && application.getPackageName() != null;
meetsGuiceRequirements = meetsGuiceRequirements && application.getResources() != null;
} catch (Exception ignored) {
Log.w(TAG, "Overriding application passed to setApplication(). If you are using a custom instance of MockApplication, ensure that the following methods are implemented:\n" +
"\tpublic PackageManager getPackageManager()\n" +
"\tpublic String getPackageName()\n" +
"\tpublic Resources getResources()");
}
if (meetsGuiceRequirements) {
super.setApplication(application);
} else {
super.setApplication(new MinimalApplication());
}
} else {
super.setApplication(application);
}
}
示例2: testWrapActivity
import android.test.mock.MockApplication; //导入依赖的package包/类
@Test
@UiThreadTest
public void testWrapActivity() throws Exception {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.madisp.pretty", "TestActivity"));
Activity act = instrumentation.newActivity(
Activity.class,
context,
null,
new MockApplication(),
intent,
new ActivityInfo(),
"",
null,
null,
null);
Pretty.wrap(act);
}
示例3: setUp
import android.test.mock.MockApplication; //导入依赖的package包/类
@Before public void setUp() throws Exception {
modules.add(new TestModule1());
modules.add(new TestModule2());
modules.add(new TestModule3());
modulesPool = new ModulesPool(modules);
entry = new TestScreen1();
MockitoAnnotations.initMocks(this);
lepka = new LepkaImpl(new MockApplication(),
new TestScreen1(), executor, modulesPool, backStack);
}
示例4: setUp
import android.test.mock.MockApplication; //导入依赖的package包/类
@Before public void setUp() throws Exception {
modules.add(new TestModule1());
modules.add(new TestModule2());
modules.add(new TestModule3());
builder.setApplication(new MockApplication())
.registerModules(modules)
.setEntryScreen(new TestScreen1())
.setUseSupport(true);
}
示例5: newMockLiveAuthClient
import android.test.mock.MockApplication; //导入依赖的package包/类
public static LiveAuthClient newMockLiveAuthClient() {
return new LiveAuthClient(new MockApplication() {
@Override
public Context getApplicationContext() {
return this;
}
}, "someclientid");
}
示例6: getApp
import android.test.mock.MockApplication; //导入依赖的package包/类
@Override
protected MockApplication getApp(String config) throws Exception {
return new MockBillingXmlApplication(config);
}
示例7: getApp
import android.test.mock.MockApplication; //导入依赖的package包/类
@Override
protected MockApplication getApp(String config) throws Exception {
return new MockBillingJsonApplication(config);
}
示例8: getApp
import android.test.mock.MockApplication; //导入依赖的package包/类
@Override
protected MockApplication getApp(String config) throws Exception {
return new MockBillingCsvApplication(config);
}
示例9: onInit
import android.test.mock.MockApplication; //导入依赖的package包/类
/**
* Do not override this method. Use {@link #onPreInit(Holo, Bundle)} and
* {@link #onPostInit(Holo, Bundle)}
*/
protected void onInit(Holo config, Bundle savedInstanceState) {
if (mInited) {
throw new IllegalStateException("This instance was already inited");
}
mInited = true;
if (config == null) {
config = createConfig(savedInstanceState);
}
if (config == null) {
config = Holo.defaultConfig();
}
onPreInit(config, savedInstanceState);
if (!config.ignoreApplicationInstanceCheck && !(getApplication() instanceof Application)) {
boolean throwError = true;
if (config.allowMockApplicationInstance) {
try {
throwError = !(getApplication() instanceof MockApplication);
if (!throwError) {
Log.w("HoloEverywhere", "Application instance is MockApplication. Wow. Let's begin tests...");
}
} catch (Exception e) {
}
}
if (throwError) {
String text = "Application instance isn't HoloEverywhere.\n";
if (getApplication().getClass() == android.app.Application.class) {
text += "Put attr 'android:name=\"org.holoeverywhere.app.Application\"'" +
" in <application> tag of AndroidManifest.xml";
} else {
text += "Please sure that you extend " + getApplication().getClass() +
" from a org.holoeverywhere.app.Application";
}
throw new IllegalStateException(text);
}
}
getLayoutInflater().setFragmentActivity(this);
if (this instanceof Activity) {
final Activity activity = (Activity) this;
ThemeManager.applyTheme(activity, mLastThemeResourceId == 0);
if (!config.ignoreThemeCheck && ThemeManager.getThemeType(this) == ThemeManager.INVALID) {
throw new HoloThemeException(activity);
}
TypedArray a = obtainStyledAttributes(new int[]{android.R.attr.windowActionBarOverlay, R.attr.windowActionBarOverlay});
if (a.getBoolean(0, false) || a.getBoolean(1, false)) {
supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
}
a.recycle();
a = obtainStyledAttributes(new int[]{android.R.attr.windowActionModeOverlay, R.attr.windowActionBarOverlay});
if (a.getBoolean(0, false) || a.getBoolean(1, false)) {
supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
}
a.recycle();
}
onPostInit(config, savedInstanceState);
lockAttaching();
}
示例10: setApplication
import android.test.mock.MockApplication; //导入依赖的package包/类
@Test public void setApplication() throws Exception {
assertTrue(builder.application instanceof MockApplication);
}
示例11: getApp
import android.test.mock.MockApplication; //导入依赖的package包/类
protected abstract MockApplication getApp(String config) throws Exception;