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
Jwen/redesign profile add ranking #273
Merged
Merged
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
3c886e3
remove bestScore and correctSongs in User
jiabaow fe92624
remove bestScore and correctSongs in ProfileActivity
jiabaow 728c3ef
add score per genre in profile
jiabaow 562c564
update test
jiabaow bf2aec1
fix indentation
jiabaow 4bcff81
rename nestedScrollView
jiabaow 6c6390d
remove redundant setting
jiabaow 93bee4d
replace image and qr code in profile
jiabaow f2ba071
re-adjust relativeLayout
jiabaow 9483f97
add total games
jiabaow 20b2af9
make stats scrollable
jiabaow 5877332
add scores & friends button ui
jiabaow d897765
add score btn listener
jiabaow 03dd561
add doc
jiabaow f04bca4
add test
jiabaow 55f2ddc
replace qr code btn to image
jiabaow 421210a
readjust scores btn and friends btn
jiabaow 20463eb
add lines
jiabaow 8418131
save profile image url in strings
jiabaow f6472bf
add top constraint to scroll view
jiabaow 888d9b4
change to set visibility on table layout
jiabaow 77f4bde
fix soft keyboard pushes layout
jiabaow 7e90c3a
merge main and resolve conflict
jiabaow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ package ch.sdp.vibester.activity | |
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.provider.CalendarContract.CalendarCache.URI | ||
import android.widget.ImageView | ||
import androidx.test.core.app.ActivityScenario | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.espresso.Espresso.onView | ||
|
@@ -48,11 +46,11 @@ class ProfileActivityTest { | |
} | ||
|
||
@BindValue @JvmField | ||
val mockAuthenticatior = mockk<FireBaseAuthenticator>() | ||
val mockAuthenticator = mockk<FireBaseAuthenticator>() | ||
|
||
private fun createMockAuthenticatorInvocation() { | ||
val mockUser = createMockUser() | ||
every { mockAuthenticatior.getCurrUser() } returns mockUser | ||
every { mockAuthenticator.getCurrUser() } returns mockUser | ||
} | ||
|
||
private fun createMockUser(): FirebaseUser { | ||
|
@@ -95,7 +93,7 @@ class ProfileActivityTest { | |
|
||
@Test | ||
fun checkProfileData() { | ||
val inputProfile = User("Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8, 29, 0) | ||
val inputProfile = User("Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8) | ||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
|
||
|
@@ -106,14 +104,20 @@ class ProfileActivityTest { | |
val scn: ActivityScenario<ProfileActivity> = ActivityScenario.launch(intent) | ||
|
||
onView(withId(R.id.username)).check(matches(withText(inputProfile.username))) | ||
onView(withId(R.id.correctSongs)).check(matches(withText(inputProfile.correctSongs.toString()))) | ||
onView(withId(R.id.totalGames)).check(matches(withText(inputProfile.totalGames.toString()))) | ||
onView(withId(R.id.ranking)).check(matches(withText(inputProfile.ranking.toString()))) | ||
onView(withId(R.id.profile_total_games_stat)).check(matches(withText(inputProfile.totalGames.toString()))) | ||
} | ||
|
||
@Test | ||
fun clickBackToMain(){ | ||
val inputProfile = User("Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8, 29, 0) | ||
fun clickScoresShowScores() { | ||
val scorePerGenre: Map<String, Int> = mapOf( | ||
"top tracks" to 1, | ||
"kpop" to 2, | ||
"rock" to 3, | ||
"BTS" to 4, | ||
"Imagine Dragons" to 5, | ||
"Billie Eilish" to 6) | ||
val inputProfile = User("Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing with the link here. It seems to be the same one as the previous comment |
||
12, scores = scorePerGenre) | ||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
|
||
|
@@ -122,14 +126,37 @@ class ProfileActivityTest { | |
createMockImageGetter() | ||
|
||
val scn: ActivityScenario<ProfileActivity> = ActivityScenario.launch(intent) | ||
onView(withId(R.id.profile_scores)).perform(click()) | ||
|
||
onView(withId(R.id.profile_scroll_stat)).check(matches(isDisplayed())) | ||
|
||
onView(withId(R.id.profile_top_tracks)).check(matches(withText(inputProfile.scores.getOrDefault("top tracks", 0).toString()))) | ||
onView(withId(R.id.profile_kpop)).check(matches(withText(inputProfile.scores.getOrDefault("kpop", 0).toString()))) | ||
onView(withId(R.id.profile_rock)).check(matches(withText(inputProfile.scores.getOrDefault("rock", 0).toString()))) | ||
onView(withId(R.id.profile_bts)).check(matches(withText(inputProfile.scores.getOrDefault("BTS", 0).toString()))) | ||
onView(withId(R.id.profile_imagine_dragons)).check(matches(withText(inputProfile.scores.getOrDefault("Imagine Dragons", 0).toString()))) | ||
onView(withId(R.id.profile_billie_eilish)).check(matches(withText(inputProfile.scores.getOrDefault("Billie Eilish", 0).toString()))) | ||
} | ||
|
||
@Test | ||
fun clickBackToMain(){ | ||
val inputProfile = User("Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a test class so shouldn't be an issue, but would it be possible to put links in strings.xml? It would help others with understanding where that link leads to |
||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
|
||
createMockDataGetter(inputProfile) | ||
createMockAuthenticatorInvocation() | ||
createMockImageGetter() | ||
|
||
val scn: ActivityScenario<ProfileActivity> = ActivityScenario.launch(intent) | ||
onView(withId(R.id.profile_returnToMain)).perform(click()) | ||
|
||
Intents.intended(IntentMatchers.hasComponent(WelcomeActivity::class.java.name)) | ||
} | ||
|
||
@Test | ||
fun shouldShowQrCode() { | ||
val inputProfile = User("Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8, 29, 0) | ||
val inputProfile = User("Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8) | ||
|
||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
|
@@ -139,16 +166,16 @@ class ProfileActivityTest { | |
createMockImageGetter() | ||
|
||
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 inputProfile = User("Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8, 29, 0) | ||
val inputProfile = User("Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8) | ||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
|
||
|
@@ -159,14 +186,15 @@ class ProfileActivityTest { | |
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() { | ||
val inputProfile = User("Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8, 29, 0) | ||
val inputProfile = User("Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8) | ||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
|
||
|
@@ -176,18 +204,20 @@ class ProfileActivityTest { | |
|
||
val scn: ActivityScenario<ProfileActivity> = ActivityScenario.launch(intent) | ||
val newUsername = "Lalisa Bon idomesniu" | ||
|
||
onView(withId(R.id.editUser)).perform(click()) | ||
onView(withId(0)).perform( | ||
ViewActions.typeText(newUsername), | ||
ViewActions.closeSoftKeyboard() | ||
) | ||
onView(withText("OK")).perform(click()) | ||
|
||
onView(withId(R.id.username)).check(matches(withText(newUsername))) | ||
} | ||
|
||
@Test | ||
fun checkEditProfileClickCancel() { | ||
val inputProfile = User( "Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8, 29, 0) | ||
val inputProfile = User( "Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8) | ||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
|
||
|
@@ -196,15 +226,15 @@ class ProfileActivityTest { | |
createMockImageGetter() | ||
|
||
val scn: ActivityScenario<ProfileActivity> = ActivityScenario.launch(intent) | ||
|
||
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 inputProfile = User( "Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8,"VvPB47tQCLdjz3YebilS6h5EXdJ3") | ||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
|
||
|
@@ -214,12 +244,13 @@ class ProfileActivityTest { | |
|
||
val scn: ActivityScenario<ProfileActivity> = ActivityScenario.launch(intent) | ||
onView(withId(R.id.showQRCode)).perform(click()) | ||
|
||
onView(withId(R.id.qrCode)).check(matches(isDisplayed())) | ||
} | ||
|
||
@Test | ||
fun checkIfPictureIsDisplayed() { | ||
val inputProfile = User( "Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8, 29, 0, "VvPB47tQCLdjz3YebilS6h5EXdJ3") | ||
val inputProfile = User( "Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8,"VvPB47tQCLdjz3YebilS6h5EXdJ3") | ||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
val intent = Intent(ctx, ProfileActivity::class.java) | ||
|
||
|
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, basically if possible, all the URLS lol