Search in sources :

Example 1 with ContextHubInfo

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();
}
Also used : ContextHubManager(android.hardware.location.ContextHubManager) ContextHubInfo(android.hardware.location.ContextHubInfo) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 2 with ContextHubInfo

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);
}
Also used : ContextHubManager(android.hardware.location.ContextHubManager) ContextHubInfo(android.hardware.location.ContextHubInfo) NanoAppInstanceInfo(android.hardware.location.NanoAppInstanceInfo) Test(org.junit.Test)

Example 3 with ContextHubInfo

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();
}
Also used : ContextHubManager(android.hardware.location.ContextHubManager) ContextHubInfo(android.hardware.location.ContextHubInfo) List(java.util.List) ContextHubTransaction(android.hardware.location.ContextHubTransaction) NanoAppState(android.hardware.location.NanoAppState) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 4 with ContextHubInfo

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();
}
Also used : ContextHubManager(android.hardware.location.ContextHubManager) ContextHubInfo(android.hardware.location.ContextHubInfo) List(java.util.List) ContextHubTransaction(android.hardware.location.ContextHubTransaction) NanoAppState(android.hardware.location.NanoAppState) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

ContextHubInfo (android.hardware.location.ContextHubInfo)4 ContextHubManager (android.hardware.location.ContextHubManager)4 Test (org.junit.Test)4 Config (org.robolectric.annotation.Config)3 ContextHubTransaction (android.hardware.location.ContextHubTransaction)2 NanoAppState (android.hardware.location.NanoAppState)2 List (java.util.List)2 NanoAppInstanceInfo (android.hardware.location.NanoAppInstanceInfo)1