Just make a few suggestions as there seem to be different questions here. 1) If all you want to do is turn off the data before running the OFFLINE test case, you can just try using robotics to do this.
Example: For Wi-Fi:
WifiManager wifi=(WifiManager)solo.getCurrentActivity().getSystemService(Context.WIFI_SERVICE); wifi.setWifiEnabled(false);
For mobile data (using reflections):
ConnectivityManager dataManager=(ConnectivityManager)solo.getCurrentActivity().getSystemService(Context.CONNECTIVITY_SERVICE); Method dataClass = ConnectivityManager.class.getDeclaredMethod("setMobileDataEnabled", boolean.class); dataClass.setAccessible(true); dataClass.invoke(dataManager, true);
You can make the two above calls in the setup() method before running a separate test case in the OFFLINE package. After all the test cases in the OFFLINE package are completed, you can turn on WiFi / DATA back in the teardown() method at the very end.
2) Looking at the application that you placed in the OP, it seems that it:
Uses ipTables based on OS version
Creates a UID-based script header for all applications that need WiFi / Data p>
You need to get a list of installed applications on the device along with any hidden applications, etc. from the package manager.
And again, it runs the scripts based on the user selection for the blacklist and redefines the existing rules in ipTable with the desired user rules.
Pretty sure, although it must have been quite difficult to put all this together ... Sounds are much simpler as marker points.
Hope this helps you.
PS: If you find out something, write an updated answer, I would like to know how you worked it.
Update: Make sure you have the necessary permissions to set WiFi / data in your application . NOT a test apk manifest. THIS SHOULD BE A MANIFESTATION OF THE APPLICATION OF MYSELF. This library can help you. Its extension for solo. http://adventuresinqa.com/2014/02/17/extsolo-library-to-extend-your-robotium-test-automation/
source share