Java 类android.test.suitebuilder.annotation.MediumTest 实例源码

项目:chromium-net-for-android    文件:NetworkChangeNotifierTest.java   
@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);
    }
}
项目:chromium-net-for-android    文件:NetworkChangeNotifierTest.java   
@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());
}
项目:chromium-net-for-android    文件:X509UtilTest.java   
@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());
    }
}
项目:GreenDao-vs-Realm    文件:GreenDaoPerformanceTest.java   
/**
 * 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());
}
项目:core-doppl    文件:DatabaseStatementTest.java   
@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();
}
项目:sqlite-android    文件:DatabaseCursorTest.java   
@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();
}
项目:sqlite-android    文件:DatabaseStatementTest.java   
@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();
}
项目:mytracks    文件:TrackRecordingServiceTest.java   
@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());
}
项目:mytracks    文件:TrackRecordingServiceTest.java   
@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());
}
项目:mytracks    文件:TrackRecordingServiceTest.java   
@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());
}
项目:GreenDao-vs-Realm    文件:GreenDaoPerformanceTest.java   
/**
 * 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());
}
项目:GreenDao-vs-Realm    文件:RealmPerformanceTest.java   
/**
 * 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");
}
项目:chromium-net-for-android    文件:NetworkChangeNotifierTest.java   
@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());
}
项目:chromium-net-for-android    文件:NetworkChangeNotifierTest.java   
@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());
}
项目:chromium-net-for-android    文件:NetworkChangeNotifierTest.java   
@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());
}
项目:chromium-net-for-android    文件:NetworkChangeNotifierTest.java   
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testNetworkChangeNotifierMaxBandwidthWifi() throws InterruptedException {
    // Test that for wifi types the link speed is read from the WifiManager.
    mWifiDelegate.setLinkSpeedInMbps(42);
    mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_WIFI);
    assertEquals(ConnectionType.CONNECTION_WIFI, getCurrentConnectionType());
    assertEquals(42.0, getCurrentMaxBandwidthInMbps());
}
项目:chromium-net-for-android    文件:NetworkChangeNotifierTest.java   
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testNetworkChangeNotifierMaxBandwidthWiMax() throws InterruptedException {
    // Show that for WiMax the link speed is unknown (+Infinity), although the type is 4g.
    // TODO(jkarlin): Add support for CONNECTION_WIMAX as specified in
    // http://w3c.github.io/netinfo/.
    mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_WIMAX);
    assertEquals(ConnectionType.CONNECTION_4G, getCurrentConnectionType());
    assertEquals(Double.POSITIVE_INFINITY, getCurrentMaxBandwidthInMbps());
}
项目:chromium-net-for-android    文件:NetworkChangeNotifierTest.java   
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testNetworkChangeNotifierMaxBandwidthBluetooth() throws InterruptedException {
    // Show that for bluetooth the link speed is unknown (+Infinity).
    mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_BLUETOOTH);
    assertEquals(ConnectionType.CONNECTION_BLUETOOTH, getCurrentConnectionType());
    assertEquals(Double.POSITIVE_INFINITY, getCurrentMaxBandwidthInMbps());
}
项目:chromium-net-for-android    文件:NetworkChangeNotifierTest.java   
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testNetworkChangeNotifierMaxBandwidthMobile() throws InterruptedException {
    // Test that for mobile types the subtype is used to determine the maxBandwidth.
    mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_MOBILE);
    mConnectivityDelegate.setNetworkSubtype(TelephonyManager.NETWORK_TYPE_LTE);
    assertEquals(ConnectionType.CONNECTION_4G, getCurrentConnectionType());
    assertEquals(100.0, getCurrentMaxBandwidthInMbps());
}
项目:chromium-net-for-android    文件:NetworkChangeNotifierTest.java   
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testNetworkChangeNotifierMaxBandwidthNotifications() throws InterruptedException {
    // Initialize the NetworkChangeNotifier with a connection.
    mConnectivityDelegate.setActiveNetworkExists(true);
    mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_WIFI);
    mWifiDelegate.setLinkSpeedInMbps(1);
    Intent connectivityIntent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
    mReceiver.onReceive(getInstrumentation().getTargetContext(), connectivityIntent);
    assertTrue(mNotifier.hasReceivedMaxBandwidthNotification());
    mNotifier.resetHasReceivedMaxBandwidthNotification();

    // We shouldn't be re-notified if the connection hasn't actually changed.
    NetworkChangeNotifierTestObserver observer = new NetworkChangeNotifierTestObserver();
    NetworkChangeNotifier.addConnectionTypeObserver(observer);
    mReceiver.onReceive(getInstrumentation().getTargetContext(), connectivityIntent);
    assertFalse(mNotifier.hasReceivedMaxBandwidthNotification());

    // We should be notified if the bandwidth changed but not the connection type.
    mWifiDelegate.setLinkSpeedInMbps(2);
    mReceiver.onReceive(getInstrumentation().getTargetContext(), connectivityIntent);
    assertTrue(mNotifier.hasReceivedMaxBandwidthNotification());
    mNotifier.resetHasReceivedMaxBandwidthNotification();

    // We should be notified if bandwidth and connection type changed.
    mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_ETHERNET);
    mReceiver.onReceive(getInstrumentation().getTargetContext(), connectivityIntent);
    assertTrue(mNotifier.hasReceivedMaxBandwidthNotification());
    mNotifier.resetHasReceivedMaxBandwidthNotification();

    // We should be notified if the connection type changed, but not the bandwidth.
    // Note that TYPE_ETHERNET and TYPE_BLUETOOTH have the same +INFINITY max bandwidth.
    // This test will fail if that changes.
    mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_BLUETOOTH);
    mReceiver.onReceive(getInstrumentation().getTargetContext(), connectivityIntent);
    assertTrue(mNotifier.hasReceivedMaxBandwidthNotification());
}
项目:chromium-net-for-android    文件:NetworkChangeNotifierTest.java   
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testCreateNetworkChangeNotifierAlwaysWatchForChanges() throws InterruptedException {
    createTestNotifier(WatchForChanges.ALWAYS);
    assertTrue(mReceiver.isReceiverRegisteredForTesting());

    // Make sure notifications can be received.
    NetworkChangeNotifierTestObserver observer = new NetworkChangeNotifierTestObserver();
    NetworkChangeNotifier.addConnectionTypeObserver(observer);
    Intent connectivityIntent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
    mReceiver.onReceive(getInstrumentation().getTargetContext(), connectivityIntent);
    assertTrue(observer.hasReceivedNotification());
}
项目:chromium-net-for-android    文件:NetworkChangeNotifierTest.java   
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testQueryableAPIsDoNotCrash() {
    NetworkChangeNotifierAutoDetect.Observer observer =
            new TestNetworkChangeNotifierAutoDetectObserver();
    NetworkChangeNotifierAutoDetect ncn = new NetworkChangeNotifierAutoDetect(observer,
            getInstrumentation().getTargetContext(), new RegistrationPolicyAlwaysRegister());
    ncn.getNetworksAndTypes();
    ncn.getDefaultNetId();
}
项目:SlackMessage    文件:SlackMessageTest.java   
@MediumTest
public void testChannelOverride() throws IOException {
    SlackMessage slackMessage = SlackMessage.create()
            .username("Hi, Im suhanlee")
            .iconEmoji(":ghost:")
            .text("BOO!")
            .channel("#testchannel");

    String body = SlackReporter.create(apiKey).reportSync(slackMessage);
    assertEquals("ok", body);
}
项目:SlackMessage    文件:SlackMessageTest.java   
@MediumTest
public void testImageUrl() throws IOException {
    SlackMessage slackMessage = SlackMessage.create()
            .username("Hi, Im suhanlee")
            .text("BOO!")
            .channel("#testchannel")
            .iconUrl("https://avatars0.githubusercontent.com/u/2666166?v=3&s=460");

    String body = SlackReporter.create(apiKey).reportSync(slackMessage);
    assertEquals("ok", body);
}
项目:intellij-ce-playground    文件:MainActivityTest.java   
@MediumTest
public void testAndroidStrings() {
    assertEquals("SUCCESS-APP", mAppTextView1.getText().toString());
    assertEquals("SUCCESS-LIB1", mLib1TextView1.getText().toString());
    assertEquals("SUCCESS-LIB2", mLib2TextView1.getText().toString());
    assertEquals("SUCCESS-LIB2b", mLib2bTextView1.getText().toString());
    assertEquals("SUCCESS-LIBAPP", mLibappTextView1.getText().toString());
}
项目:intellij-ce-playground    文件:MainActivityGroup2Test.java   
@MediumTest
public void testResOverlay() {
    // because this group has lower priority, we check that the resource from
    // this flavor is not used.
    assertFalse("fb".equals(mResOverLay.getText().toString()));
    assertEquals("fb", mResOverLay2.getText().toString());
}
项目:intellij-ce-playground    文件:MainActivityGroup1Test.java   
/**
 * The name 'test preconditions' is a convention to signal that if this
 * test doesn't pass, the test case was not set up properly and it might
 * explain any and all failures in other tests.  This is not guaranteed
 * to run before other tests, as junit uses reflection to find the tests.
 */
