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


Java MediumTest類代碼示例

本文整理匯總了Java中android.test.suitebuilder.annotation.MediumTest的典型用法代碼示例。如果您正苦於以下問題:Java MediumTest類的具體用法?Java MediumTest怎麽用?Java MediumTest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MediumTest類屬於android.test.suitebuilder.annotation包,在下文中一共展示了MediumTest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testConnectivityManagerDelegateDoesNotCrash

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testConnectivityManagerDelegateDoesNotCrash() {
    ConnectivityManagerDelegate delegate =
            new ConnectivityManagerDelegate(getInstrumentation().getTargetContext());
    delegate.getNetworkState();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // getNetworkState(Network) doesn't crash upon invalid Network argument.
        Network invalidNetwork = netIdToNetwork(NetId.INVALID);
        NetworkState invalidNetworkState = delegate.getNetworkState(invalidNetwork);
        assertFalse(invalidNetworkState.isConnected());
        assertEquals(-1, invalidNetworkState.getNetworkType());
        assertEquals(-1, invalidNetworkState.getNetworkSubType());

        Network[] networks = delegate.getAllNetworksUnfiltered();
        if (networks.length >= 1) {
            delegate.getNetworkState(networks[0]);
        }
        delegate.getDefaultNetId();
        NetworkCallback networkCallback = new NetworkCallback();
        NetworkRequest networkRequest = new NetworkRequest.Builder().build();
        delegate.registerNetworkCallback(networkRequest, networkCallback);
        delegate.unregisterNetworkCallback(networkCallback);
    }
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:27,代碼來源:NetworkChangeNotifierTest.java

