Skip to content

Commit

Permalink
fill out simulate_location
Browse files Browse the repository at this point in the history
  • Loading branch information
Mause authored Dec 2, 2024
1 parent 1562244 commit fc1e5a4
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions winforms/tests_backend/hardware/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@


class LocationProbe(HardwareProbe):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._locations = []

def cleanup(self):
# Delete the location service instance. This ensures that a freshly mocked
# LocationManager is installed for each test.
Expand Down Expand Up @@ -36,18 +40,27 @@ def add_location(self, location: LatLng, altitude, cached=False):
m.Position.Location.Longitude = location.lng
m.Position.Location.Altitude = altitude

self.app.location._impl._position_changed(None, m)
self._locations.append(m)

def reset_locations(self):
# self._cached_location = None
self._locations = []

def allow_background_permission(self):
pass

async def simulate_location_error(self, loco):
raise RuntimeError(f"Unable to obtain a location ({loco})")

async def simulate_current_location(self, loco):
res = await loco
assert res is not None
return res
async def simulate_current_location(self, location):
await self.redraw("Wait for current location")
if not self._cached_location:
# Trigger the callback
self.app.location._impl._position_changed(None, self._locations[-1])

self.reset_locations()

return await location

async def simulate_location_update(self):
pass

0 comments on commit fc1e5a4

Please sign in to comment.