Merge pull request #13297 from nextcloud/feature/add-sso-activity-test

Add SSO Activity Theme Correctness Test
This commit is contained in:
Alper Öztürk 2024-07-22 11:13:15 +02:00 committed by GitHub
commit 7935e4463f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 42 additions and 2 deletions

View file

@ -0,0 +1,28 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2024 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
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.Rule
import org.junit.Test
class SSOActivityTests : AbstractIT() {
@Suppress("DEPRECATION")
@get:Rule
var activityRule = IntentsTestRule(SsoGrantPermissionActivity::class.java, true, false)
@Test
fun testActivityTheme() {
val sut = activityRule.launchActivity(null)
assert(sut.binding != null)
assert(sut.materialAlertDialogBuilder != null)
}
}

View file

@ -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,7 +107,9 @@ public class SsoGrantPermissionActivity extends BaseActivity {
Log_OC.e(TAG, "Error retrieving app icon", e);
}
final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this)
MaterialAlertDialogBuilder builder = getMaterialAlertDialogBuilder();
builder
.setView(binding.getRoot())
.setCancelable(false)
.setPositiveButton(R.string.permission_allow, (dialog, which) -> grantPermission())
@ -121,6 +129,10 @@ public class SsoGrantPermissionActivity extends BaseActivity {
}
}
public MaterialAlertDialogBuilder getMaterialAlertDialogBuilder() {
return new MaterialAlertDialogBuilder(this);
}
@Override
protected void onStart() {
super.onStart();