當前位置: 首頁>>代碼示例>>Java>>正文


Java ShadowLog類代碼示例

本文整理匯總了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();
}
 
開發者ID:appnexus,項目名稱:mobile-sdk-android,代碼行數:26,代碼來源:BaseRoboTest.java

示例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());
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:17,代碼來源:MigrationTest.java

示例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);
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:17,代碼來源:ImapConnectionTest.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:TimberTest.java

示例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());
}
 
開發者ID:scoute-dich,項目名稱:K9-MailClient,代碼行數:17,代碼來源:MigrationTest.java

示例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);
}
 
開發者ID:brarcher,項目名稱:budget-watch,代碼行數:26,代碼來源:DatabaseCleanupTaskTest.java

示例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;
}
 
開發者ID:mplacona,項目名稱:trade-safe,代碼行數:25,代碼來源:MainActivityTest.java

示例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);
}
 
開發者ID:richardradics,項目名稱:MVPAndroidBootstrap,代碼行數:21,代碼來源:ConnectivityAwereUrlClientTest.java

示例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");
    }
}
 
開發者ID:weichweich,項目名稱:AluShare,代碼行數:26,代碼來源:DummyDataSet.java

示例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());
}
 
開發者ID:JSafaiyeh,項目名稱:Fabric-Example-App-Android,代碼行數:25,代碼來源:ServerPositioningSourceTest.java

示例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"
    );
}
 
開發者ID:JSafaiyeh,項目名稱:Fabric-Example-App-Android,代碼行數:19,代碼來源:ManifestUtilsTest.java

示例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"
    );
}
 
開發者ID:JSafaiyeh,項目名稱:Fabric-Example-App-Android,代碼行數:17,代碼來源:ManifestUtilsTest.java

示例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();
}
 
開發者ID:JSafaiyeh,項目名稱:Fabric-Example-App-Android,代碼行數:24,代碼來源:ManifestUtilsTest.java

示例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.");
}
 
開發者ID:JSafaiyeh,項目名稱:Fabric-Example-App-Android,代碼行數:22,代碼來源:ManifestUtilsTest.java

示例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();
}
 
開發者ID:JSafaiyeh,項目名稱:Fabric-Example-App-Android,代碼行數:26,代碼來源:ManifestUtilsTest.java


注:本文中的org.robolectric.shadows.ShadowLog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。