-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create calendar page layout and set up navigation (#25)
* Added Basic Calendar Cycle Top Bar * added dependencies * Styled Calendar Cycle Top Bar * Changed TopBar to use tabs, added navigation * setup basic navigation bar and graph * added calender navgiation to FAB * modularized BottomNav * modularized FAB * moved Screen enum to NavigationGraph * Added Swiping to tabs, comments * cleanup * removed unused icon * Updated Indicator Color * removed unused colors * added dependencies and tests * Added activity to manifest - temp fix so tests run Was seeing the following issues when I run tests in NavigationTest: - android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.theperiodpurse.test/androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>? - android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.theperiodpurse.test/androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>? Referred to android/android-test#196 for the fix. Looks like this is fixed in androidx.test:core:1.5.0-alpha02. * removed changes to manifest * added androidTestResultsUserPreferences to gitignore * added useful contentDescription to FAB * added instrumental tests to CI * added emulator use to workflow * fixed typo in ci * test with macOS * specify system image * Added content description for testing * Added content description for testing * Added testing for tabs * added check to hide navigation bar during onboarding * better implementation for hiding nav bar * bandaid fix for tests * fix tests * create different screen to start in Calendar page * added skipOnboarding option to AppScreen * popback stack after onboarding * #3 Created the Calendar Layout (#33) * Added basic calendar setup to the screen * Changed the minSDK in Project Configs * Updated Visuals to look like original app * Added Click Functionality * Revert "#3 Created the Calendar Layout (#33)" (#38) This reverts commit 18909c4. Co-authored-by: Pierre-William Lessard <lessardpw@gmail.com> Co-authored-by: Madeline <93456777+madelahn@users.noreply.github.com>
- Loading branch information
1 parent
9cabca7
commit 4a8f501
Showing
17 changed files
with
694 additions
and
95 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
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
119 changes: 119 additions & 0 deletions
119
app/src/androidTest/java/com/example/theperiodpurse/CalendarCycleTabTest.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,119 @@ | ||
package com.example.theperiodpurse | ||
|
||
import androidx.activity.ComponentActivity | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.test.* | ||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.navigation.compose.ComposeNavigator | ||
import androidx.navigation.testing.TestNavHostController | ||
import com.example.theperiodpurse.ui.calendar.CalendarTabItem | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class CalendarCycleTabTest { | ||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<ComponentActivity>() | ||
private lateinit var navController: TestNavHostController | ||
|
||
@Before | ||
fun setupNavHost() { | ||
composeTestRule.setContent { | ||
navController = | ||
TestNavHostController(LocalContext.current) | ||
navController.navigatorProvider.addNavigator( | ||
ComposeNavigator() | ||
) | ||
ScreenApp(navController = navController, skipOnboarding = true) | ||
} | ||
} | ||
|
||
|
||
private fun navigateToCycleScreen() { | ||
composeTestRule.onNodeWithText(CalendarTabItem.CycleTab.title).performClick() | ||
} | ||
|
||
@Test | ||
fun appTabs_clickCalendar_CycleNotDisplayed() { | ||
composeTestRule.onNodeWithContentDescription("Cycle Page").assertIsNotDisplayed() | ||
} | ||
|
||
@Test | ||
fun appTabs_clickCalendar_CalendarDisplayed() { | ||
composeTestRule.onNodeWithContentDescription("Calendar Page").assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun appTabs_clickCalendar_CalendarSelected() { | ||
composeTestRule.onNodeWithText(CalendarTabItem.CalendarTab.title).assertIsSelected() | ||
} | ||
|
||
@Test | ||
fun appTabs_clickCycleTab_DisplaysCycle() { | ||
composeTestRule.onNodeWithText(CalendarTabItem.CycleTab.title).performClick() | ||
|
||
composeTestRule.onNodeWithContentDescription("Cycle Page").assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun appTabs_clickCycleTab_SelectsCycle() { | ||
composeTestRule.onNodeWithText(CalendarTabItem.CycleTab.title).performClick() | ||
|
||
composeTestRule.onNodeWithText(CalendarTabItem.CycleTab.title).assertIsSelected() | ||
} | ||
|
||
@Test | ||
fun appTabs_swipeCalendarPage_DisplaysCycle() { | ||
composeTestRule.onRoot().performTouchInput { | ||
swipeLeft() | ||
} | ||
|
||
composeTestRule.onNodeWithContentDescription("Cycle Page").assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun appTabs_swipeCalendarPage_SelectsCycle() { | ||
composeTestRule.onRoot().performTouchInput { | ||
swipeLeft() | ||
} | ||
|
||
composeTestRule.onNodeWithText(CalendarTabItem.CycleTab.title).assertIsSelected() | ||
} | ||
|
||
@Test | ||
fun appTabs_swipeCyclePage_SelectsCalendar() { | ||
composeTestRule.onRoot().performTouchInput { | ||
swipeLeft() | ||
swipeRight() | ||
} | ||
|
||
composeTestRule.onNodeWithText(CalendarTabItem.CalendarTab.title).assertIsSelected() | ||
} | ||
|
||
@Test | ||
fun appTabs_swipeCyclePage_DisplaysCalendar() { | ||
composeTestRule.onRoot().performTouchInput { | ||
swipeLeft() | ||
swipeRight() | ||
} | ||
|
||
composeTestRule.onNodeWithContentDescription("Calendar Page").assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun appTabs_clickCalendarTab_SelectsCalendar() { | ||
navigateToCycleScreen() | ||
composeTestRule.onNodeWithText(CalendarTabItem.CalendarTab.title).performClick() | ||
|
||
composeTestRule.onNodeWithText(CalendarTabItem.CalendarTab.title).assertIsSelected() | ||
} | ||
|
||
@Test | ||
fun appTabs_clickCalendarTab_DisplaysCalendar() { | ||
navigateToCycleScreen() | ||
composeTestRule.onNodeWithText(CalendarTabItem.CalendarTab.title).performClick() | ||
|
||
composeTestRule.onNodeWithContentDescription("Calendar Page").assertIsDisplayed() | ||
} | ||
|
||
} |
70 changes: 70 additions & 0 deletions
70
app/src/androidTest/java/com/example/theperiodpurse/NavigationTest.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,70 @@ | ||
package com.example.theperiodpurse | ||
|
||
import androidx.activity.ComponentActivity | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.compose.ui.test.onNodeWithContentDescription | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import androidx.navigation.compose.ComposeNavigator | ||
import androidx.navigation.testing.TestNavHostController | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class NavigationTest { | ||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<ComponentActivity>() | ||
private lateinit var navController: TestNavHostController | ||
|
||
@Before | ||
fun setupNavHost() { | ||
composeTestRule.setContent { | ||
navController = | ||
TestNavHostController(LocalContext.current) | ||
navController.navigatorProvider.addNavigator( | ||
ComposeNavigator() | ||
) | ||
ScreenApp(navController = navController, skipOnboarding = true) | ||
} | ||
} | ||
|
||
@Test | ||
fun appNavHost_clickSettings_navigatesToSettingsScreen() { | ||
composeTestRule.onNodeWithText(Screen.Settings.name) | ||
.performClick() | ||
navController.assertCurrentRouteName(Screen.Settings.name) | ||
} | ||
|
||
private fun navigateToSettingsScreen() { | ||
composeTestRule.onNodeWithText(Screen.Settings.name).performClick() | ||
} | ||
|
||
@Test | ||
fun appNavHost_clickSettings_navigatesToInfoScreen() { | ||
composeTestRule.onNodeWithText(Screen.Learn.name) | ||
.performClick() | ||
navController.assertCurrentRouteName(Screen.Learn.name) | ||
} | ||
|
||
private fun navigateToInfoScreen() { | ||
composeTestRule.onNodeWithText(Screen.Learn.name).performClick() | ||
} | ||
|
||
@Test | ||
fun appNavHost_clickCalendarFABOnSettingsScreen_navigatesToCalendarScreen() { | ||
navigateToSettingsScreen() | ||
composeTestRule.onNodeWithContentDescription("Navigate to Calendar page") | ||
.performClick() | ||
navController.assertCurrentRouteName(Screen.Calendar.name) | ||
} | ||
|
||
@Test | ||
fun appNavHost_clickCalendarFABOnInfoScreen_navigatesToCalendarScreen() { | ||
navigateToInfoScreen() | ||
composeTestRule.onNodeWithContentDescription("Navigate to Calendar page") | ||
.performClick() | ||
navController.assertCurrentRouteName(Screen.Calendar.name) | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
app/src/androidTest/java/com/example/theperiodpurse/ScreenAssertions.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,8 @@ | ||
package com.example.theperiodpurse | ||
|
||
import androidx.navigation.NavController | ||
import org.junit.Assert.assertEquals | ||
|
||
fun NavController.assertCurrentRouteName(expectedRouteName: String) { | ||
assertEquals(expectedRouteName, currentBackStackEntry?.destination?.route) | ||
} |
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.