Skip to content

Commit

Permalink
Merge pull request #24 from LookUpGroup27/feature/landing-page-star-m…
Browse files Browse the repository at this point in the history
…ap-P1

feat: implement landing page with logo and navigation
  • Loading branch information
raniabbrk authored Oct 14, 2024
2 parents 42bc06a + d8fb6aa commit b166837
Show file tree
Hide file tree
Showing 17 changed files with 312 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
target: google_apis
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
emulator-options: -no-window -gpu off -noaudio -no-boot-anim
disable-animations: false
script: echo "Generated AVD snapshot for caching."

Expand Down
146 changes: 73 additions & 73 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -122,81 +122,81 @@ fun DependencyHandlerScope.globalTestImplementation(dep: Any) {

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.navigation.runtime.ktx)

// Jetpack Compose BOM
val composeBom = platform(libs.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

// Jetpack Compose
implementation(libs.compose.ui)
implementation(libs.compose.ui.graphics)
implementation(libs.compose.material3)
implementation(libs.compose.activity)
implementation(libs.compose.viewmodel)
implementation(libs.compose.preview)
debugImplementation(libs.compose.tooling)
androidTestImplementation(libs.compose.test.junit)
debugImplementation(libs.compose.test.manifest)

// Kaspresso test framework
androidTestImplementation(libs.kaspresso)
androidTestImplementation(libs.kaspresso.compose)

// Robolectric
testImplementation(libs.robolectric)

// Firebase
implementation(libs.firebase.database.ktx)
implementation(libs.firebase.firestore)
implementation(libs.firebase.ui.auth)
implementation(libs.firebase.auth.ktx)

// Navigation
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)

// Unit Testing
testImplementation(libs.junit)
androidTestImplementation(libs.mockk)
androidTestImplementation(libs.mockk.android)
androidTestImplementation(libs.mockk.agent)
testImplementation(libs.json)

// UI Testing
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.androidx.espresso.intents)
androidTestImplementation(libs.androidx.ui.test.junit4)
androidTestImplementation(platform(libs.androidx.compose.bom))
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.kotlin)
androidTestImplementation(libs.mockito.android)
androidTestImplementation(libs.mockito.kotlin)
testImplementation(libs.robolectric)

// Kaspresso Allure
androidTestImplementation(libs.kaspresso.allure.support)
androidTestImplementation(libs.kaspresso.compose.support)

// Coroutines Testing
testImplementation(libs.kotlinx.coroutines.test)

// Networking with OkHttp
implementation(libs.okhttp)

// Calendar
implementation(libs.ical4j)
implementation(libs.compose)
implementation("com.prolificinteractive:material-calendarview:1.4.3") {
exclude(group = "com.android.support", module = "support-v4")
}
val composeBom = platform(libs.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

// Jetpack Compose
implementation(libs.compose.ui)
implementation(libs.compose.ui.graphics)
implementation(libs.compose.material3)
implementation(libs.compose.activity)
implementation(libs.compose.viewmodel)
implementation(libs.compose.preview)
debugImplementation(libs.compose.tooling)
androidTestImplementation(libs.compose.test.junit)
debugImplementation(libs.compose.test.manifest)

// Kaspresso test framework
androidTestImplementation(libs.kaspresso)
androidTestImplementation(libs.kaspresso.compose)

// Robolectric
testImplementation(libs.robolectric)

// Firebase
implementation(libs.firebase.database.ktx)
implementation(libs.firebase.firestore)
implementation(libs.firebase.ui.auth)
implementation(libs.firebase.auth.ktx)

// Navigation
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)

// Unit Testing
testImplementation(libs.junit)
androidTestImplementation(libs.mockk)
androidTestImplementation(libs.mockk.android)
androidTestImplementation(libs.mockk.agent)
testImplementation(libs.json)

// UI Testing
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.androidx.espresso.intents)
androidTestImplementation(libs.androidx.ui.test.junit4)
androidTestImplementation(platform(libs.androidx.compose.bom))
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.kotlin)
androidTestImplementation(libs.mockito.android)
androidTestImplementation(libs.mockito.kotlin)
testImplementation(libs.robolectric)

// Kaspresso Allure
androidTestImplementation(libs.kaspresso.allure.support)
androidTestImplementation(libs.kaspresso.compose.support)

// Coroutines Testing
testImplementation(libs.kotlinx.coroutines.test)

// Networking with OkHttp
implementation(libs.okhttp)

// Calendar
implementation(libs.ical4j)
implementation(libs.compose)
implementation("com.prolificinteractive:material-calendarview:1.4.3") {
exclude(group = "com.android.support", module = "support-v4")
}
}

tasks.withType<Test> {
Expand Down Expand Up @@ -235,4 +235,4 @@ tasks.register("jacocoTestReport", JacocoReport::class) {
include("outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec")
include("outputs/code_coverage/debugAndroidTest/connected/*/coverage.ec")
})
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.github.lookupgroup27.lookup.overview

