Skip to content
Permalink
4b4c33655e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
66 lines (45 sloc) 2.23 KB
package com.example.booksharing21;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class MainActivityExpress {
private static final String VALID_Email = "john.doe@outlook.com";
private static final String VALID_Password = "1234john";
@Rule
public ActivityScenarioRule<MainActivity> activityRule =
new ActivityScenarioRule<>(MainActivity.class);
// android developers https://developer.android.com/training/testing/espresso/basics
// checking users credentials
@Test
public void ValidCredentials() {
onView(withId(R.id.email)).perform(typeText(VALID_Email), closeSoftKeyboard());
onView(withId(R.id.password)).perform(typeText(VALID_Password),closeSoftKeyboard()); }
@Test
public void WrongEmail(){
onView(withId(R.id.email)).perform(typeText("john"),closeSoftKeyboard());
onView(withId(R.id.password)).perform(typeText(VALID_Password),closeSoftKeyboard()); }
@Test
public void WrongPassword(){
onView(withId(R.id.email)).perform(typeText(VALID_Email),closeSoftKeyboard());
onView(withId(R.id.password)).perform(typeText("doe"),closeSoftKeyboard()); }
@Test
public void NoCredentials(){
onView(withId(R.id.email)).perform(typeText(""),closeSoftKeyboard());
onView(withId(R.id.password)).perform(typeText(""),closeSoftKeyboard()); }
@Test
public void RegButton(){ onView(withId(R.id.reg)).perform(click()); }
@Test
public void logButton(){ onView(withId(R.id.log)).perform(click()).check(matches(isDisplayed())); }
}