android - How to test SensorEventListeners with Robolectric? -
suppose have like
public class fizzbuzz implements sensoreventlistener { string fizzbuzz; public int onsensorchanged(sensorevent sensorevent) { if (sensorevent.sensor.gettype() != sensor.type_magnetic_field) return; // if heading mod 360 < 180.0 fizzbuzz = "fizz"; // else fizzbuzz = "buzz"; } public string getfizzbuzz() { /*... */ } } suppose want test behaviour , make sure sets attribute "fizz" when device headed somewhere between 0 , 180 degrees , "buzz" otherwise.
what proper way of doing robolectric - is, feeding fake sensorevents , verifying output 1 expected?
Comments
Post a Comment