<commit_before>package me.rei_m.hbfavmaterial.activity

import android.content.Context
import android.support.test.InstrumentationRegistry
import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.action.ViewActions.*
import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.matcher.ViewMatchers.*
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import dagger.Component
import dagger.Module
import dagger.Subcomponent
import me.rei_m.hbfavmaterial.App
import me.rei_m.hbfavmaterial.R
import me.rei_m.hbfavmaterial.di.*
import me.rei_m.hbfavmaterial.fragment.InitializeFragment
import me.rei_m.hbfavmaterial.fragment.presenter.InitializeContact
import me.rei_m.hbfavmaterial.util.CustomMatcher
import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.not
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import javax.inject.Singleton

@RunWith(AndroidJUnit4::class)
class SplashActivityTest {

    @Rule
    @JvmField
    val activityRule: ActivityTestRule<SplashActivity> = object : ActivityTestRule<SplashActivity>(SplashActivity::class.java) {

        override fun beforeActivityLaunched() {
            super.beforeActivityLaunched()

            val app = InstrumentationRegistry.getTargetContext().applicationContext as App

            val appComponent = DaggerSplashActivityTest_TestApplicationComponent.builder()
                    .applicationModule(ApplicationModule(app))
                    .infraLayerModule(InfraLayerModule())
                    .build()

            app.component = appComponent
        }
    }

    @Test
    fun 初期表示の確認() {

        // はてなID入力欄が表示.
        onView(withId(R.id.fragment_initialize_edit_hatena_id)).check(matches(isDisplayed()))

        // はてなID送信ボタンが無効な状態で表示.
        onView(withId(R.id.fragment_initialize_button_set_hatena_id)).check(matches(isDisplayed()))
        onView(withId(R.id.fragment_initialize_button_set_hatena_id)).check(matches(not(isEnabled())))

        // FABは表示されてない.
        onView(withId(R.id.fab)).check(matches(not(isDisplayed())))
    }

    @Test
    fun はてなIDを入力すると送信ボタンが有効になる() {
        onView(withId(R.id.fragment_initialize_edit_hatena_id)).perform(typeText("a"))
        onView(withId(R.id.fragment_initialize_button_set_hatena_id)).check(matches(isEnabled()))
    }

    @Test
    fun 入力したはてなIDを消すと送信ボタンが無効になる() {
        onView(withId(R.id.fragment_initialize_edit_hatena_id)).perform(typeText("a"))
        onView(withId(R.id.fragment_initialize_edit_hatena_id)).perform(replaceText(""))
        onView(withId(R.id.fragment_initialize_button_set_hatena_id)).check(matches(not(isEnabled())))
    }

    @Test<commit_msg>set up run test on circleCI<commit_after>package me.rei_m.hbfavmaterial.activity

import android.content.Context
import android.support.test.InstrumentationRegistry
import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.action.ViewActions.*
import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.matcher.ViewMatchers.*
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import android.view.WindowManager
import dagger.Component
import dagger.Module
import dagger.Subcomponent
import me.rei_m.hbfavmaterial.App
import me.rei_m.hbfavmaterial.R
import me.rei_m.hbfavmaterial.di.*
import me.rei_m.hbfavmaterial.fragment.InitializeFragment
import me.rei_m.hbfavmaterial.fragment.presenter.InitializeContact
import me.rei_m.hbfavmaterial.util.CustomMatcher
import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.not
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import javax.inject.Singleton

@RunWith(AndroidJUnit4::class)
class SplashActivityTest {

    @Rule
    @JvmField
    val activityRule: ActivityTestRule<SplashActivity> = object : ActivityTestRule<SplashActivity>(SplashActivity::class.java) {

        override fun beforeActivityLaunched() {
            super.beforeActivityLaunched()

            val app = InstrumentationRegistry.getTargetContext().applicationContext as App

            val appComponent = DaggerSplashActivityTest_TestApplicationComponent.builder()
                    .applicationModule(ApplicationModule(app))
                    .infraLayerModule(InfraLayerModule())
                    .build()

            app.component = appComponent
        }
    }

    @Before
    fun setUp() {
        val activity = activityRule.activity
        val wakeUpDevice = Runnable {
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
                    WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
                    WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
        }
        activity.runOnUiThread(wakeUpDevice)
    }

    @Test
    fun 初期表示の確認() {

        // はてなID入力欄が表示.
        onView(withId(R.id.fragment_initialize_edit_hatena_id)).check(matches(isDisplayed()))

        // はてなID送信ボタンが無効な状態で表示.
        onView(withId(R.id.fragment_initialize_button_set_hatena_id)).check(matches(isDisplayed()))
        onView(withId(R.id.fragment_initialize_button_set_hatena_id)).check(matches(not(isEnabled())))

        // FABは表示されてない.
        onView(withId(R.id.fab)).check(matches(not(isDisplayed())))
    }

    @Test
    fun はてなIDを入力すると送信ボタンが有効になる() {
        onView(withId(R.id.fragment_initialize_edit_hatena_id)).perform(typeText("a"))
        onView(withId(R.id.fragment_initialize_button_set_hatena_id)).check(matches(isEnabled()))
    }

    @Test
    fun 入力したはてなIDを消すと送信ボタンが無効になる() {
        onView(withId(R.id.fragment_initialize_edit_hatena_id)).perform(typeText("a"))
        onView(withId(R.id.fragment_initialize_edit_hatena_id)).perform(replaceText(""))
        onView(withId(R.id.fragment_initialize_button_set_hatena_id)).check(matches(not(isEnabled())))
    }

    @Test
{'fraction_non_alphanumeric': 0.10004977600796416, 'fraction_numerical': 0.000663680106188817, 'mean_word_length': 4.014975041597338, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1796409', 'n_tokens_mistral': 1990, 'n_tokens_neox': 1956, 'n_words': 217}