@MediumTest
public void testPreconditions() {
    assertNotNull(mResOverLay);
    assertNotNull(mResOverLay1);
    assertNotNull(mBuildConfig1);
    assertNotNull(mCodeOverlay1);
}
项目:accentype-android    文件:SoftKeyboardTest.java   
/**
 * Test binding to service
 */
@MediumTest
public void testBindable() {
    Intent startIntent = new Intent();
    startIntent.setClass(getContext(), SoftKeyboard.class);
    IBinder service = bindService(startIntent);
}
项目:sqlite-android    文件:DatabaseGeneralTest.java   
@MediumTest
public void testCustomFunction() {
    mDatabase.addCustomFunction("roundFunction", 1, new SQLiteDatabase.CustomFunction() {
        @Override
        public String callback(String[] args) {
            String input = args[0];
            double value = Double.parseDouble(input);
            return String.valueOf(Math.round(value));
        }
    });
    Cursor cursor = mDatabase.rawQuery("SELECT roundFunction(3.14)", null);
    assertTrue(cursor.moveToFirst());
    int result = cursor.getInt(0);
    assertSame(3, result);
}
项目:sqlite-android    文件:DatabaseGeneralTest.java   
@MediumTest
public void testUpdate() throws Exception {
    populateDefaultTable();

    ContentValues values = new ContentValues(1);
    values.put("data", "this is an updated test");
    assertEquals(1, mDatabase.update("test", values, "_id=1", null));
    Cursor c = mDatabase.query("test", null, "_id=1", null, null, null, null);
    assertNotNull(c);
    assertEquals(1, c.getCount());
    c.moveToFirst();
    String value = c.getString(c.getColumnIndexOrThrow("data"));
    assertEquals("this is an updated test", value);
}
项目:GreenDao-vs-Realm    文件:RealmPerformanceTest.java   
/**
 * Tests performance of {@link com.db.oliviergoutay.greendao_vs_realm.realm.RealmDailyMealManager#updateDatabase(Context, List)}
 */