示例2: testNetworkChangeNotifierIsOnline

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testNetworkChangeNotifierIsOnline() throws InterruptedException {
    Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
    // For any connection type it should return true.
    for (int i = ConnectivityManager.TYPE_MOBILE; i < ConnectivityManager.TYPE_VPN; i++) {
        mConnectivityDelegate.setActiveNetworkExists(true);
        mConnectivityDelegate.setNetworkType(i);
        mReceiver.onReceive(getInstrumentation().getTargetContext(), intent);
        assertTrue(NetworkChangeNotifier.isOnline());
    }
    mConnectivityDelegate.setActiveNetworkExists(false);
    mReceiver.onReceive(getInstrumentation().getTargetContext(), intent);
    assertFalse(NetworkChangeNotifier.isOnline());
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:17,代碼來源:NetworkChangeNotifierTest.java

示例3: testEkusVerified

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
@MediumTest
public void testEkusVerified() throws GeneralSecurityException, IOException {
    X509Util.addTestRootCertificate(CertTestUtil.pemToDer(CERTS_DIRECTORY + BAD_EKU_TEST_ROOT));
    X509Util.addTestRootCertificate(CertTestUtil.pemToDer(CERTS_DIRECTORY + GOOD_ROOT_CA));

    assertFalse(X509Util.verifyKeyUsage(X509Util.createCertificateFromBytes(
            CertTestUtil.pemToDer(CERTS_DIRECTORY + CRITICAL_CODE_SIGNING_EE))));

    assertFalse(X509Util.verifyKeyUsage(X509Util.createCertificateFromBytes(
            CertTestUtil.pemToDer(CERTS_DIRECTORY + NON_CRITICAL_CODE_SIGNING_EE))));

    assertFalse(X509Util.verifyKeyUsage(
            X509Util.createCertificateFromBytes(
                    readFileBytes(CERTS_DIRECTORY + WEB_CLIENT_AUTH_EE))));

    assertTrue(X509Util.verifyKeyUsage(X509Util.createCertificateFromBytes(
            CertTestUtil.pemToDer(CERTS_DIRECTORY + OK_CERT))));

    try {
        X509Util.clearTestRootCertificates();
    } catch (Exception e) {
        fail("Could not clear test root certificates: " + e.toString());
    }
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:25,代碼來源:X509UtilTest.java

示例4: testUpdateDatabasePerformance

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
/**
 * Tests performance of {@link com.db.oliviergoutay.greendao_vs_realm.greendao.GreenDaoDailyMealManager#updateDatabase(DailyMealApi)}
 */
@MediumTest
public void testUpdateDatabasePerformance() throws InterruptedException {
    CountDownLatch countDownLatch = new CountDownLatch(1);
    greenDaoDailyMealManager.setTestCountDownLatch(countDownLatch);
    long start = System.currentTimeMillis();
    greenDaoDailyMealManager.updateDatabase(getMockDailyMealForDate(new Date()));
    countDownLatch.await();
    long end = System.currentTimeMillis();

    Log.i(TAG, "Insert of 1 DailyMealApi took : " + (end - start) + " milliseconds");
    //Check time is less than 3000 millis
    assertTrue(3000 > end - start);

    //Check all were inserted
    assertEquals(1, dao.getDailyMealDao().loadAll().size());
    assertEquals(4, dao.getMealDao().loadAll().size());
}
 
開發者ID:olivierg13,項目名稱:GreenDao-vs-Realm,代碼行數:21,代碼來源:GreenDaoPerformanceTest.java

示例5: testStatementConstraint

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
@MediumTest
public void testStatementConstraint() throws Exception {
    mDatabase.execSQL("CREATE TABLE test (num INTEGER NOT NULL);");
    SQLiteStatement statement = mDatabase.compileStatement("INSERT INTO test (num) VALUES (?)");

    // Try to insert NULL, which violates the constraint
    try {
        statement.clearBindings();
        statement.execute();
        fail("expected exception not thrown");
    } catch (SQLiteConstraintException e) {
        // expected
    }

    // Make sure the statement can still be used
    statement.bindLong(1, 1);
    statement.execute();
    statement.close();

    Cursor c = mDatabase.query("test", null, null, null, null, null, null);
    int numCol = c.getColumnIndexOrThrow("num");
    c.moveToFirst();
    long num = c.getLong(numCol);
    assertEquals(1, num);
    c.close();
}
 
開發者ID:doppllib,項目名稱:core-doppl,代碼行數:27,代碼來源:DatabaseStatementTest.java

示例6: testRequeryWithSelection

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
@MediumTest
public void testRequeryWithSelection() throws Exception {
    populateDefaultTable();

    Cursor c = mDatabase.rawQuery("SELECT data FROM test WHERE data = '" + sString1 + "'",
            null);
    assertNotNull(c);
    assertEquals(1, c.getCount());
    assertTrue(c.moveToFirst());
    assertEquals(sString1, c.getString(0));
    c.deactivate();
    c.requery();
    assertEquals(1, c.getCount());
    assertTrue(c.moveToFirst());
    assertEquals(sString1, c.getString(0));
    c.close();
}
 
開發者ID:requery,項目名稱:sqlite-android,代碼行數:18,代碼來源:DatabaseCursorTest.java

示例7: testStatementMultipleBindings

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
@MediumTest
public void testStatementMultipleBindings() throws Exception {
    mDatabase.execSQL("CREATE TABLE test (num INTEGER, str TEXT);");
    SQLiteStatement statement =
            mDatabase.compileStatement("INSERT INTO test (num, str) VALUES (?, ?)");

    for (long i = 0; i < 10; i++) {
        statement.bindLong(1, i);
        statement.bindString(2, Long.toHexString(i));
        statement.execute();
    }
    statement.close();

    Cursor c = mDatabase.query("test", null, null, null, null, null, "ROWID");
    int numCol = c.getColumnIndexOrThrow("num");
    int strCol = c.getColumnIndexOrThrow("str");
    assertTrue(c.moveToFirst());
    for (long i = 0; i < 10; i++) {
        long num = c.getLong(numCol);
        String str = c.getString(strCol);
        assertEquals(i, num);
        assertEquals(Long.toHexString(i), str);
        c.moveToNext();
    }
    c.close();
}
 
開發者ID:requery,項目名稱:sqlite-android,代碼行數:27,代碼來源:DatabaseStatementTest.java

示例8: disabledTestResumeAfterReboot_simulateReboot

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
@MediumTest
public void disabledTestResumeAfterReboot_simulateReboot() throws Exception {
  updateAutoResumePrefs(PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT,
      PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);
  ITrackRecordingService service = bindAndGetService(createStartIntent());
  assertFalse(service.isRecording());

  // Simulate recording a track.
  long id = service.startNewTrack();
  assertTrue(service.isRecording());
  assertEquals(id, service.getRecordingTrackId());
  shutdownService();
  assertEquals(id, PreferencesUtils.getLong(context, R.string.recording_track_id_key));

  // Start the service in "resume" mode (simulates the on-reboot action).
  Intent startIntent = createStartIntent();
  startIntent.putExtra(TrackRecordingService.RESUME_TRACK_EXTRA_NAME, true);
  startService(startIntent);
  assertNotNull(getService());

  assertTrue(getService().isRecording());
}
 
開發者ID:Plonk42,項目名稱:mytracks,代碼行數:23,代碼來源:TrackRecordingServiceTest.java

示例9: testResumeAfterReboot_tooManyAttempts

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
@MediumTest
public void testResumeAfterReboot_tooManyAttempts() throws Exception {
  // Insert a dummy track.
  createDummyTrack(123L, System.currentTimeMillis(), true);

  // Set the number of attempts to max.
  updateAutoResumePrefs(TrackRecordingService.MAX_AUTO_RESUME_TRACK_RETRY_ATTEMPTS,
      PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);

  // Start the service in "resume" mode (simulates the on-reboot action).
  Intent startIntent = createStartIntent();
  startIntent.putExtra(TrackRecordingService.RESUME_TRACK_EXTRA_NAME, true);
  startService(startIntent);
  assertNotNull(getService());

  // We don't expect to resume the previous track, because there were already
  // too many attempts.
  assertFalse(getService().isRecording());
  ITrackRecordingService service = bindAndGetService(createStartIntent());
  assertEquals(-1L, service.getRecordingTrackId());
}
 
開發者ID:Plonk42,項目名稱:mytracks,代碼行數:22,代碼來源:TrackRecordingServiceTest.java

示例10: testInsertWaypointMarker_validWaypoint

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
@MediumTest
public void testInsertWaypointMarker_validWaypoint() throws Exception {
  createDummyTrack(123L, -1L, true);

  ITrackRecordingService service = bindAndGetService(createStartIntent());
  assertTrue(service.isRecording());
  insertLocation(service);

  assertEquals(1, service.insertWaypoint(WaypointCreationRequest.DEFAULT_WAYPOINT));
  Waypoint wpt = providerUtils.getWaypoint(1);
  assertEquals(getContext().getString(R.string.marker_waypoint_icon_url), wpt.getIcon());
  assertEquals(getContext().getString(R.string.marker_name_format, 1), wpt.getName());
  assertEquals(WaypointType.WAYPOINT, wpt.getType());
  assertEquals(123L, wpt.getTrackId());
  assertEquals(0.0, wpt.getLength());
  assertNotNull(wpt.getLocation());
  assertNull(wpt.getTripStatistics());
}
 
開發者ID:Plonk42,項目名稱:mytracks,代碼行數:19,代碼來源:TrackRecordingServiceTest.java

示例11: testUpdateDatabaseListPerformance

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
/**
 * Tests performance of {@link com.db.oliviergoutay.greendao_vs_realm.greendao.GreenDaoDailyMealManager#updateDatabase(Context, List)}
 */
@MediumTest
public void testUpdateDatabaseListPerformance() throws InterruptedException {
    List<DailyMealApi> mList = new ArrayList<>();
    Date date = new Date();
    for (int i = 0; i < 365; i++) {
        mList.add(getMockDailyMealForDate(date));
        date = Utilities.getYesterday(date);
    }

    CountDownLatch countDownLatch = new CountDownLatch(1);
    greenDaoDailyMealManager.setTestCountDownLatch(countDownLatch);
    long start = System.currentTimeMillis();
    greenDaoDailyMealManager.updateDatabase(mContext, mList);
    countDownLatch.await();
    long end = System.currentTimeMillis();

    Log.i(TAG, "Mass insert of 365 DailyMealApi took : " + (end - start) + " milliseconds");
    //Check time is less than 3000 millis
    assertTrue(3000 > end - start);

    //Check all were inserted
    assertEquals(365, dao.getDailyMealDao().loadAll().size());
    assertEquals(365 * 4, dao.getMealDao().loadAll().size());
}
 
開發者ID:olivierg13,項目名稱:GreenDao-vs-Realm,代碼行數:28,代碼來源:GreenDaoPerformanceTest.java

示例12: testQueryDatabasePerformance

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
/**
 * Tests performance of {@link com.db.oliviergoutay.greendao_vs_realm.realm.RealmDailyMealManager#queryDailyMeal(long)}
 * and {@link com.db.oliviergoutay.greendao_vs_realm.realm.RealmDailyMealManager#queryAllDailyMealsOrdered(boolean)}
 */
@MediumTest
public void testQueryDatabasePerformance() throws InterruptedException {
    //Add stuff in db
    testUpdateDatabaseListPerformance();

    //Query one object
    long eatenOn = realmDailyMealManager.queryAllDailyMealsOrdered(true).get(0).getEatenOn();
    long start = System.currentTimeMillis();
    assertNotNull(realmDailyMealManager.queryDailyMeal(eatenOn));
    long end = System.currentTimeMillis();
    Log.i(TAG, "Query of one DailyMealRealm took : " + (end - start) + " milliseconds");

    //Query all objects (not ordered)
    start = System.currentTimeMillis();
    assertEquals(365, realmDailyMealManager.queryAllDailyMealsOrdered(false).size());
    end = System.currentTimeMillis();
    Log.i(TAG, "Query of all the DailyMealRealm (not ordered) took : " + (end - start) + " milliseconds");

    //Query all objects (ordered)
    start = System.currentTimeMillis();
    assertEquals(365, realmDailyMealManager.queryAllDailyMealsOrdered(true).size());
    end = System.currentTimeMillis();
    Log.i(TAG, "Query of all the DailyMealRealm (ordered) took : " + (end - start) + " milliseconds");
}
 
開發者ID:olivierg13,項目名稱:GreenDao-vs-Realm,代碼行數:29,代碼來源:RealmPerformanceTest.java

示例13: testNetworkChangeNotifierRegistersWhenPolicyDictates

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testNetworkChangeNotifierRegistersWhenPolicyDictates()
        throws InterruptedException {
    Context context = getInstrumentation().getTargetContext();

    NetworkChangeNotifierAutoDetect.Observer observer =
            new TestNetworkChangeNotifierAutoDetectObserver();

    NetworkChangeNotifierAutoDetect receiver = new NetworkChangeNotifierAutoDetect(
            observer, context, new RegistrationPolicyApplicationStatus() {
                @Override
                int getApplicationState() {
                    return ApplicationState.HAS_RUNNING_ACTIVITIES;
                }
            });

    assertTrue(receiver.isReceiverRegisteredForTesting());

    receiver = new NetworkChangeNotifierAutoDetect(
            observer, context, new RegistrationPolicyApplicationStatus() {
                @Override
                int getApplicationState() {
                    return ApplicationState.HAS_PAUSED_ACTIVITIES;
                }
            });

    assertFalse(receiver.isReceiverRegisteredForTesting());
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:31,代碼來源:NetworkChangeNotifierTest.java

示例14: testNetworkChangeNotifierRegistersForIntents

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testNetworkChangeNotifierRegistersForIntents() throws InterruptedException {
    RegistrationPolicyApplicationStatus policy =
            (RegistrationPolicyApplicationStatus) mReceiver.getRegistrationPolicy();
    triggerApplicationStateChange(policy, ApplicationState.HAS_RUNNING_ACTIVITIES);
    assertTrue(mReceiver.isReceiverRegisteredForTesting());

    triggerApplicationStateChange(policy, ApplicationState.HAS_PAUSED_ACTIVITIES);
    assertFalse(mReceiver.isReceiverRegisteredForTesting());

    triggerApplicationStateChange(policy, ApplicationState.HAS_RUNNING_ACTIVITIES);
    assertTrue(mReceiver.isReceiverRegisteredForTesting());
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:16,代碼來源:NetworkChangeNotifierTest.java

示例15: testNetworkChangeNotifierMaxBandwidthEthernet

import android.test.suitebuilder.annotation.MediumTest; //導入依賴的package包/類
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testNetworkChangeNotifierMaxBandwidthEthernet() throws InterruptedException {
    // Show that for Ethernet the link speed is unknown (+Infinity).
    mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_ETHERNET);
    assertEquals(ConnectionType.CONNECTION_ETHERNET, getCurrentConnectionType());
    assertEquals(Double.POSITIVE_INFINITY, getCurrentMaxBandwidthInMbps());
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:10,代碼來源:NetworkChangeNotifierTest.java


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