use of android.hardware.location.ContextHubInfo in project robolectric by robolectric.
the class ShadowContextHubManagerTest method getContextHubs_returnsValidList.
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void getContextHubs_returnsValidList() {
ContextHubManager contextHubManager = (ContextHubManager) context.getSystemService(Context.CONTEXTHUB_SERVICE);
List<ContextHubInfo> contextHubInfoList = contextHubManager.getContextHubs();
assertThat(contextHubInfoList).isNotNull();
assertThat(contextHubInfoList).isNotEmpty();
}
use of android.hardware.location.ContextHubInfo in project robolectric by robolectric.
the class ShadowContextHubManagerTest method getNanoAppInstanceInfo_returnsValidInfo.
@Test
public void getNanoAppInstanceInfo_returnsValidInfo() {
ContextHubManager contextHubManager = context.getSystemService(ContextHubManager.class);
ShadowContextHubManager shadowManager = Shadow.extract(contextHubManager);
int[] handles = contextHubManager.getContextHubHandles();
ContextHubInfo hubInfo = contextHubManager.getContextHubInfo(handles[0]);
long nanoAppId = 5;
int nanoAppVersion = 1;
int nanoAppUid = 0;
shadowManager.addNanoApp(hubInfo, nanoAppUid, nanoAppId, nanoAppVersion);
NanoAppInstanceInfo info = contextHubManager.getNanoAppInstanceInfo(nanoAppUid);
assertThat(info).isNotNull();
assertThat(info.getAppId()).isEqualTo(nanoAppId);
assertThat(info.getAppVersion()).isEqualTo(nanoAppVersion);
}
use of android.hardware.location.ContextHubInfo in project robolectric by robolectric.
the class ShadowContextHubManagerTest method queryNanoApps_returnsValidNanoApps.
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void queryNanoApps_returnsValidNanoApps() throws Exception {
ContextHubManager contextHubManager = context.getSystemService(ContextHubManager.class);
ShadowContextHubManager shadowManager = Shadow.extract(contextHubManager);
List<ContextHubInfo> contextHubInfoList = contextHubManager.getContextHubs();
long nanoAppId = 5;
int nanoAppVersion = 1;
shadowManager.addNanoApp(contextHubInfoList.get(0), 0, /* nanoAppUid */
nanoAppId, nanoAppVersion);
ContextHubTransaction<List<NanoAppState>> transaction = contextHubManager.queryNanoApps(contextHubInfoList.get(0));
assertThat(transaction.getType()).isEqualTo(ContextHubTransaction.TYPE_QUERY_NANOAPPS);
ContextHubTransaction.Response<List<NanoAppState>> response = transaction.waitForResponse(1, SECONDS);
assertThat(response.getResult()).isEqualTo(ContextHubTransaction.RESULT_SUCCESS);
List<NanoAppState> states = response.getContents();
assertThat(states).isNotNull();
assertThat(states).hasSize(1);
NanoAppState state = states.get(0);
assertThat(state.getNanoAppId()).isEqualTo(nanoAppId);
assertThat(state.getNanoAppVersion()).isEqualTo(nanoAppVersion);
assertThat(state.isEnabled()).isTrue();
}
use of android.hardware.location.ContextHubInfo in project robolectric by robolectric.
the class ShadowContextHubManagerTest method queryNanoApps_noNanoAppsAdded.
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void queryNanoApps_noNanoAppsAdded() throws Exception {
ContextHubManager contextHubManager = context.getSystemService(ContextHubManager.class);
List<ContextHubInfo> contextHubInfoList = contextHubManager.getContextHubs();
ContextHubTransaction<List<NanoAppState>> transaction = contextHubManager.queryNanoApps(contextHubInfoList.get(0));
assertThat(transaction.getType()).isEqualTo(ContextHubTransaction.TYPE_QUERY_NANOAPPS);
ContextHubTransaction.Response<List<NanoAppState>> response = transaction.waitForResponse(1, SECONDS);
assertThat(response.getResult()).isEqualTo(ContextHubTransaction.RESULT_SUCCESS);
List<NanoAppState> states = response.getContents();
assertThat(states).isNotNull();
assertThat(states).isEmpty();
}
Aggregations