Offline mode testing for mobile apps: five network moments to check
Offline testing for mobile apps on simulators and emulators: emulator network profiles, the five moments to test from cold launch to reconnect, and what to assert.
- Written by
- Yuvan Sundrani
- Read time
- 8 min read
- Published
.png)
Key Takeaways
- A connection that's up but slow fails differently from no connection: OkHttp's connect, read and write timeouts default to 10 seconds each, and its call timeout defaults to none.
- The emulator's -netdelay and -netspeed presets apply to Ethernet and cellular; from Android Emulator 36.5, Wi-Fi traffic goes through netsim by default.
- waitsForConnectivity only covers connection setup. A connection that drops mid-load returns NSURLErrorNetworkConnectionLost, a different path from never connecting.
- WorkManager stops a worker when its network constraint fails and retries it later, with a default exponential backoff of 30 seconds, so "back online" sync is not instant.
- The reconnect moment is where duplicates appear: a queued write that runs twice creates two orders.
Offline testing checks five moments, each on its own network condition: cold launch with no network, a drop mid-action, a connection that's up but stalls, reconnection, and a connection that flaps. Each one has a different failure and a different assertion.
Network condition setup on Android Emulator, iOS Simulator
Android Emulator. Google's emulator command-line reference defines two presets per network type, both applying to Ethernet and cellular:
emulator @Pixel_8_API_36 -netdelay edge -netspeed edge # EDGE latency and bandwidth
emulator @Pixel_8_API_36 -netfast # same as -netspeed full -netdelay none
While the emulator runs, the console changes them without a restart: network delay gprs, network speed 14.4 80, and gsm data unregistered to take cellular data off the network. Extended controls > Cellular sets network type, signal strength and data status from the UI.
The console page lists different preset numbers from the command-line page for the same names, so measure the profile you get.
From Android Emulator 36.5, Wi-Fi traffic is handled by netsim by default, so an AVD on Wi-Fi may not see -netdelay at all. Check which interface carries the app's traffic before trusting a slow profile.
Android's Data Saver docs add two shell commands for metered behavior: adb shell cmd netpolicy set restrict-background true turns on Data Saver, and cmd netpolicy set metered-network <SSID> true marks a Wi-Fi network as metered.
iOS. Apple's release-build testing guide points to the Network Link Conditioner under Settings > Developer on a device. For the Simulator, the Mac-side Network Link Conditioner ships in Additional Tools for Xcode; Apple doesn't document its effect on the Simulator, so confirm a profile took effect by timing a known request.

App cold launch offline test
Start the app with the network already off. This tests what the app persisted, separately from what it fetches.
- Assert: the last-synced content renders from local storage, an offline indicator appears, and no request loop starts.
- Typical failure: a launch screen that waits on a config or feature-flag request with no timeout and no cached fallback.
On iOS, NWPathMonitor reports the path before the first request. On Android, registerDefaultNetworkCallback() delivers onAvailable() when a default network exists; with none, the app should render cached state without waiting for one.
Network drop during a request on iOS, Android
Drop the network while a form submits or an upload runs.
Apple's waitsForConnectivity reference separates the two cases. With the property off and no connectivity, the request fails immediately with NSURLErrorNotConnectedToInternet. The property applies only while establishing a connection; a connection that drops mid-load gets NSURLErrorNetworkConnectionLost. Background sessions ignore the property and always wait.
- Assert: the user's input survives (form fields, draft text, the selected photo), the action is queued or clearly failed, and the UI says which.
- Typical failure: a handler written for NotConnectedToInternet only, so NetworkConnectionLost falls through to a generic error and clears the form.
Slow network timeouts in mobile apps
The hardest condition to handle is a link that reports connected and delivers almost nothing. The radio icon is full, NWPathMonitor says satisfied, and requests time out one by one.
OkHttp's documented defaults explain the symptom on Android: 10 seconds each for connect, read and write timeouts, and a call timeout of 0, meaning none. A response that trickles in under the read timeout per chunk can hold a spinner for minutes.
- Assert: every user-initiated request has an overall deadline (callTimeout on OkHttp, timeoutIntervalForResource on URLSession), and the UI offers retry or cancel before it.
- Profile: -netdelay gprs -netspeed gprs on the emulator, or a high-latency, high-loss profile in the Network Link Conditioner.

Offline queue sync after reconnect
Reconnection is where offline queues prove themselves.
WorkManager's documentation states that a worker whose constraint becomes unmet is stopped and retried when the constraints are met again, with a default EXPONENTIAL backoff of 30 seconds and a minimum of 10.
A test that asserts "synced" one second after reconnecting is racing the backoff; wait for the work state, or drive constraints in a test with WorkManager's test helpers.
- Assert: each queued write reaches the server exactly once, stale screens refresh, and the offline indicator clears.
- Typical failure: the in-memory retry and the persisted queue both resend, and the server creates two orders. An idempotency key on each write closes it.
In one of our tests, the duplicate check is one instruction: check that the network log shows a single POST /api/orders with status 200. Our network traffic docs describe the Read Network Logs action and the per-run Network section that make it checkable.
Flaky connection retry storms
Toggle the network several times within a minute. Each reconnect can trigger a refresh, a token renewal and a queue flush, and without coalescing they stack.
- Assert: request counts per endpoint stay flat across toggles, and no screen re-renders into a broken intermediate state.
- Evidence: repeated identical requests in the capture. The proxy capture walkthrough shows how to count repeats per endpoint.
API suites that pass against a stable network miss all five moments; API testing for mobile covers what they don't see.
Autosana for offline mode testing
Autosana is an AI end-to-end testing agent for iOS, Android and web apps. For network conditions, our Autosana sandboxes change the device's network between two steps of a run and keep a screenshot of each, so the five moments above become repeatable runs.
Autosana key features for network conditions
- Network changes between steps. autosana sandbox set network <state> switches the device's network mid-run; the CLI's --help lists the accepted states. A run can go online, offline and back in one session, with a screenshot after every change.
- Dropped requests listed by step. On the iOS Simulator, autosana sandbox network --failed lists the requests that never completed. On every iOS and web run, the Network section shows each request, and failed ones carry status 0 with an error.
- Timing that waits for state. autosana sandbox wait 2s pauses and then captures, and each action waits for the screen to settle first, which matters when a sync runs on a 30-second backoff.
| Moment | Sandbox step | Evidence kept |
|---|---|---|
| Cold launch offline | set network with no connection, then launch --cold | Screenshot of the cached screen |
| Drop mid-action | Start the submit, then set network offline | Screenshot of the form after the drop |
| Stalling | set network to a slow state, then the action | video --last 30s of the spinner |
| Back online | set network back, wait 2s, look | Screenshot after sync, plus network --failed on the iOS Simulator |
A run after a network change: summary, flagged issue, each step with its timing, and the device screen. Source: Autosana docs video.
Autosana customer results
- Ziina (UAE financial platform) automated 69% of its E2E suite and cut active manual regression from about 12 hours across two days to about 1 hour. See the Ziina case study.
The difference between a fixed pause and waiting for a state is covered in end-to-end suites that fail at waiting.
A suite that toggles the network and then sleeps tends to end up in flaky tests in GitHub Actions.
Where Autosana fits less well
- network --failed covers the iOS Simulator; Android request failures show up in logs.
- Our Tailscale routing covers web tests only.
- A Wi-Fi to cellular handover mid-request, captive portals and carrier NAT timeouts need a real phone on a real network.
Why use Autosana for offline mode testing?
- Network changes mid-run. The device goes offline between two named steps of the same session.
- Duplicate writes are checkable. A test can count POST requests to one endpoint after reconnecting.
- The stalling case gets a recording. A 30-second video shows the spinner the user would see.
- Cached screens get proof. A cold launch with no network ends in a screenshot of what rendered.
- Start on the free tier. Up to 1,000 AI actions a month cost nothing on pay as you go.
Conclusion
Simulators and emulators cover the five moments with repeatable profiles, and that's where the regression suite belongs. A few conditions stay out of reach: a handover from Wi-Fi to cellular mid-request, a captive portal that answers every request with a login page, and carrier NAT dropping idle connections.
Those need a real phone on a real network, and they're worth one manual pass per release on the flows that write data.
FAQs
1. How do I slow down the Android Emulator network?
Start it with -netdelay and -netspeed presets such as edge, or use console network commands.
2. Why does the emulator ignore -netdelay on Wi-Fi?
The presets apply to Ethernet and cellular; Emulator 36.5 and later route Wi-Fi through netsim.
3. What is the default OkHttp timeout?
Ten seconds for connect, read and write. The call timeout defaults to none.
4. Which iOS error means the connection dropped mid-request?
NSURLErrorNetworkConnectionLost. A request with no connection at all gets NSURLErrorNotConnectedToInternet.
5. How long does WorkManager wait before retrying?
The default backoff is exponential, starting at 30 seconds, with a 10-second minimum.
6. Can an Autosana sandbox change the network during a run?
Yes. autosana sandbox set network changes it between steps, with a screenshot of each.
Sources


