Skip to content

Commit

Permalink
Correction test socket non mock
Browse files Browse the repository at this point in the history
  • Loading branch information
YohannTognetti committed Apr 30, 2020
1 parent 1a1e890 commit f6f6124
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import androidx.test.rule.ActivityTestRule;

import com.example.plplbproject.R;
import com.example.plplbproject.reseau.Connexion;

import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -45,10 +46,11 @@ public class LoginActivityTest {
public void init() {
socket = Mockito.mock(Socket.class);
when(socket.connected()).thenReturn(true);

Intent startIntent = new Intent();


mActivityRule.launchActivity(startIntent);
Connexion.CONNEXION.setSocket(socket);

//setup de bouton
loginInput = mActivityRule.getActivity().findViewById(R.id.loginInput);
Expand Down Expand Up @@ -85,6 +87,7 @@ public void testInputBadLogin(){
when(socket.connected()).thenReturn(false);
onView(withId(R.id.loginInput)).perform(typeText("ab123456"), closeSoftKeyboard());
onView(withId(R.id.connexionButton)).perform(click());
when(socket.connected()).thenReturn(false);

//on voit le message d'erreur
assertEquals(textError.getVisibility(),View.VISIBLE);
Expand Down

0 comments on commit f6f6124

Please sign in to comment.