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);
}
Aggregations