mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 12:07:09 +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
|
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 {
|
type harness struct {
|
||||||
server *grpc.Server
|
server *grpc.Server
|
||||||
fake *fakeServer
|
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) {
|
func TestClient_WaitForIdleForwardsMillis(t *testing.T) {
|
||||||
state := newHarness(t)
|
state := newHarness(t)
|
||||||
client, _ := Dial(state.address)
|
client, _ := Dial(state.address)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ func TestDriverServiceDescriptor(t *testing.T) {
|
|||||||
"PressKey": true,
|
"PressKey": true,
|
||||||
"Screenshot": true,
|
"Screenshot": true,
|
||||||
"Hierarchy": true,
|
"Hierarchy": true,
|
||||||
|
"Snapshot": true,
|
||||||
"RecentLogs": true,
|
"RecentLogs": true,
|
||||||
"WaitForIdle": true,
|
"WaitForIdle": true,
|
||||||
"Health": true,
|
"Health": true,
|
||||||
|
|||||||
Reference in new issue
Block a user