Commit Graph

56 Commits

Author SHA1 Message Date
Felipe Leme
2882cd2a7a Added tests for network restrictions while the screen is off.
BUG: 30785671
Change-Id: I1b211e545ff234272ff6acadfda9ce97765695a9
(cherry picked from commit b80a93061aa7d0a19b47a7dbb82f0dc06e3afb7e)
2016-08-20 03:58:09 +00:00
Felipe Leme
b7ff856a2a Improve check for activity on top after launch.
am: a871a99ebc

Change-Id: Ia2ae617d0c181eaed536ac81c6086d632fee6b24
2016-08-16 00:34:18 +00:00
Felipe Leme
a871a99ebc Improve check for activity on top after launch.
BUG: 30875754
Fixes: 30868243

Change-Id: I8b7624e35caef107743d61f312e220f8bc21b9b8
2016-08-15 15:50:38 -07:00
Felipe Leme
9c1322683f Improvements on retry mechanism on network tests:
- Retry on all cases (not only when expecting connected).
- Uses exponential back-off for timeout.

BUG: 27803922
Fixes: 30509643

Change-Id: I42454f43158598a72e30f290c27c5a02e80ea6d2
2016-08-01 17:23:29 -07:00
Felipe Leme
e928006e67 Cover more PendingIntent whitelist scenarios.
BUG: 29480440
Change-Id: I961b765f40135efc06fbb3e5a4a94e8e333453da
2016-06-28 09:07:53 -07:00
Felipe Leme
c3a9008e3d Add non-parcelable extras to notification to make sure it does not crash
the app.

BUG: 29402928
Change-Id: I4fc47535ae14e71c50b25285b2fe5375abdb4f11
2016-06-16 10:03:27 -07:00
Felipe Leme
1791555ca8 Merge "Changed network check URL." into nyc-dev 2016-06-06 17:09:36 +00:00
Felipe Leme
829443c140 Changed network check URL.
It cannot use google.com because it's blocked in some countries where
CTS tests are run.

BUG: 29082308

Change-Id: I749659ec2cd33248fddbe5b4ab02bd6e90f24a67
2016-06-06 16:05:57 +00:00
Felipe Leme
d1f3d68694 Skip Doze Mode-related tests when device does not support it.
Fixes: 29072117
Change-Id: I7ca37eae58258c021ed6297a9f1ee3b2749da7d7
2016-06-02 20:16:25 +00:00
Felipe Leme
b9b85ce0cd Add flakyness check when a valid connection is expected.
BUG: 29082308

Change-Id: Iadb9a0bd7fbd307d799af7a7a5dabc0ed000bc6d
2016-06-02 09:08:49 -07:00
Felipe Leme
4188bc32d5 Added test for whitelisting pending intent for Doze Mode.
BUG: 28818704

Change-Id: I927364e78cd73133899d67be23e0b274829686af
2016-05-27 14:21:36 -07:00
TreeHugger Robot
b853005f3c Merge "Use ConnectionManager API to check if network is metered." into nyc-dev 2016-05-25 16:54:26 +00:00
TreeHugger Robot
94636121f1 Merge "Add a test for closing sockets when a VPN comes up." into nyc-dev 2016-05-24 05:38:33 +00:00
Felipe Leme
68471ef930 Use ConnectionManager API to check if network is metered.
Also retry when getActiveNetworkInfo() returns null.

BUG: 28870582
BUG: 28909522
Change-Id: I4a43f171a7d6c73ea50555b66f858a54da65ae58
2016-05-23 11:33:34 -07:00
Lorenzo Colitti
cbcfb98dd8 Add a test for closing sockets when a VPN comes up.
Bug: 28251576
Change-Id: Iab0a8643cff3c54eb04168a7cdfa116c0b8e30b1
2016-05-16 23:10:44 +09:00
Felipe Leme
88debac60e Added tests for idle apps and doze mode.
BUG: 28473659
BUG: 28521946
Change-Id: I4bc9166bf2050136fa86e374aac59f80afd76f1c
2016-05-13 15:08:16 -07:00
Felipe Leme
ed64e61b5f Covers more corner cases on restricted network modes:
- Tests what happens on foreground applications when a restriction (like
  Data Saver or Battery Saver modes) is turned on (prior tests would
  turn the restriction on *before* switching the app to foreground).
