From aa3b6f8e9ea050283af8b3740d519319e6f4a801 Mon Sep 17 00:00:00 2001 From: s-ayush2903 Date: Thu, 29 Oct 2020 15:44:13 +0530 Subject: [PATCH] Made Reliable Assertion on LibraryScreen and added few Robots Added Robots for LZimHost, Reader and Bookmarks --- .../kiwix/kiwixmobile/main/KiwixMainRobot.kt | 16 +++++--- .../nav/destination/LibraryRobot.kt | 3 +- .../nav/destination/reader/ReaderRobot.kt | 36 ++++++++++++++++++ .../page/bookmarks/BookmarksRobot.kt | 7 ++++ .../kiwixmobile/webserver/ZimHostRobot.kt | 37 +++++++++++++++++++ 5 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/reader/ReaderRobot.kt create mode 100644 app/src/androidTest/java/org/kiwix/kiwixmobile/webserver/ZimHostRobot.kt diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/main/KiwixMainRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/main/KiwixMainRobot.kt index 007735da9..edee40b6b 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/main/KiwixMainRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/main/KiwixMainRobot.kt @@ -30,12 +30,17 @@ import org.kiwix.kiwixmobile.nav.destination.LibraryRobot import org.kiwix.kiwixmobile.nav.destination.OnlineLibraryRobot import org.kiwix.kiwixmobile.nav.destination.library import org.kiwix.kiwixmobile.nav.destination.onlineLibrary +import org.kiwix.kiwixmobile.nav.destination.reader.ReaderRobot +import org.kiwix.kiwixmobile.nav.destination.reader.reader import org.kiwix.kiwixmobile.page.bookmarks.BookmarksRobot import org.kiwix.kiwixmobile.page.bookmarks.bookmarks import org.kiwix.kiwixmobile.page.history.HistoryRobot import org.kiwix.kiwixmobile.page.history.history import org.kiwix.kiwixmobile.settings.SettingsRobot +import org.kiwix.kiwixmobile.settings.settingsRobo import org.kiwix.kiwixmobile.testutils.TestUtils.getResourceString +import org.kiwix.kiwixmobile.webserver.ZimHostRobot +import org.kiwix.kiwixmobile.webserver.zimHost fun kiwixMainRobo(func: KiwixMainRobot.() -> Unit) = KiwixMainRobot().applyWithViewHierarchyPrinting(func) @@ -46,10 +51,9 @@ class KiwixMainRobot : BaseRobot() { isVisible(ViewId(R.id.navigation_container)) } - fun clickReaderOnBottomNav(func: LibraryRobot.() -> Unit) { + fun clickReaderOnBottomNav(func: ReaderRobot.() -> Unit) { clickOn(ViewId(R.id.readerFragment)) - isVisible(Text(getResourceString(R.string.reader))) - library(func) + reader(func) } fun clickLibraryOnBottomNav(func: LibraryRobot.() -> Unit) { @@ -83,15 +87,15 @@ class KiwixMainRobot : BaseRobot() { pressBack() } - fun clickHostBooksOnSideNav(func: KiwixMainRobot.() -> Unit) { + fun clickHostBooksOnSideNav(func: ZimHostRobot.() -> Unit) { clickOn(Text(getResourceString(R.string.menu_host_books))) - isVisible(Text(getResourceString(R.string.menu_host_books))) + zimHost(func) pressBack() } fun clickSettingsOnSideNav(func: SettingsRobot.() -> Unit) { clickOn(Text(getResourceString(R.string.menu_settings))) - isVisible(Text(getResourceString(R.string.menu_settings))) + settingsRobo(func) pressBack() } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/LibraryRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/LibraryRobot.kt index 227f4928a..f5c89e1b9 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/LibraryRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/LibraryRobot.kt @@ -35,7 +35,7 @@ fun library(func: LibraryRobot.() -> Unit) = LibraryRobot().applyWithViewHierarc class LibraryRobot : BaseRobot() { init { - isVisible(Text(getResourceString(R.string.library))) + isVisible(ViewId(R.id.get_zim_nearby_device)) } } @@ -53,4 +53,3 @@ class OnlineLibraryRobot : BaseRobot() { language(func) } } - diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/reader/ReaderRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/reader/ReaderRobot.kt new file mode 100644 index 000000000..5568423a4 --- /dev/null +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/reader/ReaderRobot.kt @@ -0,0 +1,36 @@ +/* + * 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.nav.destination.reader + +import applyWithViewHierarchyPrinting +import org.kiwix.kiwixmobile.BaseRobot +import org.kiwix.kiwixmobile.Findable.StringId.TextId +import org.kiwix.kiwixmobile.R + +/** + * Authored by Ayush Shrivastava on 29/10/20 + */ + +fun reader(func: ReaderRobot.() -> Unit) = ReaderRobot().applyWithViewHierarchyPrinting(func) + +class ReaderRobot : BaseRobot() { + init { + isVisible(TextId(R.string.reader)) + } +} diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/page/bookmarks/BookmarksRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/page/bookmarks/BookmarksRobot.kt index 12a1528b8..8131baf3b 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/page/bookmarks/BookmarksRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/page/bookmarks/BookmarksRobot.kt @@ -19,7 +19,9 @@ package org.kiwix.kiwixmobile.page.bookmarks import applyWithViewHierarchyPrinting +import com.schibsted.spain.barista.assertion.BaristaVisibilityAssertions.assertDisplayed import org.kiwix.kiwixmobile.BaseRobot +import org.kiwix.kiwixmobile.Findable import org.kiwix.kiwixmobile.Findable.StringId.ContentDesc import org.kiwix.kiwixmobile.Findable.Text import org.kiwix.kiwixmobile.R @@ -34,6 +36,11 @@ fun bookmarks(func: BookmarksRobot.() -> Unit) = class BookmarksRobot : BaseRobot() { /** Pushed back robot rules due to lack of info to assert the correct screen */ + init { + assertDisplayed(R.string.bookmarks_from_current_book) + // isVisible(Findable.StringId.TextId(R.string.bookmarks_from_current_book)) + } + fun clickOnTrashIcon() { clickOn(ContentDesc(R.string.pref_clear_all_bookmarks_title)) } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/webserver/ZimHostRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/webserver/ZimHostRobot.kt new file mode 100644 index 000000000..024aab3cb --- /dev/null +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/webserver/ZimHostRobot.kt @@ -0,0 +1,37 @@ +/* + * 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.webserver + +import applyWithViewHierarchyPrinting +import org.kiwix.kiwixmobile.BaseRobot +import org.kiwix.kiwixmobile.Findable +import org.kiwix.kiwixmobile.R +import org.kiwix.kiwixmobile.testutils.TestUtils + +/** + * Authored by Ayush Shrivastava on 29/10/20 + */ + +fun zimHost(func: ZimHostRobot.() -> Unit) = ZimHostRobot().applyWithViewHierarchyPrinting(func) + +class ZimHostRobot : BaseRobot() { + init { + isVisible(Findable.Text(TestUtils.getResourceString(R.string.menu_host_books))) + } +}