diff --git a/internal/driver/sidecar/client.go b/internal/driver/sidecar/client.go index 04583d3..0214b29 100644 --- a/internal/driver/sidecar/client.go +++ b/internal/driver/sidecar/client.go @@ -46,6 +46,9 @@ func (c *Client) SetClearStateReinstall(serial, apkPath string, output io.Writer c.serial = serial c.apkPath = apkPath c.output = output + if c.reinstallApp == nil { + c.reinstallApp = android.ReinstallApp + } } // ForegroundApp reports the foreground package. Only Android is supported (via diff --git a/internal/driver/sidecar/client_test.go b/internal/driver/sidecar/client_test.go index 9dd6715..2cee6c6 100644 --- a/internal/driver/sidecar/client_test.go +++ b/internal/driver/sidecar/client_test.go @@ -372,6 +372,25 @@ func TestClient_LaunchClearStateWithoutApkPathUsesSidecarClear(t *testing.T) { } } +func TestClient_LaunchClearStateNonAndroidUsesSidecarClear(t *testing.T) { + state := newHarness(t) + client, _ := Dial(state.address) + defer client.Close() + client.SetPlatform("ios") + client.SetClearStateReinstall("", "/tmp/app.app", io.Discard) + client.reinstallApp = func(_ context.Context, _, _, _ string, _ io.Writer) error { + t.Fatal("reinstall must not run on a non-android platform") + return nil + } + + if err := client.Launch(context.Background(), "app.folio", true, nil); err != nil { + t.Fatal(err) + } + if !state.fake.clearState { + t.Error("non-android clear-state must forward clearState to the sidecar") + } +} + func TestClient_TapAndTapSelector(t *testing.T) { state := newHarness(t) client, _ := Dial(state.address)