mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-17 03:16:27 -04:00
Merge pull request #3061 from kiwix/Issue#3060
Convert StandardActions.java into kotlin
This commit is contained in:
commit
c65cd3df65
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Kiwix Android
|
||||
* Copyright (c) 2019 Kiwix <android.kiwix.org>
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package org.kiwix.kiwixmobile.utils;
|
||||
|
||||
import android.util.Log;
|
||||
import com.adevinta.android.barista.interaction.BaristaClickInteractions;
|
||||
import com.adevinta.android.barista.interaction.BaristaDrawerInteractions;
|
||||
import com.adevinta.android.barista.interaction.BaristaSleepInteractions;
|
||||
import org.kiwix.kiwixmobile.R;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onData;
|
||||
import static androidx.test.espresso.action.ViewActions.longClick;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static com.adevinta.android.barista.interaction.BaristaDialogInteractions.clickDialogPositiveButton;
|
||||
import static org.kiwix.kiwixmobile.testutils.TestUtils.TEST_PAUSE_MS;
|
||||
import static org.kiwix.kiwixmobile.testutils.TestUtils.getResourceString;
|
||||
import static org.kiwix.kiwixmobile.testutils.TestUtils.withContent;
|
||||
|
||||
/**
|
||||
* Created by mhutti1 on 27/04/17.
|
||||
*/
|
||||
|
||||
public class StandardActions {
|
||||
|
||||
public static void enterSettings() {
|
||||
BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
|
||||
BaristaClickInteractions.clickOn(getResourceString(R.string.menu_settings));
|
||||
}
|
||||
|
||||
public static void openDrawer() {
|
||||
BaristaDrawerInteractions.openDrawer();
|
||||
}
|
||||
|
||||
public static void deleteZimIfExists(String zimName, Integer adapterId) {
|
||||
try {
|
||||
onData(withContent(zimName)).inAdapterView(withId(adapterId)).perform(longClick());
|
||||
clickDialogPositiveButton();
|
||||
Log.i("TEST_DELETE_ZIM", "Successfully deleted ZIM file [" + zimName + "]");
|
||||
} catch (RuntimeException e) {
|
||||
Log.i("TEST_DELETE_ZIM", "Failed to delete ZIM file [" + zimName + "]... " +
|
||||
"Probably because it doesn't exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Kiwix Android
|
||||
* Copyright (c) 2019 Kiwix <android.kiwix.org>
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package org.kiwix.kiwixmobile.utils
|
||||
|
||||
import android.util.Log
|
||||
import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
|
||||
import com.adevinta.android.barista.interaction.BaristaSleepInteractions
|
||||
import org.kiwix.kiwixmobile.R
|
||||
import androidx.test.espresso.Espresso
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import com.adevinta.android.barista.interaction.BaristaDialogInteractions
|
||||
import com.adevinta.android.barista.interaction.BaristaDrawerInteractions
|
||||
import org.kiwix.kiwixmobile.testutils.TestUtils
|
||||
import java.lang.RuntimeException
|
||||
|
||||
/**
|
||||
* Created by mhutti1 on 27/04/17.
|
||||
*/
|
||||
object StandardActions {
|
||||
fun enterSettings() {
|
||||
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong())
|
||||
clickOn(TestUtils.getResourceString(R.string.menu_settings))
|
||||
}
|
||||
|
||||
fun openDrawer() {
|
||||
BaristaDrawerInteractions.openDrawer()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteZimIfExists(zimName: String, adapterId: Int) {
|
||||
try {
|
||||
Espresso.onData(TestUtils.withContent(zimName)).inAdapterView(
|
||||
ViewMatchers.withId(
|
||||
adapterId
|
||||
)
|
||||
).perform(ViewActions.longClick())
|
||||
BaristaDialogInteractions.clickDialogPositiveButton()
|
||||
Log.i("TEST_DELETE_ZIM", "Successfully deleted ZIM file [$zimName]")
|
||||
} catch (e: RuntimeException) {
|
||||
Log.i(
|
||||
"TEST_DELETE_ZIM",
|
||||
"Failed to delete ZIM file [" + zimName + "]... " +
|
||||
"Probably because it doesn't exist"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user