本文整理匯總了Java中org.robolectric.shadows.ShadowLog類的典型用法代碼示例。如果您正苦於以下問題:Java ShadowLog類的具體用法?Java ShadowLog怎麽用?Java ShadowLog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ShadowLog類屬於org.robolectric.shadows包,在下文中一共展示了ShadowLog類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setup
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@Before
public void setup() {
Robolectric.getBackgroundThreadScheduler().reset();
Robolectric.getForegroundThreadScheduler().reset();
ShadowLog.stream = System.out;
activity = Robolectric.buildActivity(MockMainActivity.class).create().start().resume().visible().get();
shadowOf(activity).grantPermissions("android.permission.INTERNET");
server= new MockWebServer();
try {
server.start();
HttpUrl url= server.url("/");
UTConstants.REQUEST_BASE_URL_UT_V2 = url.toString();
System.out.println(UTConstants.REQUEST_BASE_URL_UT_V2);
ShadowSettings.setTestURL(url.toString());
TestResponsesUT.setTestURL(url.toString());
} catch (IOException e) {
System.out.print("IOException");
}
bgScheduler = Robolectric.getBackgroundThreadScheduler();
uiScheduler = Robolectric.getForegroundThreadScheduler();
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();
bgScheduler.pause();
uiScheduler.pause();
}
示例2: setUp
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
QMail.setDebug(true);
ShadowLog.stream = System.out;
ShadowSQLiteConnection.reset();
account = getNewAccount();
StorageManager storageManager = StorageManager.getInstance(RuntimeEnvironment.application);
databaseFile = storageManager.getDatabase(account.getUuid(), account.getLocalStorageProviderId());
Assert.assertTrue(databaseFile.getParentFile().isDirectory() || databaseFile.getParentFile().mkdir());
attachmentDir = StorageManager.getInstance(RuntimeEnvironment.application).getAttachmentDirectory(
account.getUuid(), account.getLocalStorageProviderId());
Assert.assertTrue(attachmentDir.isDirectory() || attachmentDir.mkdir());
}
示例3: setUp
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
connectivityManager = mock(ConnectivityManager.class);
oAuth2TokenProvider = createOAuth2TokenProvider();
socketFactory = TestTrustedSocketFactory.newInstance();
settings = new SimpleImapSettings();
settings.setUsername(USERNAME);
settings.setPassword(PASSWORD);
if (DEBUGGING) {
ShadowLog.stream = System.out;
K9MailLib.setDebug(true);
K9MailLib.setDebugSensitive(true);
}
}
示例4: assertExceptionLogged
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
private static void assertExceptionLogged(int logType, String message, String exceptionClassname, String tag,
int index) {
List<LogItem> logs = ShadowLog.getLogs();
assertThat(logs).hasSize(index + 1);
LogItem log = logs.get(index);
assertThat(log.type).isEqualTo(logType);
assertThat(log.tag).isEqualTo(tag != null ? tag : "TimberTest");
if (message != null) {
assertThat(log.msg).startsWith(message);
}
assertThat(log.msg).contains(exceptionClassname);
// We use a low-level primitive that Robolectric doesn't populate.
assertThat(log.throwable).isNull();
}
示例5: setUp
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
K9.DEBUG = true;
ShadowLog.stream = System.out;
ShadowSQLiteConnection.reset();
account = getNewAccount();
StorageManager storageManager = StorageManager.getInstance(RuntimeEnvironment.application);
databaseFile = storageManager.getDatabase(account.getUuid(), account.getLocalStorageProviderId());
Assert.assertTrue(databaseFile.getParentFile().isDirectory() || databaseFile.getParentFile().mkdir());
attachmentDir = StorageManager.getInstance(RuntimeEnvironment.application).getAttachmentDirectory(
account.getUuid(), account.getLocalStorageProviderId());
Assert.assertTrue(attachmentDir.isDirectory() || attachmentDir.mkdir());
}
示例6: setUp
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@Before
public void setUp() throws IOException
{
// Output logs emitted during tests so they may be accessed
ShadowLog.stream = System.out;
activity = Robolectric.setupActivity(ImportExportActivity.class);
db = new DBHelper(activity);
imageDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
assertNotNull(imageDir);
boolean result;
if(imageDir.exists() == false)
{
result = imageDir.mkdirs();
assertTrue(result);
}
missingReceipt = new File(imageDir, "missing");
orphanReceipt = new File(imageDir, "orphan");
result = orphanReceipt.createNewFile();
assertTrue(result);
}
示例7: setupDagger
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@Before
public void setupDagger() {
DaggerApplicationComponentTest.builder()
.applicationContextModuleTest(new ApplicationContextModuleTest())
.repositoryModuleTest(new RepositoryModuleTest(false))
.build().inject(this);
//activity = Robolectric.setupActivity(MainActivity.class);
activity = Robolectric.buildActivity(MainActivity.class)
.create()
.start()
.resume()
.visible()
.get();
tradeAdapter = mock(TradeRecyclerViewAdapter.class);
fab = (FloatingActionButton) activity.findViewById(R.id.fab);
rvTrades = (RealmRecyclerView) activity.findViewById(R.id.list_trades);
//This is for printing log messages in console
ShadowLog.stream = System.out;
}
示例8: setUp
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
ShadowLog.stream = System.out;
mockWebServer = new MockWebServer();
mockWebServer.start(9999);
baseRetryHandler = BaseRetryHandler_.getInstance_(RuntimeEnvironment.application);
connectivityAwareUrlClient = ConnectivityAwareUrlClient_.getInstance_(RuntimeEnvironment.application);
connectivityAwareUrlClient.setWrappedClient(new OkClient(new OkHttpClient()));
connectivityAwareUrlClient.setRetryHandler(baseRetryHandler);
RestAdapter restAdapter = new RestAdapter.Builder()
.setClient(connectivityAwareUrlClient)
.setLogLevel(RestAdapter.LogLevel.FULL)
.setEndpoint(mockWebServer.getUrl("/").toString()).build();
sodaService = restAdapter.create(SodaService.class);
}
示例9: copyDataSet
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
public static void copyDataSet(String filename) throws IllegalArgumentException{ // /test/resources/databses/<filename>
String targetPath = TestHelper.getDatabasePath();
ShadowLog.stream = System.out;
File dbFile = new File(TestHelper.getTestResourcePath().concat("databases/" + filename));
if (!dbFile.exists()) {
System.out.print("File does not exist");
}
File targetDir = new File(targetPath);
if(!targetDir.exists()) {
targetDir.mkdirs();
}
File targetFile = new File(targetPath + "AluShareDataBase.db");
if (targetFile.exists()) {
targetFile.delete();
}
try {
TestHelper.copyFileUsingStream(dbFile,targetFile);
} catch (IOException e) {
System.out.println("File copy failed");
}
}
示例10: loadPositions_withNoConnection_shouldLogMoPubErrorCodeNoConnection_shouldCallFailureHandler
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@Test
public void loadPositions_withNoConnection_shouldLogMoPubErrorCodeNoConnection_shouldCallFailureHandler() {
MoPubLog.setSdkHandlerLevel(Level.ALL);
when(mockContext.checkCallingOrSelfPermission(anyString()))
.thenReturn(PackageManager.PERMISSION_DENIED);
when(spyActivity.getApplicationContext()).thenReturn(mockContext);
// Reinit the subject so we get our mocked context.
subject = new ServerPositioningSource(spyActivity);
// Simulate failure after max time.
subject.setMaximumRetryTimeMilliseconds(999);
subject.loadPositions("test_ad_unit", mockPositioningListener);
verify(mockRequestQueue).add(positionRequestCaptor.capture());
positionRequestCaptor.getValue().deliverError(new NoConnectionError());
verify(mockPositioningListener).onFailed();
final List<ShadowLog.LogItem> allLogMessages = ShadowLog.getLogs();
final ShadowLog.LogItem latestLogMessage = allLogMessages.get(allLogMessages.size() - 2);
// All log messages end with a newline character.
assertThat(latestLogMessage.msg.trim()).isEqualTo(MoPubErrorCode.NO_CONNECTION.toString());
}
示例11: displayWarningForMissingActivities_withOneMissingActivity_shouldLogOnlyThatOne
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@Test
public void displayWarningForMissingActivities_withOneMissingActivity_shouldLogOnlyThatOne() throws Exception {
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MraidActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MraidVideoPlayerActivity.class), mockResolveInfo);
// Here, we leave out MoPubBrowser on purpose
ShadowLog.setupLogging();
ManifestUtils.displayWarningForMissingActivities(context, requiredWebViewSdkActivities);
assertLogIncludes("com.mopub.common.MoPubBrowser");
assertLogDoesntInclude(
"com.mopub.mobileads.MoPubActivity",
"com.mopub.mobileads.MraidActivity",
"com.mopub.mobileads.MraidVideoPlayerActivity"
);
}
示例12: displayWarningForMissingActivities_withAllMissingActivities_shouldLogMessage
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@Test
public void displayWarningForMissingActivities_withAllMissingActivities_shouldLogMessage() throws Exception {
setDebugMode(true);
ShadowLog.setupLogging();
ManifestUtils.displayWarningForMissingActivities(context, requiredWebViewSdkActivities);
final List<ShadowLog.LogItem> logs = ShadowLog.getLogs();
assertLogIncludes(
"com.mopub.mobileads.MoPubActivity",
"com.mopub.mobileads.MraidActivity",
"com.mopub.mobileads.MraidVideoPlayerActivity",
"com.mopub.common.MoPubBrowser"
);
}
示例13: displayWarningForMisconfiguredActivities_withAllActivitiesConfigured_shouldNotLogOrShowToast
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@TargetApi(13)
@Test
public void displayWarningForMisconfiguredActivities_withAllActivitiesConfigured_shouldNotLogOrShowToast() throws Exception {
ManifestUtils.FlagCheckUtil mockActivitiyConfigCheck = mock(ManifestUtils.FlagCheckUtil.class);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_KEYBOARD_HIDDEN))).thenReturn(true);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_ORIENTATION))).thenReturn(true);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_SCREEN_SIZE))).thenReturn(true);
ManifestUtils.setFlagCheckUtil(mockActivitiyConfigCheck);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MraidActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MraidVideoPlayerActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubBrowser.class), mockResolveInfo);
ShadowLog.setupLogging();
setDebugMode(true);
ManifestUtils.displayWarningForMisconfiguredActivities(context, requiredWebViewSdkActivities);
assertThat(ShadowToast.getLatestToast()).isNull();
assertThat(ShadowLog.getLogs()).isEmpty();
}
示例14: mock
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@TargetApi(13)
@Test
public void displayWarningForMisconfiguredActivities_withOneMisconfiguredActivity_withMissingAllConfigChangesValues_shouldLogAllConfigChangesValues() throws Exception {
ManifestUtils.FlagCheckUtil mockActivitiyConfigCheck = mock(ManifestUtils.FlagCheckUtil.class);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_KEYBOARD_HIDDEN))).thenReturn(false);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_ORIENTATION))).thenReturn(false);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_SCREEN_SIZE))).thenReturn(false);
ManifestUtils.setFlagCheckUtil(mockActivitiyConfigCheck);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubActivity.class), mockResolveInfo);
ShadowLog.setupLogging();
ManifestUtils.displayWarningForMisconfiguredActivities(context, requiredWebViewSdkActivities);
assertLogIncludes("The android:configChanges param for activity " + MoPubActivity.class.getName() + " must include keyboardHidden.");
assertLogIncludes("The android:configChanges param for activity " + MoPubActivity.class.getName() + " must include orientation.");
assertLogIncludes("The android:configChanges param for activity " + MoPubActivity.class.getName() + " must include screenSize.");
}
示例15: when
import org.robolectric.shadows.ShadowLog; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@TargetApi(13)
@Test
public void displayWarningForMisconfiguredActivities_withMissingScreenSize_withTargetApiLessThan13_shouldNotLogOrShowToast() throws Exception {
// Set target API to < 13
ApplicationInfo applicationInfo = context.getApplicationInfo();
applicationInfo.targetSdkVersion = Build.VERSION_CODES.HONEYCOMB_MR1;
when(context.getApplicationInfo()).thenReturn(applicationInfo);
ManifestUtils.FlagCheckUtil mockActivitiyConfigCheck = mock(ManifestUtils.FlagCheckUtil.class);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_KEYBOARD_HIDDEN))).thenReturn(true);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_ORIENTATION))).thenReturn(true);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_SCREEN_SIZE))).thenReturn(false);
ManifestUtils.setFlagCheckUtil(mockActivitiyConfigCheck);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubActivity.class), mockResolveInfo);
ShadowLog.setupLogging();
setDebugMode(true);
ManifestUtils.displayWarningForMisconfiguredActivities(context, requiredWebViewSdkActivities);
assertThat(ShadowToast.getLatestToast()).isNull();
assertThat(ShadowLog.getLogs()).isEmpty();
}