during testing, need make wifimanager.getscanresults()
method return non-empty list. i'm using robolectric. found shadowwifimanager
has setscanresults()
method, takes list of scanresult
objects -- don't have public constructor.
i found robolectric has shadow of scanresult
, also, has newinstance
method. can used this:
shadowof(((wifimanager)controller.get().getsystemservice(context.wifi_service))).setscanresults(collections.singletonlist(shadowscanresult.newinstance("foo", "bar", "", 1, 2)));
or, more verbosely: final int level = 5; final int frequency = 100; final scanresult scanresult = shadowscanresult.newinstance( "a fake ssid", "a fake bssid", "some capabilities", level, frequency); final context context = controller.get(); final wifimanager wifimanager = (wifimanager) context.getsystemservice(context.wifi_service); shadowof(wifimanager).setscanresults(collections.singletonlist(scanresult));
Comments
Post a Comment