package com.lemonhc.mplus.mcare_plus.activity.lockScreen

import android.view.View
import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule
import org.junit.Assert.*
import org.junit.Rule
import org.junit.Test

@LargeTest
class LockScreenActivityTest{

    @get:Rule
    val activityRule = ActivityTestRule(LockScreenActivity::class.java)

    @Test
    fun testNum0() {
        val view = View(activityRule.activity)
        view.tag = 0
        activityRule.activity.numpadClick(view)
        assert(activityRule.activity.arrPassword?.contains("0") == true)
    }

    @Test
    fun testNum1() {
        val view = View(activityRule.activity)
        view.tag = 1
        activityRule.activity.numpadClick(view)
        assert(activityRule.activity.arrPassword?.contains("1") == true)
    }

    @Test
    fun testNum2() {
        val view = View(activityRule.activity)
        view.tag = 2
        activityRule.activity.numpadClick(view)
        assert(activityRule.activity.arrPassword?.contains("2") == true)
    }

    @Test
    fun testNum3() {
        val view = View(activityRule.activity)
        view.tag = 3
        activityRule.activity.numpadClick(view)
        assert(activityRule.activity.arrPassword?.contains("3") == true)
    }

    @Test
    fun testNum4() {
        val view = View(activityRule.activity)
        view.tag = 4
        activityRule.activity.numpadClick(view)
        assert(activityRule.activity.arrPassword?.contains("4") == true)
    }

    @Test
    fun testNum5() {
        val view = View(activityRule.activity)
        view.tag = 5
        activityRule.activity.numpadClick(view)
        assert(activityRule.activity.arrPassword?.contains("5") == true)
    }

    @Test
    fun testNum6() {
        val view = View(activityRule.activity)
        view.tag = 6
        activityRule.activity.numpadClick(view)
        assert(activityRule.activity.arrPassword?.contains("6") == true)
    }

    @Test
    fun testNum7() {
        val view = View(activityRule.activity)
        view.tag = 7
        activityRule.activity.numpadClick(view)
        assert(activityRule.activity.arrPassword?.contains("7") == true)
    }

    @Test
    fun testNum8() {
        val view = View(activityRule.activity)
        view.tag = 8
        activityRule.activity.numpadClick(view)
        assert(activityRule.activity.arrPassword?.contains("8") == true)
    }

    @Test
    fun testNum9() {
        val view = View(activityRule.activity)
        view.tag = 9
        activityRule.activity.numpadClick(view)
        assert(activityRule.activity.arrPassword?.contains("9") == true)
    }

    @Test
    fun testNumMinus() {
        val view = View(activityRule.activity)
        view.tag = -1
        activityRule.activity.numpadClick(view)
        assert(activityRule.activity.arrPassword?.count() == 0)
    }

    @Test
    fun testisValidNumber() {
        assertTrue(activityRule.activity.isValidNumber("022323"))
    }

    @Test
    fun testSavePasswordOnArray(){
        val view = View(activityRule.activity)
        kotlin.run {
            view.tag = 0
            activityRule.activity.numpadClick(view)
            view.tag = 2
            activityRule.activity.numpadClick(view)
            view.tag = 1
            activityRule.activity.numpadClick(view)
            view.tag = 3
            activityRule.activity.numpadClick(view)
            view.tag = 5
            activityRule.activity.numpadClick(view)
            view.tag = 4
            activityRule.activity.numpadClick(view)
        }
        kotlin.run {
            view.tag = 0
            activityRule.activity.numpadClick(view)
            view.tag = 2
            activityRule.activity.numpadClick(view)
            view.tag = 1
            activityRule.activity.numpadClick(view)
            view.tag = 3
            activityRule.activity.numpadClick(view)
            view.tag = 5
            activityRule.activity.numpadClick(view)
            view.tag = 4
            activityRule.activity.numpadClick(view)
        }


        assertTrue(activityRule.activity.comparePasswordsWithStorage())


    }

    @Test
    fun testIsOlderVersionPassword() {
        assertTrue(activityRule.activity.isOlderVersionPassword())
    }



}