- Tests multiple restrictions simultaneously enabled.

Also improved existing code:

- Fixed background state check.
- Reused some common checks in helper methods.
- Retries checks for process state.

BUG: 28473659

Change-Id: Ifcf9cc6d895ccde0ab5177f9f5d8c347ce53b811
2016-05-09 12:48:29 -07:00
Felipe Leme
6cd41f6d03 Asserts foreground apps always have network access.
BUG: 28473659
Change-Id: Iea6933a4630ff2e9c00a2d2e9e4a6f1a51de70f2
2016-05-06 14:28:03 -07:00
Felipe Leme
aa2e8ea1d8 Assert whitelists are revoked on uninstall.
BUG: 28616418
Change-Id: I909fd4c6024afe5b42560090c6e2f11b43c220de
2016-05-06 09:18:54 -07:00
Felipe Leme
691e85def7 Temporarily disable NetworkInfo check.
There are known issues that cause these check to fail, and the fix has
not been submitted yet.

BUG: 28473659
BUG: 28521946
Change-Id: I26dfbebc2d07396ef89ac78230645e4791c708ee
2016-05-04 18:48:24 +00:00
Felipe Leme
50bce69fab Improved connectivity check by also asserting NetworkInfo states.
BUG: 28473659
BUG: 26571724
Change-Id: Iba687003431ed5c353412268726967a798f538da
2016-05-03 08:29:52 -07:00
Felipe Leme
fa8e24c3e6 Added test for required packages whitelisted for Data Saver Mode.
Also fixed code that checks for whitelist uids, otherwise it would pass
when the required uid is missing but a superset was present (for
example, when asking for 1009 but 10090 was whitelisted).

BUG: 28431507
Change-Id: Iaaa67e586907dba215496460445ad627ba7b63c5
2016-04-29 14:10:12 -07:00
Felipe Leme
0e47422a47 Changed order of metered network check.
BUG: 27808364
Change-Id: I8a1088673cdd2c310a787a0b0708ad58876e9ac0
2016-04-14 12:49:31 -07:00
Felipe Leme
f744474a28 Improvements on test case setup.
- On hostside, checks if wi-fi is on instead of checking for connectivity (which can be very slow).
- Don't automatically reset metered network on superclass' tearDown().
- Make sure tearDown() cleans up all state changes.

BUG: 27808364
Change-Id: I4818047c5fb8f6f430b0aab5ecfa77717f860db3
2016-04-14 11:47:34 -07:00
Felipe Leme
52be3a68ad Refactored tests to use 'list wifi-networks'.
BUG: 27808364
Change-Id: Ife3f35e9c3c6a4285b671eeb7d7d0223be908a1b
2016-04-01 15:40:41 -07:00
Felipe Leme
eac0fe6ab1 Moved wi-fi switch to hostside.
BUG: 27808364
Change-Id: I89bca5f5ba90a7dc145d2ac170fd505161fd073d
2016-03-30 18:17:43 -07:00
Felipe Leme
bbb00ffc0f Fixed build broken by bad merge.
BUG: 27324964
Change-Id: Idbe6f8237b560db31eb949971358db41ac00d530
2016-03-30 16:37:24 -07:00
Felipe Leme
eb7e5053c1 Test network restrictions while on foreground service state.
BUG: 27324964
BUG: 26776313

Change-Id: Idcd0a391333d243d17b6bd68c67becaad2b37fdd
2016-03-30 22:32:27 +00:00
Felipe Leme
9a4643cd0e Improved test case for blacklist access.
BUG: 27127112
BUG: 26685616

Change-Id: I8b183cdb1cf5ebbc446176a042e4196ab063f1a3
2016-03-30 22:27:51 +00:00
Felipe Leme
3787c6bb7e Merge "Refactored method to get UIDs." into nyc-dev 2016-03-30 17:09:11 +00:00
Felipe Leme
c3d29ebf21 Refactored method to get UIDs.
BUG: 27904062
Change-Id: Ib0d3911f40e0a5deed833f71e75abd10a224768f
2016-03-30 10:07:20 -07:00
Felipe Leme
de7cbcf6ee Added sanity check to verify process state.
BUG: 26776313
BUG: 27324964

Change-Id: I209c04d5c6d89acdac9b5bdaee5a4dbd7700c53e
2016-03-29 17:57:14 -07:00
Nicholas Sauer
a552317982 [CTS] - Set test runtimes
bug: 27747405
Change-Id: If08ec156678d5435c88d9f179d3bacd064493aff
2016-03-19 00:10:02 +00:00
Felipe Leme
275d05f0d3 Re-try commands that set/get metered networks.
BUG: 27671582
Change-Id: I9160a964b44e6d48d8932dc1e1ea7702a5359885
2016-03-17 14:08:46 -07:00
Felipe Leme
f448ccd08d Print uid when running network checks.
BUG: 27570398
Change-Id: I4dcbd4e41641c406c687a0e29e2637581d91b17c
2016-03-09 15:10:55 -08:00
Felipe Leme
b3cc6ef3ae Added tests for battery save mode on non-metered networks.
BUG: 27127112
Change-Id: I4a05194a32294d15badfaa4156606e728f943a9a
2016-03-09 12:27:32 -08:00
Felipe Leme
37c0bf0477 Added CTS tests for apps that are blacklisted for restricted background data.
BUG: 27432317
Change-Id: Ie9156ab4f2fa7c639d8e9a978954e09b322d6187
2016-03-02 14:35:20 -08:00
Felipe Leme
d207fe5beb Tagged app2 as a CTS test artifact.
BUG: 27436960

Change-Id: I4e97b6341dae3361f4efdaec3132a7aa9a38dece
2016-03-01 16:31:58 -08:00
Stuart Scott
a9e563cf83 Switch to CTSv2
bug:21762834
Change-Id: Ie51a0ed4560b46c2f360e14980e5fab7fe6479fe
2016-02-29 21:51:59 -08:00
Felipe Leme
31c9ec9cb4 Added CTS tests to check background network access while on power save mode.
BUG: 27127112
Change-Id: Ifa3019d7b94459d737a9dff80b4b36a2dd43aca5
2016-02-23 14:14:55 -08:00
Felipe Leme
0a0857762a Split client-side test in 2 classes so some common code can be used to
test Power Save Mode.

