1
1
package fr.free.nrw.commons
2
2
3
+ import android.app.Activity
4
+ import android.app.Instrumentation.ActivityResult
5
+ import android.content.Intent
3
6
import androidx.test.espresso.Espresso
4
- import androidx.test.espresso.action.ViewActions.click
5
- import androidx.test.espresso.assertion.ViewAssertions
7
+ import androidx.test.espresso.action.ViewActions
6
8
import androidx.test.espresso.intent.Intents
7
- import androidx.test.espresso.intent.Intents.intended
9
+ import androidx.test.espresso.intent.Intents.intending
10
+ import androidx.test.espresso.intent.matcher.IntentMatchers
8
11
import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
12
+ import androidx.test.espresso.intent.matcher.IntentMatchers.isInternal
9
13
import androidx.test.espresso.matcher.ViewMatchers
10
- import androidx.test.espresso.matcher.ViewMatchers.withId
11
- import androidx.test.filters.LargeTest
14
+ import androidx.test.filters.MediumTest
12
15
import androidx.test.rule.ActivityTestRule
13
16
import androidx.test.runner.AndroidJUnit4
14
17
import fr.free.nrw.commons.auth.LoginActivity
15
- import fr.free.nrw.commons.auth.SignupActivity
18
+ import fr.free.nrw.commons.contributions.MainActivity
19
+ import org.hamcrest.CoreMatchers
20
+ import org.hamcrest.CoreMatchers.not
21
+ import org.junit.Before
16
22
import org.junit.Rule
17
23
import org.junit.Test
18
24
import org.junit.runner.RunWith
19
25
20
- @LargeTest
26
+
27
+ @MediumTest
21
28
@RunWith(AndroidJUnit4 ::class )
22
29
class LoginActivityTest {
23
30
@get:Rule
24
- var activity: ActivityTestRule <* > = ActivityTestRule (LoginActivity ::class .java)
31
+ var activityRule = ActivityTestRule (LoginActivity ::class .java)
32
+
33
+ @Before
34
+ fun setup () {
35
+ try {
36
+ Intents .init ()
37
+ } catch (ex: IllegalStateException ) {
38
+
39
+ }
40
+ UITestHelper .skipWelcome()
41
+ intending(not (isInternal())).respondWith(ActivityResult (Activity .RESULT_OK , null ))
42
+ }
43
+
44
+ @Test
45
+ fun testLogin () {
46
+ UITestHelper .loginUser()
47
+ UITestHelper .sleep(10000 )
48
+ Intents .intended(hasComponent(MainActivity ::class .java.name))
49
+ }
25
50
26
51
@Test
27
- fun isSignUpButtonWorks () {
28
- // Clicks the SignUp Button
29
- Intents .init ()
30
- Espresso .onView(withId(R .id.signupButton))
31
- .check(ViewAssertions .matches(ViewMatchers .isDisplayed()))
32
- .perform(click())
33
- intended(hasComponent(SignupActivity ::class .java.name))
34
- Intents .release()
52
+ fun testForgotPassword () {
53
+ Espresso .onView(ViewMatchers .withId(R .id.forgotPassword))
54
+ .perform(ViewActions .click())
55
+ Intents .intended(CoreMatchers .allOf(IntentMatchers .hasAction(Intent .ACTION_VIEW ), IntentMatchers .hasData(BuildConfig .FORGOT_PASSWORD_URL )));
35
56
}
36
57
}
0 commit comments