#!/usr/bin/env python3
from controlfloor import *

def taptext_test():
    relaunchApplication("com.dryark.CFAUIInspector")
    tap( "textFieldDefault" )
    tapText( "The quick brown fox jumps over the lazy dog." )
    typeSpecialKey( "Backspace" )
    typeSpecialKey( "Backspace" )
    typeSpecialKey( "Backspace" )
    typeSpecialKey( "Backspace" )
    tapText( "cat.\n\n" )
    tap( "textFieldASCIICapable" )
    tapText( "This is the ascii field" )
    tap( "textFieldNumbersAndPunctuation" )
    tapText( "Numeric" )
    tap( "textFieldDecimalPad" )
    assert tapText( "These letters will be ignored.", allow_errors = True ).error
    tapText( "123.45." )
    tap( "textFieldCapAll" )
    tapText( "capall field" )
    tap( "secureTextFieldDefault" )
    tapText( "Secure Text Field Password?" )
    tap( "textFieldNamePhonePad" )
    tapText( "Test arrow" )
    typeSpecialKey( "ArrowLeft" )
    typeSpecialKey( "ArrowLeft" )
    typeSpecialKey( "ArrowLeft" )
    typeSpecialKey( "ArrowLeft" )
    typeSpecialKey( "ArrowLeft" )
    tapText( "if " )
    typeSpecialKey( "ArrowRight" )
    typeSpecialKey( "ArrowRight" )
    typeSpecialKey( "ArrowRight" )
    typeSpecialKey( "ArrowRight" )
    typeSpecialKey( "ArrowRight" )
    tapText( " works" )
    elements = getNamedInputElements()
    assert elements.textFieldDefault.value == "The quick brown fox jumps over the lazy cat."
    assert elements.textFieldASCIICapable.value == "This is the ascii field"
    assert elements.textFieldNumbersAndPunctuation.value == "Numeric"
    assert elements.textFieldURL.value == ""
    assert elements.textFieldWebSearch.value == ""
    assert elements.textFieldTwitter.value == ""
    assert elements.textFieldEmailAddress.value == ""
    assert elements.textFieldNumberPad.value == ""
    assert elements.textFieldASCIICapableNumberPad.value == ""
    assert elements.textFieldDecimalPad.value == "123.45."
    assert elements.textFieldPhonePad.value == ""
    assert elements.textFieldNamePhonePad.value == "Test if arrow works"
    assert elements.secureTextFieldDefault.value == "•••••••••••••••••••••••••••"
    assert elements.textFieldCapAll.value == "capall field"
    assert elements.textFieldCapWords.value == ""
    assert elements.textFieldTimerResult.value == ""
    assert elements.textViewDefault.value == "Secure Text Field Password?"

cfrun(__name__,taptext_test)
