Network Testing with ADB Notes By ShariqSP

Network Testing with ADB

Network testing ensures that the application performs consistently across different types of network connections, speeds, and conditions. Using ADB commands and tools like Charles Proxy, developers can simulate various network scenarios for robust app behavior validation.

Example: Network Testing with Candy Crush APK

Download the Candy Crush APK from shariqsp.com/apk/candycrush.apk. Once installed, use the following commands and configurations to test its behavior under diverse network scenarios.

1. Simulating Different Network Types

Test the app under various network connection types:

  1. Enable Mobile Data:
    adb shell svc data enable
  2. Disable Mobile Data:
    adb shell svc data disable
  3. Enable Wi-Fi:
    adb shell svc wifi enable
  4. Disable Wi-Fi:
    adb shell svc wifi disable
  5. Test LAN Connectivity: Ensure the device is connected via USB and simulate a network proxy using tools like Charles Proxy or Fiddler.

2. Simulating Network Providers

Simulate specific network providers (e.g., Airtel, Jio, VI) using a network simulator or device settings. Note that ADB commands themselves cannot change providers but can help validate app behavior when switching networks:

  • Switch from one SIM card to another (manual or via dual-SIM device settings).
  • Simulate network change by toggling airplane mode:
    adb shell settings put global airplane_mode_on 1
                  adb shell am broadcast -a android.intent.action.AIRPLANE_MODE
    Disable it with:
    adb shell settings put global airplane_mode_on 0
                  adb shell am broadcast -a android.intent.action.AIRPLANE_MODE

3. Testing Different Network Speeds

Use Charles Proxy to throttle network speed and test the app’s performance under various conditions:

to try with charles-proxy visit below link CharlesProxy.

  • Simulate 2G: Configure Charles Proxy to throttle network speed to 128 kbps.
  • Simulate 3G: Set speed to 2 Mbps.
  • Simulate 4G: Set speed to 10-20 Mbps.
  • Simulate 5G: Configure speed to 100+ Mbps.
  • Verify app responsiveness during gameplay, syncing, and loading screens.

4. Examples for Network Testing with Candy Crush APK

Below are specific scenarios to test the Candy Crush APK:

  • Test App Behavior on Mobile Data: Enable mobile data and launch the app:
    adb shell svc data enable
                  adb shell am start -n com.king.candycrushsaga/.MainActivity
  • Test App Behavior on Wi-Fi: Connect to a Wi-Fi network and verify the app’s behavior:
    adb shell svc wifi enable
  • Simulate Network Loss: Disconnect all networks and observe the app's error handling:
    adb shell svc wifi disable
                  adb shell svc data disable
  • Test App Behavior with Slow Network Speeds: Use Charles Proxy to throttle the speed and observe gameplay behavior during syncing or level loading.
  • Switch Networks During Gameplay: Toggle between Wi-Fi and mobile data while playing:
    adb shell svc wifi enable
                  adb shell svc data enable
                  adb shell svc wifi disable

5. Additional Network Testing Scenarios

Expand network testing with these scenarios:

  • Test app reconnection behavior after toggling airplane mode.
  • Validate app response to network handoff (e.g., from Wi-Fi to mobile data).
  • Simulate a high-packet loss scenario using Charles Proxy.
  • Test app notifications or in-game purchases under intermittent network conditions.
  • Monitor app's data usage using:
    adb shell dumpsys netstats