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 #102 from MaximeZmt/jwen/lyrics-belong
Jwen/lyrics belong
- Loading branch information
Showing
17 changed files
with
414 additions
and
99 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
157 changes: 157 additions & 0 deletions
157
app/src/androidTest/java/ch/sdp/vibester/activity/LyricsBelongGameActivityTest.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,157 @@ | ||
package ch.sdp.vibester.activity | ||
|
||
import android.content.Intent | ||
import androidx.test.core.app.ActivityScenario | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.intent.Intents | ||
import androidx.test.espresso.matcher.ViewMatchers.* | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.rule.GrantPermissionRule | ||
import ch.sdp.vibester.R | ||
import ch.sdp.vibester.api.LyricsOVHApiInterface | ||
|
||
import org.hamcrest.CoreMatchers.equalTo | ||
import org.hamcrest.MatcherAssert.assertThat | ||
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 LyricsBelongGameActivityTest { | ||
|
||
@get: Rule | ||
val activityRule = ActivityScenarioRule(LyricsBelongGameActivity::class.java) | ||
|
||
@get:Rule | ||
var permissionRule: GrantPermissionRule = | ||
GrantPermissionRule.grant(android.Manifest.permission.RECORD_AUDIO) | ||
|
||
@Before | ||
fun setUp() { | ||
Intents.init() | ||
} | ||
|
||
@After | ||
fun clean() { | ||
Intents.release() | ||
} | ||
|
||
@Test | ||
fun getLyricsFromAPICorrectly() { | ||
val service = LyricsOVHApiInterface.create() | ||
val lyric = service.getLyrics("Imagine Dragons", "Thunder").execute() | ||
|
||
assertThat( | ||
lyric.body().lyrics?.replace("\n", "")?.replace("\r", ""), | ||
equalTo(("Just a young gun with a quick fuse\n" + | ||
"I was uptight, wanna let loose\n" + | ||
"I was dreaming of bigger things in\n" + | ||
"And wanna leave my own life behind\n" + | ||
"Not a yes sir, not a follower\n" + | ||
"Fit the box, fit the mold\n" + | ||
"Have a seat in the foyer, take a number\n" + | ||
"I was lightning before the thunder\n" + | ||
"Thunder, thunder\n" + | ||
"Thunder, thun-, thunder\n" + | ||
"Thun-thun-thunder, thunder, thunder\n" + | ||
"Thunder, thun-, thunder\n" + | ||
"Thun-thun-thunder, thunder\n" + | ||
"Thunder, feel the thunder\n" + | ||
"Lightning and the thunder\n" + | ||
"Thunder, feel the thunder\n" + | ||
"Lightning and the thunder\n" + | ||
"Thunder, thunder\n" + | ||
"Thunder\n" + | ||
|
||
"Kids were laughing in my classes\n" + | ||
"While I was scheming for the masses\n" + | ||
"Who do you think you are?\n" + | ||
"Dreaming 'bout being a big star\n" + | ||
"You say you're basic, you say you're easy\n" + | ||
"You're always riding in the back seat\n" + | ||
"Now I'm smiling from the stage while\n" + | ||
"You were clapping in the nose bleeds\n" + | ||
|
||
"Thunder, thunder\n" + | ||
"Thunder, thun-, thunder\n" + | ||
"Thun-thun-thunder, thunder, thunder\n" + | ||
"Thunder, thun-, thunder\n" + | ||
"Thun-thun-thunder, thunder\n" + | ||
|
||
"Thunder, feel the thunder\n" + | ||
"Lightning and the thunder\n" + | ||
"Thunder, feel the thunder\n" + | ||
"Lightning and the thunder\n" + | ||
"Thunder\n" + | ||
"Thunder, feel the thunder\n" + | ||
"Lightning and the thunder, thunder\n" + | ||
|
||
"Thunder, feel the thunder\n" + | ||
"Lightning and the thunder, thunder\n" + | ||
"Thunder, feel the thunder\n" + | ||
"Lightning and the thunder, thunder\n" + | ||
"Thunder, feel the thunder\n" + | ||
"Lightning and the thunder, thunder\n" + | ||
"Thunder, feel the thunder (feel the)\n" + | ||
"Lightning and the thunder, thunder\n" + | ||
|
||
"Thunder, thun-, thunder\n" + | ||
"Thun-thun-thunder, thunder\n" + | ||
"Thunder, thun-, thunder\n" + | ||
"Thun-thun-thunder, thunder\n" + | ||
"Thunder, thun-, thunder\n" + | ||
"Thun-thun-thunder, thunder\n" + | ||
"Thunder, thun-, thunder\n" + | ||
"Thun-thun-thunder, thunder").replace("\r", "").replace("\n", "")) | ||
) | ||
} | ||
|
||
@Test | ||
fun btnCheckVisibleAfterSpeak() { | ||
val intent = Intent(ApplicationProvider.getApplicationContext(), LyricsBelongGameActivity::class.java) | ||
val scn: ActivityScenario<LyricsBelongGameActivity> = ActivityScenario.launch(intent) | ||
scn.onActivity { activity -> | ||
activity.testUpdateSpeechResult("hey") | ||
} | ||
onView(withId(R.id.lyricMatchResult)).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) | ||
} | ||
|
||
@Test | ||
fun checkLyricsShouldReturnCorrect() { | ||
val intent = Intent(ApplicationProvider.getApplicationContext(), LyricsBelongGameActivity::class.java) | ||
val scn: ActivityScenario<LyricsBelongGameActivity> = ActivityScenario.launch(intent) | ||
scn.onActivity { activity -> | ||
activity.testCheckLyrics("Just a young gun with a quick fuse") | ||
} | ||
Thread.sleep(5000) | ||
onView(withId(R.id.lyricMatchResult)).check(matches(withText("res: correct"))) | ||
} | ||
|
||
@Test | ||
fun checkLyricsShouldReturnTooBad() { | ||
val intent = Intent(ApplicationProvider.getApplicationContext(), LyricsBelongGameActivity::class.java) | ||
val scn: ActivityScenario<LyricsBelongGameActivity> = ActivityScenario.launch(intent) | ||
scn.onActivity { activity -> | ||
activity.testCheckLyrics("I don't remember the lyrics") | ||
} | ||
Thread.sleep(5000) | ||
onView(withId(R.id.lyricMatchResult)).check(matches(withText("res: too bad"))) | ||
} | ||
|
||
@Test | ||
fun shouldUpdateSpeechFromInput() { | ||
val intent = Intent(ApplicationProvider.getApplicationContext(), LyricsBelongGameActivity::class.java) | ||
val scn: ActivityScenario<LyricsBelongGameActivity> = ActivityScenario.launch(intent) | ||
scn.onActivity { activity -> | ||
activity.testUpdateSpeechResult("hey") | ||
} | ||
onView(withId(R.id.lyricResult)).check(matches(withText("hey"))) | ||
} | ||
|
||
|
||
} |
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 |
---|---|---|
@@ -1,61 +1,65 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="ch.sdp.vibester"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.MyApplication" | ||
android:usesCleartextTraffic="true"> | ||
<activity | ||
android:name=".activity.IncorrectSongsActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.GameEndingActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.TypingGameActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.GamescreenActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.ProfileActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".LyricTemporary" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.GameSetupActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.ScoreBoardActivity" | ||
android:theme="@style/AppTheme.NoActionBar" /> | ||
<activity | ||
android:name=".activity.WelcomeActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.AuthenticationActivity" | ||
android:exported="true" /> | ||
<activity | ||
android:name=".GenreTemporary" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="ch.sdp.vibester"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
<uses-permission android:name="android.permission.RECORD_AUDIO" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.MyApplication" | ||
android:usesCleartextTraffic="true"> | ||
<activity | ||
android:name=".activity.IncorrectSongsActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.LyricsBelongGameActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.GameEndingActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.TypingGameActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.GamescreenActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.ProfileActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".LyricTemporary" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.GameSetupActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.ScoreBoardActivity" | ||
android:theme="@style/AppTheme.NoActionBar" /> | ||
<activity | ||
android:name=".activity.WelcomeActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.AuthenticationActivity" | ||
android:exported="true" /> | ||
<activity | ||
android:name=".GenreTemporary" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Oops, something went wrong.