Search in sources :

Example 6 with Suppress

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

the class TimeTest method disableTestGetJulianDay.

@Suppress
public void disableTestGetJulianDay() throws Exception {
    Time time = new Time();
    // same Julian day.
    for (int monthDay = 1; monthDay <= 366; monthDay++) {
        for (int zoneIndex = 0; zoneIndex < mTimeZones.length; zoneIndex++) {
            // We leave the "month" as zero because we are changing the
            // "monthDay" from 1 to 366.  The call to normalize() will
            // then change the "month" (but we don't really care).
            time.set(0, 0, 0, monthDay, 0, 2008);
            time.timezone = mTimeZones[zoneIndex];
            long millis = time.normalize(true);
            if (zoneIndex == 0) {
                Log.i("TimeTest", time.format("%B %d, %Y"));
            }
            // This is the Julian day for 12am for this day of the year
            int julianDay = Time.getJulianDay(millis, time.gmtoff);
            // Julian day.
            for (int hour = 0; hour < 24; hour++) {
                for (int minute = 0; minute < 60; minute += 15) {
                    time.set(0, minute, hour, monthDay, 0, 2008);
                    millis = time.normalize(true);
                    int day = Time.getJulianDay(millis, time.gmtoff);
                    if (day != julianDay) {
                        Log.e("TimeTest", "Julian day: " + day + " at time " + time.hour + ":" + time.minute + " != today's Julian day: " + julianDay + " timezone: " + time.timezone);
                    }
                    assertEquals(day, julianDay);
                }
            }
        }
    }
}
Also used : Time(android.text.format.Time) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 7 with Suppress

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

the class ListWithScreenOfNoSelectablesTest method testGoFromNoSelectionToSelectionExists.

@MediumTest
// Failing.
@Suppress
public void testGoFromNoSelectionToSelectionExists() {
    // go down untile first (and only selectable) item is off screen
    View first = mListView.getChildAt(0);
    while (first.getParent() != null) {
        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
    }
    // nothing should be selected
    assertEquals("selected position", ListView.INVALID_POSITION, mListView.getSelectedItemPosition());
    assertNull("selected view", mListView.getSelectedView());
    // go up once to bring the selectable back on screen
    sendKeys(KeyEvent.KEYCODE_DPAD_UP);
    assertEquals("first visible position", 0, mListView.getFirstVisiblePosition());
    assertEquals("selected position", ListView.INVALID_POSITION, mListView.getSelectedItemPosition());
    // up once more should give it selection
    sendKeys(KeyEvent.KEYCODE_DPAD_UP);
    assertEquals("selected position", 0, mListView.getSelectedItemPosition());
}
Also used : View(android.view.View) ListView(android.widget.ListView) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 8 with Suppress

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

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)

Example 9 with Suppress

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

the class NetworkPolicyManagerServiceTest method testUidRemovedPolicyCleared.

@Suppress
public void testUidRemovedPolicyCleared() throws Exception {
    Future<Void> future;
    // POLICY_REJECT should RULE_REJECT in background
    expectSetUidMeteredNetworkBlacklist(UID_A, true);
    expectSetUidForeground(UID_A, false);
    future = expectRulesChanged(UID_A, RULE_REJECT_METERED);
    replay();
    mService.setUidPolicy(APP_ID_A, POLICY_REJECT_METERED_BACKGROUND);
    future.get();
    verifyAndReset();
    // uninstall should clear RULE_REJECT
    expectSetUidMeteredNetworkBlacklist(UID_A, false);
    expectSetUidForeground(UID_A, false);
    future = expectRulesChanged(UID_A, RULE_ALLOW_ALL);
    replay();
    final Intent intent = new Intent(ACTION_UID_REMOVED);
    intent.putExtra(EXTRA_UID, UID_A);
    mServiceContext.sendBroadcast(intent);
    future.get();
    verifyAndReset();
}
Also used : Intent(android.content.Intent) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 10 with Suppress

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

the class NetworkPolicyManagerServiceTest method testNetworkPolicyAppliedCycleLastMonth.

@Suppress
public void testNetworkPolicyAppliedCycleLastMonth() throws Exception {
    NetworkState[] state = null;
    NetworkStats stats = null;
    Future<Void> future;
    final long TIME_FEB_15 = 1171497600000L;
    final long TIME_MAR_10 = 1173484800000L;
    final int CYCLE_DAY = 15;
    setCurrentTimeMillis(TIME_MAR_10);
    // first, pretend that wifi network comes online. no policy active,
    // which means we shouldn't push limit to interface.
    state = new NetworkState[] { buildWifi() };
    expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce();
    expectCurrentTime();
    expectClearNotifications();
    expectAdvisePersistThreshold();
    future = expectMeteredIfacesChanged();
    replay();
    mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION));
    future.get();
    verifyAndReset();
    // now change cycle to be on 15th, and test in early march, to verify we
    // pick cycle day in previous month.
    expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce();
    expectCurrentTime();
    // pretend that 512 bytes total have happened
    stats = new NetworkStats(getElapsedRealtime(), 1).addIfaceValues(TEST_IFACE, 256L, 2L, 256L, 2L);
    expect(mStatsService.getNetworkTotalBytes(sTemplateWifi, TIME_FEB_15, TIME_MAR_10)).andReturn(stats.getTotalBytes()).atLeastOnce();
    expectPolicyDataEnable(TYPE_WIFI, true);
    // TODO: consider making strongly ordered mock
    expectRemoveInterfaceQuota(TEST_IFACE);
    expectSetInterfaceQuota(TEST_IFACE, (2 * MB_IN_BYTES) - 512);
    expectClearNotifications();
    expectAdvisePersistThreshold();
    future = expectMeteredIfacesChanged(TEST_IFACE);
    replay();
    setNetworkPolicies(new NetworkPolicy(sTemplateWifi, CYCLE_DAY, TIMEZONE_UTC, 1 * MB_IN_BYTES, 2 * MB_IN_BYTES, false));
    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