Search in sources :

Example 6 with OSDeviceState

use of com.onesignal.OSDeviceState in project OneSignal-Android-SDK by OneSignal.

the class MainOneSignalClassRunner method testDeviceStateHasSMSAddress.

@Test
public void testDeviceStateHasSMSAddress() throws Exception {
    assertNull(OneSignal.getDeviceState());
    OneSignalInit();
    threadAndTaskWait();
    OSDeviceState device = OneSignal.getDeviceState();
    assertNull(device.getSMSNumber());
    OneSignal.setSMSNumber(ONESIGNAL_SMS_NUMBER);
    threadAndTaskWait();
    // Device is a snapshot, last value should not change
    assertNull(device.getSMSNumber());
    // Retrieve new user device
    assertEquals(ONESIGNAL_SMS_NUMBER, OneSignal.getDeviceState().getSMSNumber());
}
Also used : OSDeviceState(com.onesignal.OSDeviceState) Test(org.junit.Test)

Example 7 with OSDeviceState

use of com.onesignal.OSDeviceState in project OneSignal-Android-SDK by OneSignal.

the class MainOneSignalClassRunner method testDeviceStateHasEmailAddress.

@Test
public void testDeviceStateHasEmailAddress() throws Exception {
    String testEmail = "test@onesignal.com";
    assertNull(OneSignal.getDeviceState());
    OneSignalInit();
    threadAndTaskWait();
    OSDeviceState device = OneSignal.getDeviceState();
    assertNull(device.getEmailAddress());
    OneSignal.setEmail(testEmail);
    threadAndTaskWait();
    // Device is a snapshot, last value should not change
    assertNull(device.getEmailAddress());
    // Retrieve new user device
    assertEquals(testEmail, OneSignal.getDeviceState().getEmailAddress());
}
Also used : OSDeviceState(com.onesignal.OSDeviceState) Test(org.junit.Test)

Example 8 with OSDeviceState

use of com.onesignal.OSDeviceState in project OneSignal-Android-SDK by OneSignal.

the class MainOneSignalClassRunner method shouldGetEmailUserIdAfterAppRestart.

@Test
public void shouldGetEmailUserIdAfterAppRestart() throws Exception {
    OneSignalInit();
    OneSignal.setEmail("josh@onesignal.com");
    threadAndTaskWait();
    restartAppAndElapseTimeToNextSession(time);
    OneSignalInit();
    OSDeviceState deviceState = OneSignal.getDeviceState();
    assertEquals("josh@onesignal.com", deviceState.getEmailAddress());
    assertNotNull(deviceState.getEmailUserId());
}
Also used : OSDeviceState(com.onesignal.OSDeviceState) Test(org.junit.Test)

Example 9 with OSDeviceState

use of com.onesignal.OSDeviceState in project OneSignal-Android-SDK by OneSignal.

the class MainOneSignalClassRunner method shouldReturnCorrectGetPermissionSubscriptionState.

@Test
public void shouldReturnCorrectGetPermissionSubscriptionState() throws Exception {
    OneSignalInit();
    threadAndTaskWait();
    OSDeviceState deviceState = OneSignal.getDeviceState();
    assertTrue(deviceState.areNotificationsEnabled());
    assertTrue(deviceState.isSubscribed());
}
Also used : OSDeviceState(com.onesignal.OSDeviceState) Test(org.junit.Test)

Example 10 with OSDeviceState

use of com.onesignal.OSDeviceState in project OneSignal-Android-SDK by OneSignal.

the class MainOneSignalClassRunner method testDeviceStateHasSMSId.

@Test
public void testDeviceStateHasSMSId() throws Exception {
    assertNull(OneSignal.getDeviceState());
    OneSignalInit();
    threadAndTaskWait();
    OSDeviceState device = OneSignal.getDeviceState();
    assertNull(device.getSMSUserId());
    OneSignal.setSMSNumber(ONESIGNAL_SMS_NUMBER);
    threadAndTaskWait();
    // Device is a snapshot, last value should not change
    assertNull(device.getSMSUserId());
    // Retrieve new user device
    assertEquals(SMS_USER_ID, OneSignal.getDeviceState().getSMSUserId());
}
Also used : OSDeviceState(com.onesignal.OSDeviceState) Test(org.junit.Test)

Aggregations

OSDeviceState (com.onesignal.OSDeviceState)14 Test (org.junit.Test)12