diff --git a/app/src/androidTest/java/ch/sdp/vibester/activity/AuthenticationActivityTest.kt b/app/src/androidTest/java/ch/sdp/vibester/activity/AuthenticationActivityTest.kt index 7e4213430..2336bc2d8 100644 --- a/app/src/androidTest/java/ch/sdp/vibester/activity/AuthenticationActivityTest.kt +++ b/app/src/androidTest/java/ch/sdp/vibester/activity/AuthenticationActivityTest.kt @@ -155,23 +155,6 @@ class AuthenticationActivityTest { onView(withId(R.id.email)).check(matches(withText("Password has to be at least 6 symbols"))) } - @Test - fun derinTest() { - val a = FireBaseAuthenticator() - - a.googleActivityResult(-1, -1, null) - - onView(withId(R.id.email)).check(matches(withText("TextView"))) - } - - @Test - fun ardaTest() { - val a = FireBaseAuthenticator() - - a.googleActivityResult(1000, -1, null) - - onView(withId(R.id.email)).check(matches(withText("TextView"))) - } @Test fun logInCorrect() { diff --git a/app/src/androidTest/java/ch/sdp/vibester/activity/WelcomeActivityTest.kt b/app/src/androidTest/java/ch/sdp/vibester/activity/WelcomeActivityTest.kt index 04b282ca0..b77091310 100644 --- a/app/src/androidTest/java/ch/sdp/vibester/activity/WelcomeActivityTest.kt +++ b/app/src/androidTest/java/ch/sdp/vibester/activity/WelcomeActivityTest.kt @@ -1,5 +1,7 @@ package ch.sdp.vibester.activity +import android.content.Intent +import androidx.test.core.app.ApplicationProvider import androidx.test.espresso.Espresso.onView import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.intent.Intents @@ -9,6 +11,7 @@ import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import ch.sdp.vibester.R +import com.google.firebase.auth.FirebaseAuth import dagger.hilt.android.testing.HiltAndroidRule import dagger.hilt.android.testing.HiltAndroidTest import org.junit.After @@ -23,11 +26,8 @@ class WelcomeActivityTest { @get:Rule(order = 0) var hiltRule = HiltAndroidRule(this) - @get:Rule(order = 1) - val testRule = ActivityScenarioRule( - WelcomeActivity::class.java - ) + val testRule = ActivityScenarioRule(WelcomeActivity::class.java) @Before fun setUp() { @@ -46,7 +46,15 @@ class WelcomeActivityTest { } @Test - fun checkIntentOnProfile() { + fun checkIntentOnMyAccountLoggedOut() { + FirebaseAuth.getInstance().signOut() + onView(withId(R.id.welcome_profile)).perform(click()) + intended(hasComponent(AuthenticationActivity::class.java.name)) + } + + @Test + fun checkIntentOnMyAccountLoggedIn() { + WelcomeActivity.setLoggedIn() onView(withId(R.id.welcome_profile)).perform(click()) intended(hasComponent(ProfileActivity::class.java.name)) } @@ -57,12 +65,6 @@ class WelcomeActivityTest { intended(hasComponent(ScoreBoardActivity::class.java.name)) } - @Test - fun checkIntentOnSettings() { - onView(withId(R.id.welcome_settings)).perform(click()) - intended(hasComponent(AuthenticationActivity::class.java.name)) - } - @Test fun checkIntentOnDownload() { onView(withId(R.id.welcome_download)).perform(click()) diff --git a/app/src/main/java/ch/sdp/vibester/activity/AuthenticationActivity.kt b/app/src/main/java/ch/sdp/vibester/activity/AuthenticationActivity.kt index c94312a2a..5e536672b 100644 --- a/app/src/main/java/ch/sdp/vibester/activity/AuthenticationActivity.kt +++ b/app/src/main/java/ch/sdp/vibester/activity/AuthenticationActivity.kt @@ -10,11 +10,13 @@ import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import ch.sdp.vibester.R import ch.sdp.vibester.auth.FireBaseAuthenticator +import ch.sdp.vibester.helper.IntentSwitcher import com.google.android.gms.auth.api.signin.GoogleSignIn import com.google.android.gms.auth.api.signin.GoogleSignInClient import com.google.android.gms.auth.api.signin.GoogleSignInOptions import com.google.android.gms.tasks.Task import com.google.firebase.auth.AuthResult +import com.google.firebase.auth.FirebaseAuth import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject @@ -33,7 +35,7 @@ class AuthenticationActivity : AppCompatActivity() { super.onCreate(savedInstanceState) requestWindowFeature(Window.FEATURE_NO_TITLE) supportActionBar?.hide() - setContentView(R.layout.activity_google_log_in) + setContentView(R.layout.activity_authentication) val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() @@ -41,6 +43,7 @@ class AuthenticationActivity : AppCompatActivity() { googleSignInClient = GoogleSignIn.getClient(this, gso) + val btCreateAcc = findViewById