android - Robolectric 3.0 testing Vibrator service -


i in process of migrating test cases latest robolectric 3.0. test viberator service in app, earlier used

org.robolectric.shadows.shadowvibrator 

but not able test it, using custom shadow class.

even robolectric wesite not updated , shows use robolectric.shadowof_() not exist.

this link of website, not updated version. kindly guide.

following code custom implementation:--

the custom class:--

@implements(vibrator.class) public class shadowvibrator {     private boolean vibrating;     private boolean cancelled;     private long milliseconds;     private long[] pattern;     private int repeat;      @implementation     public void vibrate(long milliseconds) {         vibrating = true;         this.milliseconds = milliseconds;     }      @implementation     public void vibrate(long[] pattern, int repeat) {         vibrating = true;         this.pattern = pattern;         this.repeat = repeat;     }      @implementation     public void cancel() {         cancelled = true;         vibrating = false;     }      public boolean isvibrating() {         return vibrating;     }      public boolean iscancelled() {         return cancelled;     }      public long getmilliseconds() {         return milliseconds;     }      public long[] getpattern() {         return pattern;     }      public int getrepeat() {         return repeat;     } } 

and want use in code , can point me correct api:--

shadowvibrator shadowvibrator = shadows.shadowof((vibrator) context.getsystemservice(context.vibrator_service)); 

have @ robovibrator

robovibrator vibrator = (robovibrator) runtimeenvironment.application.getsystemservice(context.vibrator_service); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -