Search in sources :

Example 1 with MainActivity

use of com.onesignal.example.MainActivity 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)

Aggregations

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