diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseActivityTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseActivityTest.kt index fdb7c7537..e3c949d47 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseActivityTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseActivityTest.kt @@ -35,10 +35,10 @@ abstract class BaseActivityTest { @get:Rule abstract var activityRule: ActivityTestRule @get:Rule - var readPermissionRule: GrantPermissionRule = + open var readPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(permission.READ_EXTERNAL_STORAGE) @get:Rule - var writePermissionRule: GrantPermissionRule = + open var writePermissionRule: GrantPermissionRule = GrantPermissionRule.grant(permission.WRITE_EXTERNAL_STORAGE) val context: Context by lazy { diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.java b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.java deleted file mode 100644 index d63c99a77..000000000 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Kiwix Android - * Copyright (c) 2020 Kiwix - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -package org.kiwix.kiwixmobile.help; - -import android.Manifest; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.filters.LargeTest; -import androidx.test.rule.ActivityTestRule; -import androidx.test.rule.GrantPermissionRule; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.kiwix.kiwixmobile.R; -import org.kiwix.kiwixmobile.main.KiwixMainActivity; - -import static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; -import static com.schibsted.spain.barista.interaction.BaristaClickInteractions.clickOn; - -@LargeTest -@RunWith(AndroidJUnit4.class) -public class HelpFragmentTest { - - @Rule - public ActivityTestRule activityTestRule = - new ActivityTestRule<>(KiwixMainActivity.class); - @Rule - public GrantPermissionRule readPermissionRule = - GrantPermissionRule.grant(Manifest.permission.READ_EXTERNAL_STORAGE); - @Rule - public GrantPermissionRule writePermissionRule = - GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE); - - @Before - public void setup() { - openDrawer(); - clickOn(R.string.menu_help); - } - - @Test - public void verifyHelpActivity() { - HelpRobot helpRobot = new HelpRobot(); - helpRobot.clickOnWhatDoesKiwixDo(); - helpRobot.assertWhatDoesKiwixDoIsExpanded(); - helpRobot.clickOnWhatDoesKiwixDo(); - helpRobot.clickOnWhereIsContent(); - helpRobot.assertWhereIsContentIsExpanded(); - helpRobot.clickOnWhereIsContent(); - helpRobot.clickOnSendFeedback(); - } - - private void openDrawer() { - onView(withContentDescription(R.string.open_drawer)).perform(click()); - } -} diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt new file mode 100644 index 000000000..b3a0fceb1 --- /dev/null +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt @@ -0,0 +1,59 @@ +/* + * Kiwix Android + * Copyright (c) 2019 Kiwix + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package org.kiwix.kiwixmobile.help + +import android.Manifest +import android.os.Build +import androidx.test.filters.SdkSuppress +import androidx.test.internal.runner.junit4.statement.UiThreadStatement.runOnUiThread +import androidx.test.rule.ActivityTestRule +import androidx.test.rule.GrantPermissionRule +import org.junit.Rule +import org.junit.Test +import org.kiwix.kiwixmobile.R +import org.kiwix.kiwixmobile.main.KiwixMainActivity + +@SdkSuppress(minSdkVersion = Build.VERSION_CODES.JELLY_BEAN_MR2) +class HelpFragmentTest { + + @get:Rule + var activityRule: ActivityTestRule = + ActivityTestRule(KiwixMainActivity::class.java) + + @get:Rule + var readPermissionRule: GrantPermissionRule = + GrantPermissionRule.grant(Manifest.permission.READ_EXTERNAL_STORAGE) + + @get:Rule + var writePermissionRule: GrantPermissionRule = + GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE) + + @Test + fun verifyHelpActivity() { + runOnUiThread { activityRule.activity.navigate(R.id.helpFragment) } + help { + clickOnWhatDoesKiwixDo() + assertWhatDoesKiwixDoIsExpanded() + clickOnWhatDoesKiwixDo() + clickOnWhereIsContent() + assertWhereIsContentIsExpanded() + clickOnWhereIsContent() + clickOnSendFeedback() + } + } +}