<commit_before>package by.anatoldeveloper.helpers.testframeworks;

import android.support.test.InstrumentationRegistry;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.IdlingResource;
import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.rule.ActivityTestRule;

import org.junit.Rule;
import org.junit.Test;

import by.anatoldeveloper.helpers.testframeworks.activity.LoginActivity;
import by.anatoldeveloper.helpers.testframeworks.ui.fragments.LoginFragment;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
 * Created by Nublo on 28.08.2016.
 * Copyright Nublo
 */
public class MainActivityLoginFragmentTest {

    @Rule
    public ActivityTestRule<LoginActivity> activityTestRule = new ActivityTestRule<>(LoginActivity.class);

    @Test
    public void checkErrorShowingForIncorrectUser() {
        onView(withId(R.id.login_invalid_credentials)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
        onView(withId(R.id.login_username)).perform(typeText("test"));
        onView(withId(R.id.login_password)).perform(typeText("<PASSWORD>"));
        onView(withId(R.id.login_enter)).perform(click());
        onView(withId(R.id.login_invalid_credentials)).check(matches(isDisplayed()));
    }

    @Test
    public void successLogin() {
        onView(withId(R.id.login_invalid_credentials)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
        onView(withId(R.id.login_username)).perform(typeText(LoginFragment.DEFAULT_LOGIN));
        onView(withId(R.id.login_password)).perform(typeText(LoginFragment.DEFAULT_PASSWORD));
        onView(withId(R.id.login_enter)).perform(click());

        IdlingResource idlingResource = startTiming(1500);
        onView(withId(R.id.login_invalid_credentials)).check(matches(isDisplayed())).
                check(matches(withText(InstrumentationRegistry.getTargetContext().getString(R.string.success_login))));
        stopTiming(idlingResource);
    }

    public IdlingResource startTiming(long time) {
        IdlingResource idlingResource = new ElapsedTimeIdlingResource(time);
        Espresso.registerIdlingResources(idlingResource);
        return idlingResource;
    }

    public void stopTiming(IdlingResource idlingResource) {
        Espresso.unregisterIdlingResources(idlingResource);
    }

}<commit_msg>Moved .travis.yml to root folder.<commit_after>package by.anatoldeveloper.helpers.testframeworks;

import android.support.test.InstrumentationRegistry;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.IdlingResource;
import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.rule.ActivityTestRule;

import org.junit.Rule;
import org.junit.Test;

import by.anatoldeveloper.helpers.testframeworks.activity.LoginActivity;
import by.anatoldeveloper.helpers.testframeworks.ui.fragments.LoginFragment;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
 * Created by Nublo on 28.08.2016.
 * Copyright Nublo
 */
public class MainActivityLoginFragmentTest {

    @Rule
    public ActivityTestRule<LoginActivity> activityTestRule = new ActivityTestRule<>(LoginActivity.class);

    @Test
    public void checkErrorShowingForIncorrectUser() {
        onView(withId(R.id.login_invalid_credentials)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
        onView(withId(R.id.login_username)).perform(typeText("test"));
        onView(withId(R.id.login_password)).perform(typeText("<PASSWORD>"));
        onView(withId(R.id.login_enter)).perform(click());
        onView(withId(R.id.login_invalid_credentials)).check(matches(isDisplayed()));
    }

    @Test
    public void successLogin() {
        onView(withId(R.id.login_invalid_credentials)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
        onView(withId(R.id.login_username)).perform(typeText(LoginFragment.DEFAULT_LOGIN));
        onView(withId(R.id.login_password)).perform(typeText(LoginFragment.DEFAULT_PASSWORD));
        onView(withId(R.id.login_enter)).perform(click());

        IdlingResource idlingResource = startTiming(1500);
        onView(withId(R.id.login_invalid_credentials)).check(matches(isDisplayed())).
                check(matches(withText(InstrumentationRegistry.getTargetContext().getString(R.string.success_login))));
        stopTiming(idlingResource);
    }

    public IdlingResource startTiming(long time) {
        IdlingResource idlingResource = new ElapsedTimeIdlingResource(time);
        Espresso.registerIdlingResources(idlingResource);
        return idlingResource;
    }

    public void stopTiming(IdlingResource idlingResource) {
        Espresso.unregisterIdlingResources(idlingResource);
    }
}
{'fraction_non_alphanumeric': 0.10963793982661907, 'fraction_numerical': 0.00407955124936257, 'mean_word_length': 5.402611534276387, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3409334', 'n_tokens_mistral': 1774, 'n_tokens_neox': 1752, 'n_words': 202}