mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 06:35:48 +03:00
Add test
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
8acb50aa10
commit
7896d983e6
2 changed files with 49 additions and 11 deletions
|
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue