package kr.co.hanwha.hifive.screen.intro;

import android.support.test.espresso.Espresso;
import android.support.test.espresso.action.ViewActions;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import kr.co.hanwha.hifive.R;

import static android.support.test.espresso.matcher.ViewMatchers.withId;

@RunWith(AndroidJUnit4.class)
public class IntroActivityTest {
    @Rule
    public ActivityTestRule<IntroActivity> mActivityRule =
            new ActivityTestRule<>(IntroActivity.class);
    //    public val rule  = ActivityTestRule(MainActivity::class.java)

    @Before
    public void init(){

    }

    private String user_id = "sanghoonkwon@hanwha.com";
    private String password = "hanwha0107";

    @Test
    public void showAccountLogin() {

//        throw new NullPointerException();
//        Espresso.onView()

    }

    @Test
    public void loginFailedTest(){
        IntroPresenter presenter = new IntroPresenter(mActivityRule.getActivity());
        presenter.doAccountLogin(user_id, "wrong");
    }

    @Test
    public void loginSuccessTest(){
//        Espresso.onView((withId(R.id.alertAccount_textView)))
//                .perform(ViewActions.typeText(user_id));

//        Espresso.onView((withId(R.id.id_loginEditText)))
//        Espresso.onView((withId(R.id.hint_textView)))
//        .perform(ViewActions.typeText(user_id));

//        Espresso.onView(withId(R.id.id_loginEditText))
//                .check(matches(isDisplayed()));

//        IntroActivity view = new IntroActivity();
//        IntroPresenter presenter = new IntroPresenter(view);
        IntroPresenter presenter = new IntroPresenter(mActivityRule.getActivity());
        presenter.doAccountLogin(user_id, password);
    }
}

/*
// Create the service Intent.
        Intent serviceIntent = new Intent(InstrumentationRegistry.getTargetContext(), LocalService.class);

        // Data can be passed to the service via the Intent.
        serviceIntent.putExtra(LocalService.SEED_KEY, 42L);

        // Bind the service and grab a reference to the binder.
        IBinder binder = mServiceRule.bindService(serviceIntent);

        // Get the reference to the service, or you can call public methods on the binder directly.
        LocalService service = ((LocalService.LocalBinder) binder).getService();

        // Verify that the service is working correctly.
        assertThat(service.getRandomInt(), is(any(Integer.class)));
 */