diff --git a/internal/driver/sidecar/client_test.go b/internal/driver/sidecar/client_test.go index 00799b7..d64d868 100644 --- a/internal/driver/sidecar/client_test.go +++ b/internal/driver/sidecar/client_test.go @@ -105,6 +105,15 @@ func (s *fakeServer) Screenshot(_ context.Context, _ *driverpb.Empty) (*driverpb return &driverpb.Image{Png: s.imagePNG, Width: s.imageWidth, Height: s.imageHeight}, nil } +func (s *fakeServer) Snapshot(_ context.Context, _ *driverpb.Empty) (*driverpb.SnapshotResponse, error) { + s.mutex.Lock() + defer s.mutex.Unlock() + return &driverpb.SnapshotResponse{ + Hierarchy: &driverpb.HierarchyJSON{Json: s.hierarchy}, + Screenshot: &driverpb.Image{Png: s.imagePNG, Width: s.imageWidth, Height: s.imageHeight}, + }, nil +} + type harness struct { server *grpc.Server fake *fakeServer @@ -260,6 +269,23 @@ func TestClient_HierarchyAndScreenshot(t *testing.T) { } } +func TestClient_SnapshotPairsHierarchyAndScreenshot(t *testing.T) { + state := newHarness(t) + client, _ := Dial(state.address) + defer client.Close() + + hierarchyJSON, image, err := client.Snapshot(context.Background()) + if err != nil { + t.Fatal(err) + } + if hierarchyJSON != `{"x":1}` { + t.Errorf("hierarchy wrong: %q", hierarchyJSON) + } + if image.Width != 1080 || image.Height != 2340 || len(image.PNG) != 1 { + t.Errorf("image wrong: %+v", image) + } +} + func TestClient_WaitForIdleForwardsMillis(t *testing.T) { state := newHarness(t) client, _ := Dial(state.address) diff --git a/proto/driverpb/driver_test.go b/proto/driverpb/driver_test.go index 6ca1bd0..0812179 100644 --- a/proto/driverpb/driver_test.go +++ b/proto/driverpb/driver_test.go @@ -22,6 +22,7 @@ func TestDriverServiceDescriptor(t *testing.T) { "PressKey": true, "Screenshot": true, "Hierarchy": true, + "Snapshot": true, "RecentLogs": true, "WaitForIdle": true, "Health": true,