use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by crdroidandroid.
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());
}
use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by crdroidandroid.
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();
}
}
use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by crdroidandroid.
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();
}
use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by crdroidandroid.
the class NetworkPolicyManagerServiceTest method testMeteredNetworkWithoutLimit.
@Suppress
public void testMeteredNetworkWithoutLimit() 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);
// bring up wifi network with metered policy
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, Long.MAX_VALUE);
expectClearNotifications();
expectAdvisePersistThreshold();
future = expectMeteredIfacesChanged(TEST_IFACE);
replay();
setNetworkPolicies(new NetworkPolicy(sTemplateWifi, CYCLE_DAY, TIMEZONE_UTC, WARNING_DISABLED, LIMIT_DISABLED, true));
future.get();
verifyAndReset();
}
}
use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by crdroidandroid.
the class LinkPropertiesTest method testIsReachable.
@SmallTest
// Failing.
@Suppress
public void testIsReachable() {
final LinkProperties v4lp = new LinkProperties();
assertFalse(v4lp.isReachable(DNS1));
assertFalse(v4lp.isReachable(DNS2));
// Add an on-link route, making the on-link DNS server reachable,
// but there is still no IPv4 address.
assertTrue(v4lp.addRoute(new RouteInfo(new IpPrefix(NetworkUtils.numericToInetAddress("75.208.0.0"), 16))));
assertFalse(v4lp.isReachable(DNS1));
assertFalse(v4lp.isReachable(DNS2));
// Adding an IPv4 address (right now, any IPv4 address) means we use
// the routes to compute likely reachability.
assertTrue(v4lp.addLinkAddress(new LinkAddress(ADDRV4, 16)));
assertTrue(v4lp.isReachable(DNS1));
assertFalse(v4lp.isReachable(DNS2));
// Adding a default route makes the off-link DNS server reachable.
assertTrue(v4lp.addRoute(new RouteInfo(GATEWAY1)));
assertTrue(v4lp.isReachable(DNS1));
assertTrue(v4lp.isReachable(DNS2));
final LinkProperties v6lp = new LinkProperties();
final InetAddress kLinkLocalDns = NetworkUtils.numericToInetAddress("fe80::6:1");
final InetAddress kLinkLocalDnsWithScope = NetworkUtils.numericToInetAddress("fe80::6:2%43");
final InetAddress kOnLinkDns = NetworkUtils.numericToInetAddress("2001:db8:85a3::53");
assertFalse(v6lp.isReachable(kLinkLocalDns));
assertFalse(v6lp.isReachable(kLinkLocalDnsWithScope));
assertFalse(v6lp.isReachable(kOnLinkDns));
assertFalse(v6lp.isReachable(DNS6));
// Add a link-local route, making the link-local DNS servers reachable. Because
// we assume the presence of an IPv6 link-local address, link-local DNS servers
// are considered reachable, but only those with a non-zero scope identifier.
assertTrue(v6lp.addRoute(new RouteInfo(new IpPrefix(NetworkUtils.numericToInetAddress("fe80::"), 64))));
assertFalse(v6lp.isReachable(kLinkLocalDns));
assertTrue(v6lp.isReachable(kLinkLocalDnsWithScope));
assertFalse(v6lp.isReachable(kOnLinkDns));
assertFalse(v6lp.isReachable(DNS6));
// Add a link-local address--nothing changes.
assertTrue(v6lp.addLinkAddress(LINKADDRV6LINKLOCAL));
assertFalse(v6lp.isReachable(kLinkLocalDns));
assertTrue(v6lp.isReachable(kLinkLocalDnsWithScope));
assertFalse(v6lp.isReachable(kOnLinkDns));
assertFalse(v6lp.isReachable(DNS6));
// Add a global route on link, but no global address yet. DNS servers reachable
// via a route that doesn't require a gateway: give them the benefit of the
// doubt and hope the link-local source address suffices for communication.
assertTrue(v6lp.addRoute(new RouteInfo(new IpPrefix(NetworkUtils.numericToInetAddress("2001:db8:85a3::"), 64))));
assertFalse(v6lp.isReachable(kLinkLocalDns));
assertTrue(v6lp.isReachable(kLinkLocalDnsWithScope));
assertTrue(v6lp.isReachable(kOnLinkDns));
assertFalse(v6lp.isReachable(DNS6));
// Add a global address; the on-link global address DNS server is (still)
// presumed reachable.
assertTrue(v6lp.addLinkAddress(new LinkAddress(ADDRV6, 64)));
assertFalse(v6lp.isReachable(kLinkLocalDns));
assertTrue(v6lp.isReachable(kLinkLocalDnsWithScope));
assertTrue(v6lp.isReachable(kOnLinkDns));
assertFalse(v6lp.isReachable(DNS6));
// Adding a default route makes the off-link DNS server reachable.
assertTrue(v6lp.addRoute(new RouteInfo(GATEWAY62)));
assertFalse(v6lp.isReachable(kLinkLocalDns));
assertTrue(v6lp.isReachable(kLinkLocalDnsWithScope));
assertTrue(v6lp.isReachable(kOnLinkDns));
assertTrue(v6lp.isReachable(DNS6));
// Check isReachable on stacked links. This requires that the source IP address be assigned
// on the interface returned by the route lookup.
LinkProperties stacked = new LinkProperties();
// Can't add a stacked link without an interface name.
stacked.setInterfaceName("v4-test0");
v6lp.addStackedLink(stacked);
InetAddress stackedAddress = Address("192.0.0.4");
LinkAddress stackedLinkAddress = new LinkAddress(stackedAddress, 32);
assertFalse(v6lp.isReachable(stackedAddress));
stacked.addLinkAddress(stackedLinkAddress);
assertFalse(v6lp.isReachable(stackedAddress));
stacked.addRoute(new RouteInfo(stackedLinkAddress));
assertTrue(stacked.isReachable(stackedAddress));
assertTrue(v6lp.isReachable(stackedAddress));
assertFalse(v6lp.isReachable(DNS1));
stacked.addRoute(new RouteInfo((IpPrefix) null, stackedAddress));
assertTrue(v6lp.isReachable(DNS1));
}
Aggregations