mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(driver): add env param to Launch interface and all implementations
This commit is contained in:
1 parent
3a6979a9db
commit
f446439e33
6 files changed
+7
-6
No files matched your search
@@ -77,7 +77,7 @@ func New() *Driver {
|
|||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Launch(ctx context.Context, bundleID string, clearState bool) error {
|
func (d *Driver) Launch(ctx context.Context, bundleID string, clearState bool, _ map[string]string) error {
|
||||||
if clearState {
|
if clearState {
|
||||||
if err := chromedp.Run(d.tabCtx, network.ClearBrowserCookies()); err != nil {
|
if err := chromedp.Run(d.tabCtx, network.ClearBrowserCookies()); err != nil {
|
||||||
return fmt.Errorf("clear cookies: %w", err)
|
return fmt.Errorf("clear cookies: %w", err)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
// lives under driver/sidecar; the web implementation under driver/chrome;
|
// lives under driver/sidecar; the web implementation under driver/chrome;
|
||||||
// tests use driver/mock.
|
// tests use driver/mock.
|
||||||
type DeviceDriver interface {
|
type DeviceDriver interface {
|
||||||
Launch(ctx context.Context, bundleID string, clearState bool) error
|
Launch(ctx context.Context, bundleID string, clearState bool, env map[string]string) error
|
||||||
Terminate(ctx context.Context) error
|
Terminate(ctx context.Context) error
|
||||||
|
|
||||||
Tap(ctx context.Context, x, y int) error
|
Tap(ctx context.Context, x, y int) error
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ func (d *Driver) failure(kind ActionKind) error {
|
|||||||
return d.Failures[kind]
|
return d.Failures[kind]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Launch(_ context.Context, bundleID string, clearState bool) error {
|
func (d *Driver) Launch(_ context.Context, bundleID string, clearState bool, _ map[string]string) error {
|
||||||
if err := d.failure(ActionLaunch); err != nil {
|
if err := d.failure(ActionLaunch); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func TestRecordsAllActionsInOrder(t *testing.T) {
|
|||||||
mock := New()
|
mock := New()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
if err := mock.Launch(ctx, "com.example", true); err != nil {
|
if err := mock.Launch(ctx, "com.example", true, nil); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := mock.Tap(ctx, 100, 200); err != nil {
|
if err := mock.Tap(ctx, 100, 200); err != nil {
|
||||||
|
|||||||
@@ -48,10 +48,11 @@ func (c *Client) WaitForHealth(ctx context.Context, pollInterval time.Duration)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Launch(ctx context.Context, bundleID string, clearState bool) error {
|
func (c *Client) Launch(ctx context.Context, bundleID string, clearState bool, env map[string]string) error {
|
||||||
_, err := c.stub.Launch(ctx, &driverpb.LaunchRequest{
|
_, err := c.stub.Launch(ctx, &driverpb.LaunchRequest{
|
||||||
BundleId: bundleID,
|
BundleId: bundleID,
|
||||||
ClearState: clearState,
|
ClearState: clearState,
|
||||||
|
Env: env,
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ func TestClient_LaunchAndTerminate(t *testing.T) {
|
|||||||
client, _ := Dial(state.address)
|
client, _ := Dial(state.address)
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
if err := client.Launch(context.Background(), "com.example", true); err != nil {
|
if err := client.Launch(context.Background(), "com.example", true, nil); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if state.fake.launchedBundleID != "com.example" || !state.fake.clearState {
|
if state.fake.launchedBundleID != "com.example" || !state.fake.clearState {
|
||||||
|
|||||||
Reference in new issue
Block a user