This repository has been archived by the owner on Jan 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #227 from MaximeZmt/jwen/qr-code-generator
Jwen/qr code generator
- Loading branch information
Showing
25 changed files
with
474 additions
and
234 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,7 @@ import androidx.test.espresso.action.ViewActions.click | |
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.intent.Intents | ||
import androidx.test.espresso.intent.matcher.IntentMatchers | ||
import androidx.test.espresso.matcher.ViewMatchers.withId | ||
import androidx.test.espresso.matcher.ViewMatchers.withText | ||
import androidx.test.espresso.matcher.ViewMatchers.* | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import ch.sdp.vibester.R | ||
import ch.sdp.vibester.TestMode | ||
|
@@ -22,6 +21,7 @@ import dagger.hilt.android.testing.HiltAndroidRule | |
import dagger.hilt.android.testing.HiltAndroidTest | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import org.hamcrest.CoreMatchers.not | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Rule | ||
|
@@ -77,7 +77,7 @@ class ProfileActivityTest { | |
} | ||
|
||
@Test | ||
fun clickBackToMain(){ | ||
fun clickBackToMain() { | ||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
intent.putExtra("isUnitTest", true) | ||
|
@@ -88,6 +88,33 @@ class ProfileActivityTest { | |
Intents.intended(IntentMatchers.hasComponent(WelcomeActivity::class.java.name)) | ||
} | ||
|
||
@Test | ||
fun shouldShowQrCode() { | ||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
intent.putExtra("isUnitTest", true) | ||
|
||
val scn: ActivityScenario<ProfileActivity> = ActivityScenario.launch(intent) | ||
|
||
onView(withId(R.id.showQRCode)).perform(click()) | ||
onView(withId(R.id.QrCodePage)).check(matches(isDisplayed())) | ||
onView(withId(R.id.profileContent)).check(matches(not(isDisplayed()))) | ||
onView(withId(R.id.qrCode)).check(matches(isDisplayed())) | ||
} | ||
|
||
@Test | ||
fun clickBackToProfile() { | ||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
intent.putExtra("isUnitTest", true) | ||
|
||
val scn: ActivityScenario<ProfileActivity> = ActivityScenario.launch(intent) | ||
onView(withId(R.id.showQRCode)).perform(click()) | ||
onView(withId(R.id.qrCode_returnToProfile)).perform(click()) | ||
onView(withId(R.id.QrCodePage)).check(matches(not(isDisplayed()))) | ||
onView(withId(R.id.profileContent)).check(matches(isDisplayed())) | ||
} | ||
|
||
|
||
@Test | ||
fun checkEditProfile() { | ||
|
@@ -102,14 +129,13 @@ class ProfileActivityTest { | |
val scn: ActivityScenario<ProfileActivity> = ActivityScenario.launch(intent) | ||
|
||
val newUsername = "Lalisa Bon idomesniu" | ||
onView(withId(R.id.editUser)).perform(ViewActions.click()) | ||
onView(withId(R.id.editUser)).perform(click()) | ||
onView(withId(0)).perform( | ||
ViewActions.typeText(newUsername), | ||
ViewActions.closeSoftKeyboard() | ||
) | ||
onView(withText("OK")).perform(ViewActions.click()) | ||
onView(withText("OK")).perform(click()) | ||
onView(withId(R.id.username)).check(matches(withText(newUsername))) | ||
|
||
} | ||
|
||
@Test | ||
|
@@ -124,9 +150,24 @@ class ProfileActivityTest { | |
|
||
val scn: ActivityScenario<ProfileActivity> = ActivityScenario.launch(intent) | ||
|
||
onView(withId(R.id.editUser)).perform(ViewActions.click()) | ||
onView(withText("Cancel")).perform(ViewActions.click()) | ||
onView(withId(R.id.editUser)).perform(click()) | ||
onView(withText("Cancel")).perform(click()) | ||
onView(withId(R.id.username)).check(matches(withText("Lalisa Bon"))) | ||
} | ||
|
||
@Test | ||
fun checkQrCodeGenerator() { | ||
val inputProfile = User( "Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8, 29, 0, "VvPB47tQCLdjz3YebilS6h5EXdJ3") | ||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
intent.putExtra("isUnitTest", true) | ||
intent.putExtra("userTestProfile", inputProfile) | ||
|
||
createMockInvocation(inputProfile) | ||
|
||
val scn: ActivityScenario<ProfileActivity> = ActivityScenario.launch(intent) | ||
onView(withId(R.id.showQRCode)).perform(click()) | ||
onView(withId(R.id.qrCode)).check(matches(isDisplayed())) | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.