Search in sources :

Example 1 with BlankActivity

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

the class MainOneSignalClassRunner method testAndroidManifestConfigChangeFlags_orientationFlag.

/**
 * Created a AndroidManifest with 2 activities, 1 with the orientation config and 1 without
 * Using this AndroidManifest setup to test that a config setting is detectable
 */
@Test
public void testAndroidManifestConfigChangeFlags_orientationFlag() throws Exception {
    OneSignalInit();
    threadAndTaskWait();
    // Set ActivityInfo.CONFIG_ORIENTATION configChanges flag
    OneSignalShadowPackageManager.configChanges = ActivityInfo.CONFIG_ORIENTATION;
    // Verify BlankActivity has orientation flag
    boolean blankHasFlag = OneSignalPackagePrivateHelper.hasConfigChangeFlag(blankActivity, ActivityInfo.CONFIG_ORIENTATION);
    assertTrue(blankHasFlag);
    // Go to MainActivity
    Intent mainIntent = new Intent(blankActivity, MainActivity.class);
    Activity mainActivity = Robolectric.buildActivity(MainActivity.class).newIntent(mainIntent).create().get();
    // Set no configChanges flags
    OneSignalShadowPackageManager.configChanges = 0;
    // Verify MainActivity has no orientation flag
    boolean mainHasFlag = OneSignalPackagePrivateHelper.hasConfigChangeFlag(mainActivity, ActivityInfo.CONFIG_ORIENTATION);
    assertFalse(mainHasFlag);
}
Also used : TestHelpers.stopActivity(com.test.onesignal.TestHelpers.stopActivity) TestHelpers.pauseActivity(com.test.onesignal.TestHelpers.pauseActivity) BlankActivity(com.onesignal.example.BlankActivity) PermissionsActivity(com.onesignal.PermissionsActivity) MainActivity(com.onesignal.example.MainActivity) Activity(android.app.Activity) Intent(android.content.Intent) MainActivity(com.onesignal.example.MainActivity) Test(org.junit.Test)

Example 2 with BlankActivity

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

the class NotificationOpenedActivityHMSIntegrationTestsRunner method osIAMPreview_showsPreview.

@Test
public void osIAMPreview_showsPreview() throws Exception {
    ActivityController<BlankActivity> blankActivityController = Robolectric.buildActivity(BlankActivity.class).create();
    Activity blankActivity = blankActivityController.get();
    OneSignal.setAppId(ONESIGNAL_APP_ID);
    OneSignal.initWithContext(blankActivity);
    threadAndTaskWait();
    blankActivityController.resume();
    threadAndTaskWait();
    Intent intent = helper_baseHMSOpenIntent().putExtra(PAYLOAD_OS_ROOT_CUSTOM, new JSONObject() {

        {
            put(PAYLOAD_OS_NOTIFICATION_ID, UUID.randomUUID().toString());
            put(PUSH_ADDITIONAL_DATA_KEY, new JSONObject() {

                {
                    put("os_in_app_message_preview_id", "UUID");
                }
            });
        }
    }.toString());
    helper_startHMSOpenActivity(intent);
    assertEquals("PGh0bWw+PC9odG1sPgoKPHNjcmlwdD4KICAgIHNldFBsYXllclRhZ3MobnVsbCk7Cjwvc2NyaXB0Pg==", ShadowOSWebView.lastData);
}
Also used : BlankActivity(com.onesignal.example.BlankActivity) JSONObject(org.json.JSONObject) BlankActivity(com.onesignal.example.BlankActivity) Activity(android.app.Activity) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

Activity (android.app.Activity)2 Intent (android.content.Intent)2 BlankActivity (com.onesignal.example.BlankActivity)2 Test (org.junit.Test)2 PermissionsActivity (com.onesignal.PermissionsActivity)1 MainActivity (com.onesignal.example.MainActivity)1 TestHelpers.pauseActivity (com.test.onesignal.TestHelpers.pauseActivity)1 TestHelpers.stopActivity (com.test.onesignal.TestHelpers.stopActivity)1 JSONObject (org.json.JSONObject)1