diff --git a/app/src/androidTest/java/com/nextcloud/client/sso/SSOActivityIT.kt b/app/src/androidTest/java/com/nextcloud/client/sso/SSOActivityIT.kt new file mode 100644 index 0000000000..56867be13c --- /dev/null +++ b/app/src/androidTest/java/com/nextcloud/client/sso/SSOActivityIT.kt @@ -0,0 +1,28 @@ +package com.nextcloud.client.sso + +import androidx.test.espresso.intent.rule.IntentsTestRule +import com.owncloud.android.AbstractIT +import com.owncloud.android.ui.activity.SsoGrantPermissionActivity +import org.junit.Assert.fail +import org.junit.Rule +import org.junit.Test + +class SSOActivityIT : AbstractIT() { + + @Suppress("DEPRECATION") + @get:Rule + var activityRule = IntentsTestRule(SsoGrantPermissionActivity::class.java, true, false) + + @Test + fun testActivityStartsWithoutCrash() { + val sut = activityRule.launchActivity(null) + assert(sut.binding != null) + + try { + sut.showDialog() + assert(true) + } catch (e: Exception) { + fail("Wrong theme style applied") + } + } +} diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SsoGrantPermissionActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/SsoGrantPermissionActivity.java index aa5a77ce7d..808548c94e 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SsoGrantPermissionActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/SsoGrantPermissionActivity.java @@ -69,13 +69,19 @@ public class SsoGrantPermissionActivity extends BaseActivity { private AlertDialog dialog; + private DialogSsoGrantPermissionBinding binding; + + public DialogSsoGrantPermissionBinding getBinding() { + return binding; + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); viewThemeUtils = themeUtilsFactory.withDefaultSchemes(); - DialogSsoGrantPermissionBinding binding = DialogSsoGrantPermissionBinding.inflate(getLayoutInflater()); + binding = DialogSsoGrantPermissionBinding.inflate(getLayoutInflater()); ComponentName callingActivity = getCallingActivity(); @@ -101,16 +107,7 @@ public class SsoGrantPermissionActivity extends BaseActivity { Log_OC.e(TAG, "Error retrieving app icon", e); } - final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this) - .setView(binding.getRoot()) - .setCancelable(false) - .setPositiveButton(R.string.permission_allow, (dialog, which) -> grantPermission()) - .setNegativeButton(R.string.permission_deny, (dialog, which) -> exitFailed()); - - viewThemeUtils.dialog.colorMaterialAlertDialogBackground(this, builder); - - dialog = builder.create(); - dialog.show(); + showDialog(); Log_OC.v(TAG, "TOKEN-REQUEST: Calling Package: " + packageName); Log_OC.v(TAG, "TOKEN-REQUEST: App Name: " + appName); @@ -121,6 +118,19 @@ public class SsoGrantPermissionActivity extends BaseActivity { } } + public void showDialog() { + final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this) + .setView(binding.getRoot()) + .setCancelable(false) + .setPositiveButton(R.string.permission_allow, (dialog, which) -> grantPermission()) + .setNegativeButton(R.string.permission_deny, (dialog, which) -> exitFailed()); + + viewThemeUtils.dialog.colorMaterialAlertDialogBackground(this, builder); + + dialog = builder.create(); + dialog.show(); + } + @Override protected void onStart() { super.onStart();