-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added viewing the list of servers on Android [#3]
- Loading branch information
Showing
12 changed files
with
630 additions
and
33 deletions.
There are no files selected for viewing
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
85 changes: 85 additions & 0 deletions
85
...riant/src/androidTest/java/org/comixedproject/variant/android/view/main/HomeViewKtTest.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,85 @@ | ||
/* | ||
* Variant - A digital comic book reading application for the iPad and Android tablets. | ||
* Copyright (C) 2024, The ComiXed Project | ||
* | ||
* 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.comixedproject.variant.android.view.main | ||
|
||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import org.comixedproject.variant.android.VariantTheme | ||
import org.comixedproject.variant.model.OPDSServer | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class HomeViewKtTest { | ||
val SERVER_LIST = listOf<OPDSServer>( | ||
OPDSServer( | ||
"1", | ||
"Home Server", | ||
"http://comixedproject.org:7171/opds", | ||
"[email protected]", | ||
"my!password" | ||
) | ||
) | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun testHomeViewHasTitle() { | ||
composeTestRule.setContent { | ||
VariantTheme { | ||
HomeView(serverList = SERVER_LIST) | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag(TAG_TITLE_TEXT).assertExists() | ||
} | ||
|
||
@Test | ||
fun testHomeViewHasBottomBar() { | ||
composeTestRule.setContent { | ||
VariantTheme { | ||
HomeView(serverList = SERVER_LIST) | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag(TAG_BOTTOM_BAR).assertExists() | ||
} | ||
|
||
@Test | ||
fun testHomeViewHasAddServerButton() { | ||
composeTestRule.setContent { | ||
VariantTheme { | ||
HomeView(serverList = SERVER_LIST) | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag(TAG_ADD_SERVER_BUTTON).assertExists() | ||
} | ||
|
||
@Test | ||
fun testHomeViewHasAddServerList() { | ||
composeTestRule.setContent { | ||
VariantTheme { | ||
HomeView(serverList = SERVER_LIST) | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag(TAG_SERVER_LIST).assertExists() | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
...nt/src/androidTest/java/org/comixedproject/variant/android/view/opds/ServerEntryKtTest.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,73 @@ | ||
/* | ||
* Variant - A digital comic book reading application for the iPad and Android tablets. | ||
* Copyright (C) 2024, The ComiXed Project | ||
* | ||
* 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.comixedproject.variant.android.view.opds | ||
|
||
import androidx.compose.ui.test.assertTextContains | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import org.comixedproject.variant.android.VariantTheme | ||
import org.comixedproject.variant.model.OPDSServer | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class ServerEntryKtTest { | ||
val SERVER = OPDSServer( | ||
"1", | ||
"Home Server", | ||
"http://comixedproject.org:7171/opds", | ||
"[email protected]", | ||
"my!password" | ||
) | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun testServerEntryServerName() { | ||
composeTestRule.setContent { | ||
VariantTheme { | ||
ServerEntry(server = SERVER) | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag(TAG_SERVER_NAME).assertTextContains(SERVER.name) | ||
} | ||
|
||
@Test | ||
fun testServerEntryServerUrl() { | ||
composeTestRule.setContent { | ||
VariantTheme { | ||
ServerEntry(server = SERVER) | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag(TAG_SERVER_URL).assertTextContains(SERVER.url) | ||
} | ||
|
||
@Test | ||
fun testServerEntryUsername() { | ||
composeTestRule.setContent { | ||
VariantTheme { | ||
ServerEntry(server = SERVER) | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag(TAG_USERNAME).assertTextContains(SERVER.username) | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...ant/src/androidTest/java/org/comixedproject/variant/android/view/opds/ServerListKtTest.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,52 @@ | ||
/* | ||
* Variant - A digital comic book reading application for the iPad and Android tablets. | ||
* Copyright (C) 2024, The ComiXed Project | ||
* | ||
* 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.comixedproject.variant.android.view.opds | ||
|
||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import org.comixedproject.variant.android.VariantTheme | ||
import org.comixedproject.variant.model.OPDSServer | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class ServerListKtTest { | ||
val SERVER_LIST = listOf<OPDSServer>( | ||
OPDSServer( | ||
"1", | ||
"Home Server", | ||
"http://comixedproject.org:7171/opds", | ||
"[email protected]", | ||
"my!password" | ||
) | ||
) | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun testServerList() { | ||
composeTestRule.setContent { | ||
VariantTheme { | ||
ServerList(serverList = SERVER_LIST) | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag(TAG_SERVER_LIST_COLUMN).assertExists() | ||
} | ||
} |
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 |
---|---|---|
|
@@ -21,38 +21,54 @@ package org.comixedproject.variant.android | |
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.material3.* | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import org.comixedproject.variant.Greeting | ||
import org.comixedproject.variant.android.view.main.HomeView | ||
import org.comixedproject.variant.model.OPDSServer | ||
|
||
class MainActivity : ComponentActivity() { | ||
val serverList = listOf( | ||
OPDSServer( | ||
"1", | ||
"Server 1", | ||
"http://comixedproject.org:7171/opds", | ||
"[email protected]", | ||
"my!password" | ||
), | ||
OPDSServer( | ||
"2", | ||
"Server 2", | ||
"http://comixedproject.org:7171/opds", | ||
"[email protected]", | ||
"my!password" | ||
), | ||
OPDSServer( | ||
"3", | ||
"Server 3", | ||
"http://comixedproject.org:7171/opds", | ||
"[email protected]", | ||
"my!password" | ||
), | ||
OPDSServer( | ||
"4", | ||
"Server 4", | ||
"http://comixedproject.org:7171/opds", | ||
"[email protected]", | ||
"my!password" | ||
), | ||
OPDSServer( | ||
"5", | ||
"Server 5", | ||
"http://comixedproject.org:7171/opds", | ||
"[email protected]", | ||
"my!password" | ||
), | ||
) | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
MyApplicationTheme { | ||
Surface( | ||
modifier = Modifier.fillMaxSize(), | ||
color = MaterialTheme.colorScheme.background | ||
) { | ||
GreetingView(Greeting().greet()) | ||
} | ||
VariantTheme { | ||
HomeView(serverList) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun GreetingView(text: String) { | ||
Text(text = text) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun DefaultPreview() { | ||
MyApplicationTheme { | ||
GreetingView("Hello, Android!") | ||
} | ||
} | ||
} |
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
Oops, something went wrong.