Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions app/src/androidTest/java/com/github/se/gomeet/endtoend/EndToEnd.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.GrantPermissionRule
import com.github.se.gomeet.MainActivity
import com.github.se.gomeet.R
import com.github.se.gomeet.model.event.Event
import com.github.se.gomeet.model.repository.EventRepository
import com.github.se.gomeet.model.repository.UserRepository
import com.github.se.gomeet.screens.CreateEventScreen
import com.github.se.gomeet.screens.CreateScreen
import com.github.se.gomeet.screens.EventsScreen
Expand All @@ -29,6 +32,7 @@ import com.google.firebase.ktx.Firebase
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase
import io.github.kakaocup.compose.node.element.ComposeScreen
import io.github.kakaocup.kakao.common.utilities.getResourceString
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.tasks.await
Expand Down Expand Up @@ -87,12 +91,19 @@ class EndToEndTest : TestCase() {
@JvmStatic
fun tearDown() = runBlocking {

// Clean up the event
eventVM.getAllEvents()?.forEach { eventVM.removeEvent(it.eventID) }
// Clean up the user
// Clean up the events
val events = mutableListOf<Event>()
val latch = CountDownLatch(1)
eventVM.getAllEvents {
if (it != null) {
events.addAll(it)
latch.countDown()
}
}
assert(latch.await(3, TimeUnit.SECONDS))
events.forEach { event -> EventRepository.removeEvent(event.eventID) } // Clean up the user
UserRepository.removeUser(uid)
Firebase.auth.currentUser?.delete()?.await()
userVM.deleteUser(uid)

return@runBlocking
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.GrantPermissionRule
import com.github.se.gomeet.MainActivity
import com.github.se.gomeet.R
import com.github.se.gomeet.model.event.Event
import com.github.se.gomeet.model.event.location.Location
import com.github.se.gomeet.model.repository.EventRepository
import com.github.se.gomeet.model.repository.UserRepository
import com.github.se.gomeet.screens.EventInfoScreen
import com.github.se.gomeet.screens.ExploreScreen
import com.github.se.gomeet.screens.FollowScreen
Expand All @@ -35,6 +38,7 @@ import io.github.kakaocup.compose.node.element.ComposeScreen
import io.github.kakaocup.kakao.common.utilities.getResourceString
import java.time.LocalDate
import java.time.LocalTime
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.tasks.await
Expand Down Expand Up @@ -170,13 +174,21 @@ class EndToEndTest2 : TestCase() {
@AfterClass
@JvmStatic
fun tearDown() = runBlocking {
// clean up the event
eventVM.getAllEvents()?.forEach { eventVM.removeEvent(it.eventID) }

// clean up the events
val events = mutableListOf<Event>()
val latch = CountDownLatch(1)
eventVM.getAllEvents {
if (it != null) {
events.addAll(it)
latch.countDown()
}
}
assert(latch.await(3, TimeUnit.SECONDS))
events.forEach { event -> EventRepository.removeEvent(event.eventID) }
// clean up the users
Firebase.auth.currentUser?.delete()?.await()
userVM.deleteUser(uid1)
userVM.deleteUser(uid2)
UserRepository.removeUser(uid1)
UserRepository.removeUser(uid2)
Firebase.auth.signInWithEmailAndPassword(email1, pwd1).await()
Firebase.auth.currentUser?.delete()?.await()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.GrantPermissionRule
import com.github.se.gomeet.MainActivity
import com.github.se.gomeet.R
import com.github.se.gomeet.model.event.Event
import com.github.se.gomeet.model.event.location.Location
import com.github.se.gomeet.model.repository.EventRepository
import com.github.se.gomeet.model.repository.UserRepository
import com.github.se.gomeet.screens.AddParticipantsScreen
import com.github.se.gomeet.screens.CreateEventScreen
import com.github.se.gomeet.screens.CreateScreen
Expand All @@ -38,6 +41,7 @@ import io.github.kakaocup.compose.node.element.ComposeScreen
import io.github.kakaocup.kakao.common.utilities.getResourceString
import java.time.LocalDate
import java.time.LocalTime
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.tasks.await
Expand Down Expand Up @@ -155,13 +159,21 @@ class EndToEndTest3 : TestCase() {
@JvmStatic
fun tearDown() = runBlocking {

// clean up the event
eventVM.getAllEvents()?.forEach { eventVM.removeEvent(it.eventID) }

// clean up the events
val events = mutableListOf<Event>()
val latch = CountDownLatch(1)
eventVM.getAllEvents {
if (it != null) {
events.addAll(it)
latch.countDown()
}
}
assert(latch.await(3, TimeUnit.SECONDS))
events.forEach { event -> EventRepository.removeEvent(event.eventID) }
// clean up the users
UserRepository.removeUser(uid1)
UserRepository.removeUser(uid2)
Firebase.auth.currentUser?.delete()?.await()
userVM.deleteUser(uid1)
userVM.deleteUser(uid2)
Firebase.auth.signInWithEmailAndPassword(email2, pwd2).await()
Firebase.auth.currentUser?.delete()?.await()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.github.se.gomeet.R
import com.github.se.gomeet.model.event.Event
import com.github.se.gomeet.model.event.location.Location
import com.github.se.gomeet.model.repository.EventRepository
import com.github.se.gomeet.model.repository.UserRepository
import com.github.se.gomeet.ui.navigation.NavigationActions
import com.github.se.gomeet.viewmodel.EventViewModel
import com.github.se.gomeet.viewmodel.UserViewModel
Expand All @@ -24,6 +27,7 @@ import com.google.firebase.ktx.Firebase
import io.github.kakaocup.kakao.common.utilities.getResourceString
import java.time.LocalDate
import java.time.LocalTime
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.tasks.await
Expand Down Expand Up @@ -105,12 +109,20 @@ class SearchModuleTest {
@AfterClass
@JvmStatic
fun tearDown() = runBlocking {
// Clean up the event
eventVM.getAllEvents()?.forEach { eventVM.removeEvent(it.eventID) }

UserRepository.removeUser(uid)
// Clean up the events
val events = mutableListOf<Event>()
val latch = CountDownLatch(1)
eventVM.getAllEvents {
if (it != null) {
events.addAll(it)
latch.countDown()
}
}
assert(latch.await(3, TimeUnit.SECONDS))
events.forEach { event -> EventRepository.removeEvent(event.eventID) }
// Clean up the user
Firebase.auth.currentUser?.delete()?.await()
userVM.deleteUser(uid)

return@runBlocking
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import androidx.compose.ui.test.performTextInput
import androidx.navigation.compose.rememberNavController
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.se.gomeet.R
import com.github.se.gomeet.model.event.Event
import com.github.se.gomeet.model.repository.EventRepository
import com.github.se.gomeet.ui.navigation.NavigationActions
import com.github.se.gomeet.viewmodel.EventCreationViewModel
import com.github.se.gomeet.viewmodel.EventViewModel
import com.github.se.gomeet.viewmodel.UserViewModel
import io.github.kakaocup.kakao.common.utilities.getResourceString
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.runBlocking
import org.junit.AfterClass
import org.junit.Rule
Expand All @@ -37,14 +41,21 @@ class CreateEventTest {
fun tearDown() = runBlocking {

// Clean up the events
eventVM.getAllEvents()?.forEach { eventVM.removeEvent(it.eventID) }

return@runBlocking
val events = mutableListOf<Event>()
val latch = CountDownLatch(1)
eventVM.getAllEvents {
if (it != null) {
events.addAll(it)
latch.countDown()
}
}
assert(latch.await(3, TimeUnit.SECONDS))
events.forEach { event -> EventRepository.removeEvent(event.eventID) }
}
}

@Test
fun testCratePrivateEvent() {
fun testCreatePrivateEvent() {
val eventVM = EventViewModel(uid)

composeTestRule.setContent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ import androidx.compose.ui.test.performScrollTo
import androidx.navigation.compose.rememberNavController
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.se.gomeet.R
import com.github.se.gomeet.model.event.Event
import com.github.se.gomeet.model.event.location.Location
import com.github.se.gomeet.model.repository.EventRepository
import com.github.se.gomeet.model.repository.UserRepository
import com.github.se.gomeet.ui.navigation.NavigationActions
import com.github.se.gomeet.viewmodel.EventViewModel
import com.github.se.gomeet.viewmodel.UserViewModel
import io.github.kakaocup.kakao.common.utilities.getResourceString
import java.time.LocalDate
import java.time.LocalTime
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.runBlocking
import org.junit.AfterClass
Expand All @@ -32,11 +36,16 @@ class EditEventTest {

companion object {
private lateinit var eventUid: String
private val eventVM = EventViewModel("")
private val uid = "EditEventTestUserUid"
private val eventVM = EventViewModel(uid)
private val userVM = UserViewModel(uid)

@JvmStatic
@BeforeClass
fun setup() = runBlocking {
// Create a user
userVM.createUserIfNew(uid, "uname", "fn", "ln", "email", "phone", "country")

// Create an event
eventVM.createEvent(
"title",
Expand All @@ -57,18 +66,25 @@ class EditEventTest {
UserViewModel(""),
"eventid")

while (eventVM.getAllEvents()!!.isEmpty()) {
TimeUnit.SECONDS.sleep(1)
}

eventUid = eventVM.getAllEvents()!![0].eventID
eventVM.getAllEvents { if (it != null) eventUid = it[0].eventID }
}

@AfterClass
@JvmStatic
fun tearDown() = runBlocking {
// Clean up the event
eventVM.getAllEvents()?.forEach { eventVM.removeEvent(it.eventID) }
// Clean up the user
UserRepository.removeUser(uid)
// Clean up the events
val events = mutableListOf<Event>()
val latch = CountDownLatch(1)
eventVM.getAllEvents {
if (it != null) {
events.addAll(it)
latch.countDown()
}
}
assert(latch.await(3, TimeUnit.SECONDS))
events.forEach { event -> EventRepository.removeEvent(event.eventID) }

return@runBlocking
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import androidx.compose.ui.test.junit4.createComposeRule
import androidx.navigation.compose.rememberNavController
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.se.gomeet.R
import com.github.se.gomeet.model.event.Event
import com.github.se.gomeet.model.event.location.Location
import com.github.se.gomeet.model.repository.EventRepository
import com.github.se.gomeet.model.repository.UserRepository
import com.github.se.gomeet.ui.navigation.NavigationActions
import com.github.se.gomeet.viewmodel.EventViewModel
import com.github.se.gomeet.viewmodel.UserViewModel
Expand All @@ -14,6 +17,8 @@ import com.google.firebase.ktx.Firebase
import io.github.kakaocup.kakao.common.utilities.getResourceString
import java.time.LocalDate
import java.time.LocalTime
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.tasks.await
import org.junit.AfterClass
Expand Down Expand Up @@ -87,12 +92,20 @@ class EventsTest {
@AfterClass
@JvmStatic
fun tearDown() = runBlocking {
// Clean up the event
eventVM.getAllEvents()?.forEach { eventVM.removeEvent(it.eventID) }

// Clean up the events
val events = mutableListOf<Event>()
val latch = CountDownLatch(1)
eventVM.getAllEvents {
if (it != null) {
events.addAll(it)
latch.countDown()
}
}
assert(latch.await(3, TimeUnit.SECONDS))
events.forEach { event -> EventRepository.removeEvent(event.eventID) }
// Clean up the user
UserRepository.removeUser(uid)
Firebase.auth.currentUser?.delete()?.await()
userVM.deleteUser(uid)

return@runBlocking
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.ui.test.performClick
import androidx.navigation.compose.rememberNavController
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.se.gomeet.R
import com.github.se.gomeet.model.repository.UserRepository
import com.github.se.gomeet.ui.navigation.NavigationActions
import com.github.se.gomeet.viewmodel.UserViewModel
import com.google.firebase.auth.ktx.auth
Expand Down Expand Up @@ -75,9 +76,9 @@ class AddFriendTest {
fun tearDown() = runBlocking {

// Clean up the users
Firebase.auth.currentUser?.delete()
userVM.deleteUser(uid1)
userVM.deleteUser(uid2)
UserRepository.removeUser(uid1)
UserRepository.removeUser(uid2)
Firebase.auth.currentUser?.delete()?.await()

return@runBlocking
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.ui.test.performTextInput
import androidx.navigation.compose.rememberNavController
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.se.gomeet.R
import com.github.se.gomeet.model.repository.UserRepository
import com.github.se.gomeet.ui.navigation.NavigationActions
import com.github.se.gomeet.viewmodel.UserViewModel
import com.google.firebase.auth.ktx.auth
Expand Down Expand Up @@ -58,8 +59,8 @@ class EditProfileTest {
@JvmStatic
fun tearDown() = runBlocking {
// Clean up the user
UserRepository.removeUser(uid)
Firebase.auth.currentUser!!.delete().await()
userVM.deleteUser(uid)

return@runBlocking
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import androidx.navigation.compose.rememberNavController
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.se.gomeet.R
import com.github.se.gomeet.model.event.location.Location
import com.github.se.gomeet.model.repository.EventRepository
import com.github.se.gomeet.model.repository.UserRepository
import com.github.se.gomeet.ui.mainscreens.notifications.Notifications
import com.github.se.gomeet.ui.navigation.NavigationActions
import com.github.se.gomeet.viewmodel.EventViewModel
Expand Down Expand Up @@ -92,8 +94,8 @@ class NotificationsTest {
@JvmStatic
fun tearDown() = runBlocking {
// Clean up the user and the event
userVM.deleteUser(uid1)
eventVM.removeEvent(eventId)
UserRepository.removeUser(uid1)
EventRepository.removeEvent(eventId)

return@runBlocking
}
Expand Down
Loading