-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CATROID-1130 Refactor TermsOfUseDialogTest and AboutDialogTest to kotlin
- Loading branch information
1 parent
b2695f8
commit c9310d9
Showing
4 changed files
with
230 additions
and
236 deletions.
There are no files selected for viewing
125 changes: 0 additions & 125 deletions
125
catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/dialog/AboutDialogTest.java
This file was deleted.
Oops, something went wrong.
119 changes: 119 additions & 0 deletions
119
catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/dialog/AboutDialogTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* Catroid: An on-device visual programming system for Android devices | ||
* Copyright (C) 2010-2021 The Catrobat Team | ||
* (<http://developer.catrobat.org/credits>) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* An additional term exception under section 7 of the GNU Affero | ||
* General Public License, version 3, is available at | ||
* http://developer.catrobat.org/license_additional_term | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.catrobat.catroid.uiespresso.ui.dialog | ||
|
||
import android.preference.PreferenceManager | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.espresso.Espresso | ||
import androidx.test.espresso.action.ViewActions | ||
import androidx.test.espresso.assertion.ViewAssertions | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.catrobat.catroid.BuildConfig | ||
import org.catrobat.catroid.R | ||
import org.catrobat.catroid.common.Constants | ||
import org.catrobat.catroid.common.SharedPreferenceKeys | ||
import org.catrobat.catroid.testsuites.annotations.Cat.AppUi | ||
import org.catrobat.catroid.testsuites.annotations.Level.Smoke | ||
import org.catrobat.catroid.ui.MainMenuActivity | ||
import org.catrobat.catroid.uiespresso.util.rules.DontGenerateDefaultProjectActivityTestRule | ||
import org.catrobat.catroid.utils.Utils | ||
import org.junit.After | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.experimental.categories.Category | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class AboutDialogTest { | ||
@get:Rule | ||
var baseActivityTestRule = DontGenerateDefaultProjectActivityTestRule( | ||
MainMenuActivity::class.java, true, false | ||
) | ||
|
||
private var bufferedPrivacyPolicyPreferenceSetting = 0 | ||
|
||
@Before | ||
@Throws(Exception::class) | ||
fun setUp() { | ||
val sharedPreferences = PreferenceManager | ||
.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext()) | ||
bufferedPrivacyPolicyPreferenceSetting = sharedPreferences | ||
.getInt(SharedPreferenceKeys.AGREED_TO_PRIVACY_POLICY_VERSION, 0) | ||
sharedPreferences | ||
.edit() | ||
.putInt( | ||
SharedPreferenceKeys.AGREED_TO_PRIVACY_POLICY_VERSION, | ||
Constants.CATROBAT_TERMS_OF_USE_ACCEPTED | ||
) | ||
.commit() | ||
baseActivityTestRule.launchActivity(null) | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext()) | ||
.edit() | ||
.putInt( | ||
SharedPreferenceKeys.AGREED_TO_PRIVACY_POLICY_VERSION, | ||
bufferedPrivacyPolicyPreferenceSetting | ||
) | ||
.commit() | ||
} | ||
|
||
@Category(AppUi::class, Smoke::class) | ||
@Test | ||
fun aboutDialogTest() { | ||
Espresso.openActionBarOverflowOrOptionsMenu(baseActivityTestRule.activity) | ||
|
||
Espresso.onView(ViewMatchers.withText(R.string.main_menu_about)) | ||
.perform(ViewActions.click()) | ||
|
||
Espresso.onView(ViewMatchers.withText(R.string.dialog_about_title)) | ||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed())) | ||
|
||
Espresso.onView(ViewMatchers.withText(R.string.dialog_about_license_info)) | ||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed())) | ||
|
||
Espresso.onView(ViewMatchers.withText(R.string.dialog_about_license_link_text)) | ||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed())) | ||
|
||
Espresso.onView(ViewMatchers.withText(R.string.dialog_about_catrobat_link_text)) | ||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed())) | ||
|
||
Espresso.onView(ViewMatchers.withId(R.id.dialog_about_text_view_catrobat_version_name)) | ||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed())) | ||
|
||
Assert.assertNotNull(Utils.getVersionName(ApplicationProvider.getApplicationContext())) | ||
|
||
Assert.assertNotEquals("", BuildConfig.VERSION_NAME) | ||
|
||
Espresso.onView(ViewMatchers.withText(R.string.ok)) | ||
.perform(ViewActions.click()) | ||
|
||
Espresso.onView(ViewMatchers.withText(R.string.dialog_about_title)) | ||
.check(ViewAssertions.doesNotExist()) | ||
} | ||
} |
111 changes: 0 additions & 111 deletions
111
.../src/androidTest/java/org/catrobat/catroid/uiespresso/ui/dialog/TermsOfUseDialogTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.