Improve NetworkPolicyManagerTest
Basically, this commit is to fix the comments left on
aosp/1737395.
- Remove MeterednessConfigurationRule since this test won't
change meteredness.
- Launch activity without checking network access because such
behavior has covered by DataSaverModeTest. This test can only
focus on the network rule changed when the app is in the
foreground or background.
Also improve test by
- Having a new function to just launch the activity without
checking network status.
- Having a callback design when launching an activity to ensure
that the ACTION_FINISH_ACTIVITY is registered before leaving
launchActivity() method. Without this design, there might be a
race when activity is launched but ACTION_FINISH_ACTIVITY
has not registered before test calls finishActivity().
When the issue is happened, there is no way to fix it, so have
a callback design to prevent this problem.
Ignore-AOSP-First: There is a merge conflict in AOSP.
Bug: 176289731
Test: atest CtsHostsideNetworkTests:HostsideNetworkPolicyManagerTests \
#testIsUidNetworkingBlocked_withDataSaverMode \
CtsHostsideNetworkTests:HostsideNetworkPolicyManagerTests \
#testIsUidRestrictedOnMeteredNetworks --rerun-until-failure 100
Change-Id: I045e4a7dd0cec15f20e529024cd1fc06bcccd68f
4 files changed