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

Popular posts from this blog

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -