Search in sources :

Example 21 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by DirtyUnicorns.

the class DatabaseCursorTest method testCursorWindowFailureWhenTooManyCursorWindowsLeftOpen.

/**
     * sometimes CursorWindow creation fails due to non-availability of memory create
     * another CursorWindow object. One of the scenarios of its occurrence is when
     * there are too many CursorWindow objects already opened by the process.
     * This test is for that scenario.
     */
@LargeTest
// Failing.
@Suppress
public void testCursorWindowFailureWhenTooManyCursorWindowsLeftOpen() {
    mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data TEXT);");
    mDatabase.execSQL("INSERT INTO test values(1, 'test');");
    int N = 1024;
    ArrayList<Cursor> cursorList = new ArrayList<Cursor>();
    // open many cursors until a failure occurs
    for (int i = 0; i < N; i++) {
        try {
            Cursor cursor = mDatabase.rawQuery("select * from test", null);
            cursor.getCount();
            cursorList.add(cursor);
        } catch (CursorWindowAllocationException e) {
            // got the exception we wanted
            break;
        } catch (Exception e) {
            fail("unexpected exception: " + e.getMessage());
            e.printStackTrace();
            break;
        }
    }
    for (Cursor c : cursorList) {
        c.close();
    }
}
Also used : ArrayList(java.util.ArrayList) SQLiteCursor(android.database.sqlite.SQLiteCursor) Cursor(android.database.Cursor) CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException) Suppress(android.test.suitebuilder.annotation.Suppress) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 22 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by DirtyUnicorns.

the class SSLTest method testCertificate.

//This test relies on network resources.
@Suppress
public void testCertificate() throws Exception {
    // test www.fortify.net/sslcheck.html
    Socket ssl = SSLCertificateSocketFactory.getDefault().createSocket("www.fortify.net", 443);
    assertNotNull(ssl);
    OutputStream out = ssl.getOutputStream();
    assertNotNull(out);
    InputStream in = ssl.getInputStream();
    assertNotNull(in);
    String get = "GET /sslcheck.html HTTP/1.1\r\nHost: 68.178.217.222\r\n\r\n";
    // System.out.println("going for write...");
    out.write(get.getBytes());
    byte[] b = new byte[1024];
    // System.out.println("going for read...");
    int ret = in.read(b);
// System.out.println(new String(b));
}
Also used : InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) Socket(java.net.Socket) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 23 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by DirtyUnicorns.

the class MediaPlayerInvokeTest method testPing.

// Generate a random number, sends it to the ping test player.
@Suppress
@MediumTest
public void testPing() throws Exception {
    mPlayer.setDataSource("test:invoke_mock_media_player.so?url=ping");
    Parcel request = mPlayer.newRequest();
    Parcel reply = Parcel.obtain();
    int val = rnd.nextInt();
    request.writeInt(val);
    mPlayer.invoke(request, reply);
    assertEquals(val, reply.readInt());
}
Also used : Parcel(android.os.Parcel) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 24 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by DirtyUnicorns.

the class SettingsProviderTest method testRowNumberContentUri.

@MediumTest
// Settings.Bookmarks uses a query format that's not supported now.
@Suppress
public void testRowNumberContentUri() {
    ContentResolver r = getContext().getContentResolver();
    // The bookmarks table (and everything else) uses standard row number content URIs.
    Uri uri = Settings.Bookmarks.add(r, new Intent("TEST"), "Test Title", "Test Folder", '*', 123);
    assertTrue(ContentUris.parseId(uri) > 0);
    assertEquals("TEST", Settings.Bookmarks.getIntentForShortcut(r, '*').getAction());
    ContentValues v = new ContentValues();
    v.put(Settings.Bookmarks.INTENT, "#Intent;action=TOAST;end");
    assertEquals(1, r.update(uri, v, null, null));
    assertEquals("TOAST", Settings.Bookmarks.getIntentForShortcut(r, '*').getAction());
    assertEquals(1, r.delete(uri, null, null));
    assertEquals(null, Settings.Bookmarks.getIntentForShortcut(r, '*'));
}
Also used : ContentValues(android.content.ContentValues) Intent(android.content.Intent) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 25 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by DirtyUnicorns.

the class NetworkPolicyManagerServiceTest method testOverWarningLimitNotification.