BUG:  27127112
Change-Id: I6954ce8474da6da678d4bfe194334ed5a08aaeff
2016-02-19 15:21:18 -08:00
Felipe Leme
a0f49f2384 Refactored how data is shared between test apps.
When running the device-site tests, it's necessary to share state
between a second app and the main test app. Currently that's achieved
through a shared preference file that is accessed by both apps (since
they use a shared id), but this approach will not work on power save
mode tests (because the test app will be in foreground and the
background restrictions won't be applied in the second app).

This change refactors the data sharing mechanism by:

- Using an ordered broadcast that is sent from the test app to the
  secondary app.
- Checking for the network status in the secondary app.
- Moving the test logic to the client-side tests.

BUG:  27127112
Change-Id: I44987701b908b329fdf40e3a7a97e9f30cfadecb
2016-02-19 15:20:17 -08:00
Felipe Leme
a557ba6818 Updated tests cases after to assert the proper number of notifications.
Previously NMPS was broadcasting an intent every time
add|removeRestrictBackgroundWhitelistedUid() was called, but that
behavior has been changed to just broadcast an intent when there is a
change.

BUG: 26685616

Change-Id: I4eb7a4fda864a28ea23b661d1a88e18bfb80533d
2016-02-11 17:00:23 -08:00
Felipe Leme
38300a564a Refactored tests to make a real network connection.
The current approach assumes that if the active network is null it is
blocked for background access, but that's not the case.

BUG: 26685616
Change-Id: Ic6990037a2bc503c14512d7303ec71eb178f784b
2016-02-10 11:25:38 -08:00
Felipe Leme
c50a6c7d4b Improve CTS tests to really check background network restrictions.
BUG: 26685616
Change-Id: If2b1649435b0a4e5b8c383eb3196807a03359d70
2016-02-08 12:40:43 -08:00
Felipe Leme
4fc69f6c25 Split hostside network tests in multiple classes.
Initially HostsideNetworkTests.java was used to just launch VpnTest, but
it became more complex with the inclusion of ConnectivityManagerTest,
which required hostside logic.

By splitting these tests not only the VPN tests will run faster (since it
doesn't need the setup/clean from ConnectivityManager), but the
ConnectivityManager tests will be cleaner (since it can have more logic
on setup and teardown).

BUG: 26685616
Change-Id: Ie29c4a3e83956b217d90b84c9b4541690cde0344
2016-02-04 12:49:32 -08:00
Felipe Leme
34caa7fc25 Renamed and cloned HostsideNetworkTests.java
This is a no-op change that will make it easier to split the
HostsideNetworkTestCase.java logic into multiple files.

In this change, HostsideNetworkTests.java was renamed to
HostsideNetworkTestCase.java and copied as-is to
HostsideRestrictBackgroundNetworkTests.java; the next change will split
the logic in between these class so they can be properly git-diffed.

In fact, the only difference between then is the class declarations:

diff HostsideNetworkTestCase.java HostsideRestrictBackgroundNetworkTests.java
39c39
< abstract class HostsideNetworkTestCase extends DeviceTestCase implements IAbiReceiver,
---
> public class HostsideRestrictBackgroundNetworkTests extends DeviceTestCase implements IAbiReceiver,

BUG: 26685616
Change-Id: I87dadec528eaeff776d55d3382f356066496429a
2016-02-04 12:44:21 -08:00
Felipe Leme
5b35136917 Added CTS tests for RESTRICT_BACKGROUND_CHANGED.
These tests require a second app (besides the test app) that defines a
service; the host-side test then launches the service whose only purpose
is to define a broadcast receiver, which in turn will count the number
of intents received in a shared preferences file. Then the test app will
read the shared preferences and assert the proper number of intents have
been received.

BUG: 26451391
Change-Id: I4c5d5e57c09a0bd57a7f6581820cc9115318dd47
2016-02-04 10:22:42 -08:00
Felipe Leme
d12935eed8 Removed reference to hidden annotation.
BUG: 26082535
BUG: 26451391
Change-Id: I267010a49df3212ca96f54b65aa7c8a14982a70c
2016-01-27 12:34:06 -08:00
Felipe Leme
310885be93 Added tests for restricted background APIs.
Although the main purpose of these change is to test the new public
API (ConnectivityManager.getRestrictBackgroundStatus()), it also
indirectly tests the new private API on
INetworkPolicyManager (addRestrictBackgroundWhitelistedUid(),
removeRestrictBackgroundWhitelistedUid(), and
getRestrictBackgroundWhitelistedUids()), since they're used on each test
to setup the device state.

This change also modified how the device-side tests are run: the
runDeviceTests() had a className parameter that was not used, and this
CL not only uses it but also introduces a methodName as well. The
reasoning for this change is that the host-side tests must interact with
the device-side tests many times during each test; in fact, the "real"
test is done at the host side, while the device-side test is just used
to assert the expected result of getRestrictBackgroundStatus()).

BUG: 26451391

Change-Id: I7114e350f3b247d2f05b0c280a09cad383c61f9a
2016-01-27 09:32:44 -08:00