Skip to content

Commit

Permalink
Merge pull request #13297 from nextcloud/feature/add-sso-activity-test
Browse files Browse the repository at this point in the history
Add SSO Activity Theme Correctness Test
  • Loading branch information
alperozturk96 authored Jul 22, 2024
2 parents 8acb50a + efc956d commit 7935e44
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2024 Alper Ozturk <[email protected]>
* 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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -101,7 +107,9 @@ protected void onCreate(Bundle savedInstanceState) {
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())
Expand All @@ -121,6 +129,10 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

public MaterialAlertDialogBuilder getMaterialAlertDialogBuilder() {
return new MaterialAlertDialogBuilder(this);
}

@Override
protected void onStart() {
super.onStart();
Expand Down

0 comments on commit 7935e44

Please sign in to comment.