@MediumTest
public void testUpdateDatabaseListPerformance() throws InterruptedException {
    List<DailyMealRealm> mList = new ArrayList<>();
    Date date = new Date();
    for (int i = 0; i < 365; i++) {
        mList.add(getMockDailyMealForDate(date));

        date = getYesterday(date);
    }

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

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

    //Check all were inserted
    assertEquals(365, DbApp.getRealm().where(DailyMealRealm.class).count());
    assertEquals(365 * 4, DbApp.getRealm().where(MealRealm.class).count());
    assertEquals(365 * 3, DbApp.getRealm().where(MealItemRealm.class).count());
}
项目:sqlite-android    文件:DatabaseGeneralTest.java   
@MediumTest
public void testUnionsWithBindArgs() {
    /* make sure unions with bindargs work http://b/issue?id=1061291 */
    mDatabase.execSQL("CREATE TABLE A (i int);");
    mDatabase.execSQL("create table B (k int);");
    mDatabase.execSQL("create table C (n int);");
    mDatabase.execSQL("insert into A values(1);");
    mDatabase.execSQL("insert into A values(2);");
    mDatabase.execSQL("insert into A values(3);");
    mDatabase.execSQL("insert into B values(201);");
    mDatabase.execSQL("insert into B values(202);");
    mDatabase.execSQL("insert into B values(203);");
    mDatabase.execSQL("insert into C values(901);");
    mDatabase.execSQL("insert into C values(902);");
    String s = "select i from A where i > 2 " +
            "UNION select k from B where k > 201 " +
            "UNION select n from C where n !=900;";
    Cursor c = mDatabase.rawQuery(s, null);
    int n = c.getCount();
    c.close();
    String s1 = "select i from A where i > ? " +
            "UNION select k from B where k > ? " +
            "UNION select n from C where n != ?;";
    Cursor c1 = mDatabase.rawQuery(s1, new String[]{"2", "201", "900"});
    assertEquals(n, c1.getCount());
    c1.close();
}
项目:intellij-ce-playground    文件:MainActivityTest.java   
@MediumTest
public void testJavaStrings() {
    assertEquals("SUCCESS-APP", mAppTextView2.getText().toString());
    assertEquals("SUCCESS-LIB1", mLib1TextView2.getText().toString());
    assertEquals("SUCCESS-LIB2", mLib2TextView2.getText().toString());
    assertEquals("SUCCESS-LIB2b", mLib2bTextView2.getText().toString());
    assertEquals("SUCCESS-LIBAPP", mLibappTextView2.getText().toString());
}
项目:Freifunk-App    文件:NodeRepositoryTest.java   
@Test
@MediumTest
public void load_withoutFile_returnsEmpty() throws Exception {
    NodeRepository sut = makeSut();

    sut.setNodes(NodeRepository.load(getTestContext()));

    assertEquals(0, sut.getNodes().count());
}
项目:mytracks    文件:TrackRecordingServiceTest.java   
@MediumTest
public void testRecording_oldTracks() throws Exception {
  createDummyTrack(123L, -1L, false);

  ITrackRecordingService service = bindAndGetService(createStartIntent());
  assertFalse(service.isRecording());
  assertEquals(-1L, service.getRecordingTrackId());
}
项目:mytracks    文件:TrackRecordingServiceTest.java   
@MediumTest
public void testRecording_orphanedRecordingTrack() throws Exception {
  // Just set recording track to a bogus value.
  PreferencesUtils.setLong(context, R.string.recording_track_id_key, 256L);

  // Make sure that the service will not start recording and will clear
  // the bogus track.
  ITrackRecordingService service = bindAndGetService(createStartIntent());
  assertFalse(service.isRecording());
  assertEquals(-1L, service.getRecordingTrackId());
}
项目:mytracks    文件:TrackRecordingServiceTest.java   
@MediumTest
public void testStartNewTrack_alreadyRecording() throws Exception {
  createDummyTrack(123L, -1L, true);

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

  // Starting a new track when there is a recording should just return -1L.
  long newTrack = service.startNewTrack();
  assertEquals(-1L, newTrack);

  assertEquals(123L, PreferencesUtils.getLong(context, R.string.recording_track_id_key));
  assertEquals(123L, service.getRecordingTrackId());
}
项目:intellij-ce-playground    文件:MainTest.java   
/**
 * The name 'test preconditions' is a convention to signal that if this
 * test doesn't pass, the test case was not set up properly and it might
 * explain any and all failures in other tests.  This is not guaranteed
 * to run before other tests, as junit uses reflection to find the tests.
 */
@MediumTest
public void testPreconditions() {
    assertNotNull(mNoOverlayIV);
    assertNotNull(mTypeOverlayIV);
    assertNotNull(mFlavorOverlayIV);
    assertNotNull(mTypeFlavorOverlayIV);
    assertNotNull(mVariantTypeFlavorOverlayIV);
}
项目:intellij-ce-playground    文件:MainActivityTest.java   
/**
 * The name 'test preconditions' is a convention to signal that if this
 * test doesn't pass, the test case was not set up properly and it might
 * explain any and all failures in other tests.  This is not guaranteed
 * to run before other tests, as junit uses reflection to find the tests.
 */
@MediumTest
public void testPreconditions() {
    assertNotNull(mLib1TextView1);

    // use some of Guava's class as they should be accessible through the
    // classpath from the library
    Iterable<String> segments = Splitter.on("-").split(mLib1TextView1.getText());
    assertEquals("SUCCESS", segments.iterator().next());
}
项目:mytracks    文件:TrackRecordingServiceTest.java   
@MediumTest
public void testInsertStatisticsMarker_noRecordingTrack() throws Exception {
  ITrackRecordingService service = bindAndGetService(createStartIntent());
  assertFalse(service.isRecording());

  long waypointId = service.insertWaypoint(WaypointCreationRequest.DEFAULT_STATISTICS);
  assertEquals(-1L, waypointId);
}