package com.lcw.robotiumtest;

import android.app.Application;
import android.test.ActivityInstrumentationTestCase2;
import android.test.ApplicationTestCase;

import com.robotium.solo.Solo;

/**
 * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
 */
public class ApplicationTest extends ActivityInstrumentationTestCase2<LoginActivity> {
    private Solo solo;

    public ApplicationTest() {
        super(LoginActivity.class);
    }
    @Override
    protected void setUp() throws Exception {
        solo = new Solo(getInstrumentation(), getActivity());
    }

    @Override
    protected void tearDown() throws Exception {
        solo.finishOpenedActivities();
    }

    public void testLoginIn() throws Exception {
        solo.unlockScreen();
        solo.clickOnEditText(0);
        solo.enterText(0, "admin1111");
        solo.clickOnEditText(1);
        solo.enterText(1, "admin1111");
        solo.clickOnButton("SIGN IN");
        boolean is = solo.searchText("success");
        if (is){
        }else {
            solo.clickOnEditText(0);
            solo.clearEditText(0);
            solo.enterText(0, "admin");
            solo.clickOnEditText(1);
            solo.clearEditText(1);
            solo.enterText(1, "admin");
            solo.clickOnButton("SIGN IN");
        }
        is = solo.searchText("success");
        if (is){
            solo.sleep(2000);
        }
    }
}