From 4fffac5a9ad9d2a3c273785ffc7b308dac2d066c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 4 Jun 2008 20:16:55 +0000 Subject: [PATCH] 2008-06-04 22:13 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * tests/rto_get.prg + Added keypress emulator to aid automated testing. + Added test for EMG's bug case. [RC1] --- harbour-RC1/ChangeLog | 6 +++ harbour-RC1/tests/rto_get.prg | 87 ++++++++++++++++++++++++----------- 2 files changed, 65 insertions(+), 28 deletions(-) diff --git a/harbour-RC1/ChangeLog b/harbour-RC1/ChangeLog index 9285d8e57c..e8dc5a3fdb 100644 --- a/harbour-RC1/ChangeLog +++ b/harbour-RC1/ChangeLog @@ -8,6 +8,12 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-06-04 22:13 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + * tests/rto_get.prg + + Added keypress emulator to aid automated testing. + + Added test for EMG's bug case. + [RC1] + 2008-06-04 19:54 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/hbsqlit3/hbsqlit3.c ! Removed 'HB_VER_MAJOR < 1' version check, as it diff --git a/harbour-RC1/tests/rto_get.prg b/harbour-RC1/tests/rto_get.prg index 9c562519fb..9354d7aaa7 100644 --- a/harbour-RC1/tests/rto_get.prg +++ b/harbour-RC1/tests/rto_get.prg @@ -55,6 +55,7 @@ #include "common.ch" #include "error.ch" #include "fileio.ch" +#include "inkey.ch" #ifndef __HARBOUR__ #define hb_OSNewLine() ( Chr( 13 ) + Chr( 10 ) ) @@ -282,21 +283,21 @@ FUNCTION Main( cArg01, cArg02, cArg03, cArg04 ) SetPos( 14, 16 ) ; o := _GET_( cStr07, "cStr07", "@R 999 9999 999999",, ) o:display() o:setFocus() - TGetTOVS( o, "1231234123456" ) + TGetTOVS( o, { "1231234123456" } ) TEST_LINE( o:Assign() ) cStr07 := Space(10) SetPos( 14, 16 ) ; o := _GET_( cStr07, "cStr07", "@R 999 9999 999999",, ) o:display() o:setFocus() - TGetTOVS( o, "1231234123456" ) + TGetTOVS( o, { "1231234123456" } ) TEST_LINE( o:Assign() ) cStr07 := Space(10) SetPos( 14, 16 ) ; o := _GET_( cStr07, "cStr07", "@R 999 9999 999999",, ) o:display() o:setFocus() - TGetTOVS( o, "1231234123456" ) + TGetTOVS( o, { "1231234123456" } ) TEST_LINE( o:Assign() ) // ; @@ -305,21 +306,21 @@ FUNCTION Main( cArg01, cArg02, cArg03, cArg04 ) SetPos( 14, 16 ) ; o := _GET_( cStr07, "cStr07", "@ER 999 9999 999999",, ) o:display() o:setFocus() - TGetTOVS( o, "1231234123456" ) + TGetTOVS( o, { "1231234123456" } ) TEST_LINE( o:Assign() ) cStr07 := Space(10) SetPos( 14, 16 ) ; o := _GET_( cStr07, "cStr07", "@ER 999 9999 999999",, ) o:display() o:setFocus() - TGetTOVS( o, "1231234123456" ) + TGetTOVS( o, { "1231234123456" } ) TEST_LINE( o:Assign() ) cStr07 := Space(10) SetPos( 14, 16 ) ; o := _GET_( cStr07, "cStr07", "@ER 999 9999 999999",, ) o:display() o:setFocus() - TGetTOVS( o, "1231234123456" ) + TGetTOVS( o, { "1231234123456" } ) TEST_LINE( o:Assign() ) // ; Edmer #2 @@ -328,7 +329,7 @@ FUNCTION Main( cArg01, cArg02, cArg03, cArg04 ) SetPos( 14, 16 ) ; o := _GET_( nInt02, "nInt02", "9,999,999.99",, ) o:display() o:setFocus() - TGetTOVS( o, "12345" ) + TGetTOVS( o, { "12345" } ) TEST_LINE( o:Assign() ) // ; @@ -337,7 +338,16 @@ FUNCTION Main( cArg01, cArg02, cArg03, cArg04 ) SetPos( 14, 16 ) ; o := _GET_( nInt02, "nInt02", "@E 9,999,999.9999",, ) o:display() o:setFocus() - TGetTOVS( o, "12345" ) + TGetTOVS( o, { "12345" } ) + TEST_LINE( o:Assign() ) + + // ; EMG + + nInt02 := 0 + SetPos( 14, 16 ) ; o := _GET_( nInt02, "nInt02", "@EZ 999,999.99",, ) + o:display() + o:setFocus() + TGetTOVS( o, { "1", K_RIGHT } ) TEST_LINE( o:Assign() ) // ; @@ -581,14 +591,14 @@ FUNCTION Main( cArg01, cArg02, cArg03, cArg04 ) o := _GET_( dDate01, "dDate01" ) TEST_LINE( OBJ_CREATE() ) TEST_LINE( o:SetFocus() ) - TGetTOVS( o, "12345678" ) + TGetTOVS( o, { "12345678" } ) TEST_LINE( o:KillFocus() ) SetPos( 14, 16 ) ; dDate01 := hb_SToD( "20070425" ) o := _GET_( dDate01, "dDate01", "@E" ) TEST_LINE( OBJ_CREATE() ) TEST_LINE( o:SetFocus() ) - TGetTOVS( o, "12345678" ) + TGetTOVS( o, { "12345678" } ) TEST_LINE( o:KillFocus() ) SET CENTURY OFF @@ -597,42 +607,42 @@ FUNCTION Main( cArg01, cArg02, cArg03, cArg04 ) o := _GET_( dDate01, "dDate01" ) TEST_LINE( OBJ_CREATE() ) TEST_LINE( o:SetFocus() ) - TGetTOVS( o, "12345678" ) + TGetTOVS( o, { "12345678" } ) TEST_LINE( o:KillFocus() ) SetPos( 14, 16 ) ; dDate01 := hb_SToD( "20070425" ) o := _GET_( dDate01, "dDate01", "@E" ) TEST_LINE( OBJ_CREATE() ) TEST_LINE( o:SetFocus() ) - TGetTOVS( o, "12345678" ) + TGetTOVS( o, { "12345678" } ) TEST_LINE( o:KillFocus() ) SetPos( 14, 16 ) ; cStr01 := "hello world" o := _GET_( cStr01, "cStr01", "!!LY!!!!!!" ) TEST_LINE( OBJ_CREATE() ) TEST_LINE( o:SetFocus() ) - TGetTOVS( o, "12345678" ) + TGetTOVS( o, { "12345678" } ) TEST_LINE( o:KillFocus() ) SetPos( 14, 16 ) ; cStr01 := "hello world" o := _GET_( cStr01, "cStr01", "!!!.!!!!!!" ) TEST_LINE( OBJ_CREATE() ) TEST_LINE( o:SetFocus() ) - TGetTOVS( o, "12345678" ) + TGetTOVS( o, { "12345678" } ) TEST_LINE( o:KillFocus() ) SetPos( 14, 16 ) ; cStr01 := "hello world" o := _GET_( cStr01, "cStr01", "@R !!LY!!!!!!" ) TEST_LINE( OBJ_CREATE() ) TEST_LINE( o:SetFocus() ) - TGetTOVS( o, "12345678" ) + TGetTOVS( o, { "12345678" } ) TEST_LINE( o:KillFocus() ) SetPos( 14, 16 ) ; cStr01 := "hello world" o := _GET_( cStr01, "cStr01", "@R !!!.!!!!!!" ) TEST_LINE( OBJ_CREATE() ) TEST_LINE( o:SetFocus() ) - TGetTOVS( o, "12345678" ) + TGetTOVS( o, { "12345678" } ) TEST_LINE( o:KillFocus() ) // ; Exercises @@ -663,23 +673,44 @@ FUNCTION Main( cArg01, cArg02, cArg03, cArg04 ) RETURN 0 -PROCEDURE TGetTOVS( o, cKeys ) - LOCAL tmp +PROCEDURE TGetTOVS( o, aKeys, lInsert ) + LOCAL tmp, tmp1 - FOR tmp := 1 TO Len( cKeys ) - TEST_CALL( o, "o:overStrike( '" + SubStr( cKeys, tmp, 1 ) + "' )", {|| o:overStrike( SubStr( cKeys, tmp, 1 ) ) } ) + DEFAULT lInsert TO .F. + + FOR tmp := 1 TO Len( aKeys ) + IF ISCHAR( aKeys[ tmp ] ) + FOR tmp1 := 1 TO Len( aKeys[ tmp ] ) + IF lInsert + TEST_CALL( o, "o:insert( '" + SubStr( aKeys[ tmp ], tmp1, 1 ) + "' )", {|| o:insert( SubStr( aKeys[ tmp ], tmp1, 1 ) ) } ) + ELSE + TEST_CALL( o, "o:overStrike( '" + SubStr( aKeys[ tmp ], tmp1, 1 ) + "' )", {|| o:overStrike( SubStr( aKeys[ tmp ], tmp1, 1 ) ) } ) + ENDIF + NEXT + ELSEIF ISNUM( aKeys[ tmp ] ) + DO CASE + CASE aKeys[ tmp ] == K_INS ; lInsert := ! lInsert + CASE aKeys[ tmp ] == K_HOME ; TEST_LINE( oGet:Home() ) + CASE aKeys[ tmp ] == K_END ; TEST_LINE( oGet:End() ) + CASE aKeys[ tmp ] == K_RIGHT ; TEST_LINE( oGet:Right() ) + CASE aKeys[ tmp ] == K_LEFT ; TEST_LINE( oGet:Left() ) + CASE aKeys[ tmp ] == K_CTRL_RIGHT ; TEST_LINE( oGet:WordRight() ) + CASE aKeys[ tmp ] == K_CTRL_LEFT ; TEST_LINE( oGet:WordLeft() ) + CASE aKeys[ tmp ] == K_BS ; TEST_LINE( oGet:BackSpace() ) + CASE aKeys[ tmp ] == K_DEL ; TEST_LINE( oGet:Delete() ) + CASE aKeys[ tmp ] == K_CTRL_T ; TEST_LINE( oGet:DelWordRight() ) + CASE aKeys[ tmp ] == K_CTRL_Y ; TEST_LINE( oGet:DelEnd() ) + CASE aKeys[ tmp ] == K_CTRL_BS ; TEST_LINE( oGet:DelWordLeft() ) + CASE aKeys[ tmp ] == K_CTRL_U ; TEST_LINE( oGet:Undo() ) + CASE o:type == "N" .AND. Chr( aKeys[ tmp ] ) $ ".," ; TEST_LINE( oGet:ToDecPos() ) + ENDCASE + ENDIF NEXT RETURN -PROCEDURE TGetTIns( o, cKeys ) - LOCAL tmp - - FOR tmp := 1 TO Len( cKeys ) - TEST_CALL( o, "o:insert( '" + SubStr( cKeys, tmp, 1 ) + "' )", {|| o:insert( SubStr( cKeys, tmp, 1 ) ) } ) - NEXT - - RETURN +PROCEDURE TGetTIns( o, aKeys ) + RETURN TGetTOVS( o, aKeys, .T. ) PROCEDURE TGetAssign( xVar ) LOCAL o