@Suppress
public void testOverWarningLimitNotification() throws Exception {
    NetworkState[] state = null;
    NetworkStats stats = null;
    Future<Void> future;
    Future<String> tagFuture;
    final long TIME_FEB_15 = 1171497600000L;
    final long TIME_MAR_10 = 1173484800000L;
    final int CYCLE_DAY = 15;
    setCurrentTimeMillis(TIME_MAR_10);
    // assign wifi policy
    state = new NetworkState[] {};
    stats = new NetworkStats(getElapsedRealtime(), 1).addIfaceValues(TEST_IFACE, 0L, 0L, 0L, 0L);
    {
        expectCurrentTime();
        expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce();
        expect(mStatsService.getNetworkTotalBytes(sTemplateWifi, TIME_FEB_15, currentTimeMillis())).andReturn(stats.getTotalBytes()).atLeastOnce();
        expectPolicyDataEnable(TYPE_WIFI, true);
        expectClearNotifications();
        expectAdvisePersistThreshold();
        future = expectMeteredIfacesChanged();
        replay();
        setNetworkPolicies(new NetworkPolicy(sTemplateWifi, CYCLE_DAY, TIMEZONE_UTC, 1 * MB_IN_BYTES, 2 * MB_IN_BYTES, false));
        future.get();
        verifyAndReset();
    }
    // bring up wifi network
    incrementCurrentTime(MINUTE_IN_MILLIS);
    state = new NetworkState[] { buildWifi() };
    stats = new NetworkStats(getElapsedRealtime(), 1).addIfaceValues(TEST_IFACE, 0L, 0L, 0L, 0L);
    {
        expectCurrentTime();
        expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce();
        expect(mStatsService.getNetworkTotalBytes(sTemplateWifi, TIME_FEB_15, currentTimeMillis())).andReturn(stats.getTotalBytes()).atLeastOnce();
        expectPolicyDataEnable(TYPE_WIFI, true);
        expectRemoveInterfaceQuota(TEST_IFACE);
        expectSetInterfaceQuota(TEST_IFACE, 2 * MB_IN_BYTES);
        expectClearNotifications();
        expectAdvisePersistThreshold();
        future = expectMeteredIfacesChanged(TEST_IFACE);
        replay();
        mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION));
        future.get();
        verifyAndReset();
    }
    // go over warning, which should kick notification
    incrementCurrentTime(MINUTE_IN_MILLIS);
    stats = new NetworkStats(getElapsedRealtime(), 1).addIfaceValues(TEST_IFACE, 1536 * KB_IN_BYTES, 15L, 0L, 0L);
    {
        expectCurrentTime();
        expect(mStatsService.getNetworkTotalBytes(sTemplateWifi, TIME_FEB_15, currentTimeMillis())).andReturn(stats.getTotalBytes()).atLeastOnce();
        expectPolicyDataEnable(TYPE_WIFI, true);
        expectForceUpdate();
        expectClearNotifications();
        tagFuture = expectEnqueueNotification();
        replay();
        mNetworkObserver.limitReached(null, TEST_IFACE);
        assertNotificationType(TYPE_WARNING, tagFuture.get());
        verifyAndReset();
    }
    // go over limit, which should kick notification and dialog
    incrementCurrentTime(MINUTE_IN_MILLIS);
    stats = new NetworkStats(getElapsedRealtime(), 1).addIfaceValues(TEST_IFACE, 5 * MB_IN_BYTES, 512L, 0L, 0L);
    {
        expectCurrentTime();
        expect(mStatsService.getNetworkTotalBytes(sTemplateWifi, TIME_FEB_15, currentTimeMillis())).andReturn(stats.getTotalBytes()).atLeastOnce();
        expectPolicyDataEnable(TYPE_WIFI, false);
        expectForceUpdate();
        expectClearNotifications();
        tagFuture = expectEnqueueNotification();
        replay();
        mNetworkObserver.limitReached(null, TEST_IFACE);
        assertNotificationType(TYPE_LIMIT, tagFuture.get());
        verifyAndReset();
    }
    // now snooze policy, which should remove quota
    incrementCurrentTime(MINUTE_IN_MILLIS);
    {
        expectCurrentTime();
        expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce();
        expect(mStatsService.getNetworkTotalBytes(sTemplateWifi, TIME_FEB_15, currentTimeMillis())).andReturn(stats.getTotalBytes()).atLeastOnce();
        expectPolicyDataEnable(TYPE_WIFI, true);
        // snoozed interface still has high quota so background data is
        // still restricted.
        expectRemoveInterfaceQuota(TEST_IFACE);
        expectSetInterfaceQuota(TEST_IFACE, Long.MAX_VALUE);
        expectAdvisePersistThreshold();
        expectMeteredIfacesChanged(TEST_IFACE);
        future = expectClearNotifications();
        tagFuture = expectEnqueueNotification();
        replay();
        mService.snoozeLimit(sTemplateWifi);
        assertNotificationType(TYPE_LIMIT_SNOOZED, tagFuture.get());
        future.get();
        verifyAndReset();
    }
}
Also used : NetworkPolicy(android.net.NetworkPolicy) NetworkStats(android.net.NetworkStats) Intent(android.content.Intent) NetworkState(android.net.NetworkState) Suppress(android.test.suitebuilder.annotation.Suppress)

Aggregations

Suppress (android.test.suitebuilder.annotation.Suppress)199 MediumTest (android.test.suitebuilder.annotation.MediumTest)73 ServiceStatus (com.vodafone360.people.service.ServiceStatus)39 Cursor (android.database.Cursor)29 Contact (com.vodafone360.people.datatypes.Contact)28 ArrayList (java.util.ArrayList)26 SmallTest (android.test.suitebuilder.annotation.SmallTest)17 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)16 Intent (android.content.Intent)15 LargeTest (android.test.suitebuilder.annotation.LargeTest)15 ContentValues (android.content.ContentValues)13 NetworkStats (android.net.NetworkStats)13 Uri (android.net.Uri)13 Time (android.text.format.Time)12 Random (java.util.Random)12 DatabaseHelper (com.vodafone360.people.database.DatabaseHelper)11 IEngineEventCallback (com.vodafone360.people.engine.IEngineEventCallback)11 IContactSyncCallback (com.vodafone360.people.engine.contactsync.IContactSyncCallback)11 ProcessorFactory (com.vodafone360.people.engine.contactsync.ProcessorFactory)11 DownloadManager (android.app.DownloadManager)10