mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
test(driver): cover Snapshot in proto descriptor and sidecar client
Adds Snapshot to the descriptor allowlist and a sidecar-client test that asserts both fields come back over the wire.
This commit is contained in:
1 parent
5c58610181
commit
56b762deac
2 files changed
+27
No files matched your search
@@ -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)
|
||||
|
||||
@@ -22,6 +22,7 @@ func TestDriverServiceDescriptor(t *testing.T) {
|
||||
"PressKey": true,
|
||||
"Screenshot": true,
|
||||
"Hierarchy": true,
|
||||
"Snapshot": true,
|
||||
"RecentLogs": true,
|
||||
"WaitForIdle": true,
|
||||
"Health": true,
|
||||
|
||||
Reference in new issue
Block a user