import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.espresso.intent.Intents
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.lookupgroup27.lookup.MainActivity
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class LandingScreenTest {

@get:Rule val composeTestRule = createAndroidComposeRule<MainActivity>()

@Before
fun setUp() {
// Initialize Espresso Intents to capture and validate outgoing intents
Intents.init()
}

@After
fun tearDown() {
// Release Espresso Intents after tests
Intents.release()
}

@Test
fun logoAndButtonAreDisplayed() {
// Verify that the Look Up logo is displayed
composeTestRule.onNodeWithContentDescription("Look Up Logo").assertIsDisplayed()

// Verify that the Home button is displayed and clickable
composeTestRule.onNodeWithContentDescription("Home Icon").assertIsDisplayed()
composeTestRule.onNodeWithContentDescription("Home Icon").assertHasClickAction()
}

@Test
fun backgroundIsClickableAndNavigatesToMap() {
// Verify that the background image is displayed and clickable
composeTestRule.onNodeWithContentDescription("Background").assertIsDisplayed()
composeTestRule.onNodeWithContentDescription("Background").assertHasClickAction()

// Perform click action on the background image
composeTestRule.onNodeWithContentDescription("Background").performClick()

// Wait for the UI to settle after the click
composeTestRule.waitForIdle()

// Assert that the Map screen is displayed by checking for specific text or UI elements
composeTestRule.onNodeWithText("This is the Map screen.").assertIsDisplayed()
}

@Test
fun homeButtonIsClickable() {
// Perform click action on the home button using its testTag
composeTestRule.onNodeWithTag("Home Icon").performClick()

// Wait for the UI to settle after the click
composeTestRule.waitForIdle()

// Assert that the Menu screen is displayed by checking for specific text
composeTestRule.onNodeWithText("This is the Menu screen.").assertIsDisplayed()
}

@Test
fun testMapViewPromptIsDisplayed() {
// Assert that it is displayed
composeTestRule.onNodeWithText("Click for full map view").assertIsDisplayed()
}
}
48 changes: 32 additions & 16 deletions app/src/main/java/com/github/lookupgroup27/lookup/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.semantics.*
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.compose.*
import androidx.navigation.navigation
import com.github.lookupgroup27.lookup.model.calendar.CalendarViewModel
import com.github.lookupgroup27.lookup.resources.C
import com.github.lookupgroup27.lookup.ui.map.MapScreen
import com.github.lookupgroup27.lookup.ui.navigation.*
import com.github.lookupgroup27.lookup.ui.overview.*
import com.github.lookupgroup27.lookup.ui.theme.SampleAppTheme

class MainActivity : ComponentActivity() {
Expand All @@ -24,20 +27,33 @@ class MainActivity : ComponentActivity() {
Surface(
modifier = Modifier.fillMaxSize().semantics { testTag = C.Tag.main_screen_container },
color = MaterialTheme.colorScheme.background) {
Greeting("Android")
LookUpApp()
}
}
}
}
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(text = "Hello $name!", modifier = modifier.semantics { testTag = C.Tag.greeting })
}
@Composable
fun LookUpApp() {
val navController = rememberNavController()
val navigationActions = NavigationActions(navController)
val calendarViewModel: CalendarViewModel = viewModel()

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
SampleAppTheme { Greeting("Android") }
NavHost(navController = navController, startDestination = Route.LANDING) {
navigation(
startDestination = Screen.LANDING,
route = Route.LANDING,
) {
composable(Screen.LANDING) { LandingScreen(navigationActions) }
}
navigation(startDestination = Screen.MENU, route = Route.MENU) {
composable(Screen.MENU) { MenuScreen(navigationActions) }
composable(Screen.QUIZ) { QuizScreen(navigationActions) }
composable(Screen.CALENDAR) { CalendarScreen(calendarViewModel, navigationActions) }
}
navigation(startDestination = Screen.MAP, route = Route.MAP) {
composable(Screen.MAP) { MapScreen(navigationActions) }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.github.lookupgroup27.lookup.ui.map

import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import com.github.lookupgroup27.lookup.ui.navigation.NavigationActions

@Composable fun MapScreen() {}
@Composable
fun MapScreen(navigationActions: NavigationActions) {
Text(text = "This is the Map screen.")
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ object Route {
const val PROFILE = "Profile"
const val MENU = "Menu"
const val COLLECTION = "Collection"
const val LANDING = "Landing"
}

object Screen {
Expand All @@ -27,6 +28,7 @@ object Screen {
const val PROFILE = "Profile Screen"
const val MENU = "Menu Screen"
const val COLLECTION = "Collection Screen"
const val LANDING = "Landing Screen"
}

data class TopLevelDestination(val route: String, val icon: ImageVector, val textId: String)
Expand Down
Loading

0 comments on commit b166837

Please sign in to comment.