当前位置: 首页>>代码示例>>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;未经允许,请勿转载。