Tst: more input simulation functions
[far2l.git] / testing / README.md
blob728aa4289601f59b72c28bf925708d1c6794d1d7
1 To run tests run far2l-smoke-run.sh specifying path to far2l which was built by cmake configured with -DTESTING=Yes  
2 Example: `./far2l-smoke-run.sh ../../far2l.build/install/far2l`  
3 Note: if provided far2l built without testing support this will just stuck.. for now.  
4 Actual tests written in JS and located under test directory. They can use following predefined functions to perform actions:
6 ---------------------------------------------------------
8 `StartApp(["arg1", "arg2" ...])`
10 Starts far2l with given arguments, note that some arguments are implicitly inserted - path to far2l as very first argument and --test=  
11 Returns status of started far2l as structure of following fields:
12  * Width uint32
13  * Height uint32
14  * Title string
16 ---------------------------------------------------------
18 `AppStatus()`
20 Returns actual status of far2l as structure described above.
22 ---------------------------------------------------------
24 `ReadCellRaw(x, y)`
26 Reads screen cell at specified coordinates.  
27 Returns structure which has following fields:
28  * Text string           - string representing contained character
29  * Attributes uint64     - value from corresponding CHAR_INFO::Attributes
31 ---------------------------------------------------------
33 `ReadCell(x, y)`
35 Reads screen cell at specified coordinates.  
36 Returns more 'decomposed' (comparing to Raw version) structure wich has following fields:
37  * Text string           - string representing contained character
38  * BackTC uint32         - 24 bit foreground color if its used
39  * ForeTC uint32         - 24 bit background color if its used
40  * Back uint8            - 4 bit base foreground color
41  * Fore uint8            - 4 bit base background color
42  * IsBackTC bool         - true if 24 bit foreground color is used
43  * IsForeTC bool         - true if 24 bit background color is used
44  * ForeBlue bool         - true if base foreground color has blue component
45  * ForeGreen bool        - true if base foreground color has green component
46  * ForeRed bool          - true if base foreground color has red component
47  * ForeIntense bool      - true if base foreground color has intensified brightness
48  * BackBlue bool         - true if base background color has blue component
49  * BackGreen bool        - true if base background color has green component
50  * BackRed bool          - true if base background color has red component
51  * BackIntense bool      - true if base background color has intensified brightness
52  * ReverseVideo bool     - true if foreground/background colors are swapped at rendering
53  * Underscore bool       - true if character is underscored (not implemented yet)
54  * Strikeout bool        - true if character is striked out (not implemented yet)
56 ---------------------------------------------------------
58 `BoundedLines(left, top, width, height, " \t")`
60 Returns array of lines bounded by specified rectangle.  
61 Optionally trims edges of each line from trim_chars characters if its not empty.
63 ---------------------------------------------------------
65 `SurroundedLines(x, y, "║═│─", " \t")`
67 Returns array of lines bounded by any of specified in boundary_chars characters.  
68 x, y represends coordinates of any cell inside of required area  
69 Optionally trims edges of each line from trim_chars characters if its not empty.
71 ---------------------------------------------------------
73 `CheckCellChar(x, y, "abcdef...")`  
74 `CheckCellCharOrDie(x, y, "abcdef...")`
76 Checks if cell under specified coordinates contains any of characters contained in specified string.  
77 Returns matched character. But if no character matched then:
78  * CheckCellChar returns empty string
79  * CheckCellCharOrDie aborts execution
82 ---------------------------------------------------------
84 `ExpectStrings(["string 1", "string 2" ...], x, y, w, h, timeout_ms)`  
85 `ExpectStringsOrDie(["string 1", "string 2" ...], x, y, w, h, timeout_ms)`
87 Waits given amount of milliseconds for any of given strings will appear in provided rectangular area.  
88 Returns result as structure of following fields, that defines index of found string and its coordinates:
89  * I uint32
90  * X uint32
91  * Y uint32
93 In case no string found before timeout reached:
94  * ExpectStrings returns all fields set to 0xffffffff (-1)
95  * ExpectStringsOrDie aborts execution
97 ---------------------------------------------------------
99 `ExpectString("string", x, y, w, h, timeout_ms)`  
100 `ExpectStringOrDie("string", x, y, w, h, timeout_ms)`
102 Simplified version of ExpectStrings that waits for one string only.  
103 Returns same as ExpectStrings.
105 ---------------------------------------------------------
107 `ExpectAppExit(code, timeout_ms)`  
108 `ExpectAppExitOrDie(code, timeout_ms)`
110 Expects that far2l will exit with specified exit code withing given milliseconds of timeout.  
111 Returns empty string if everything happen as expected, otherwise:
112  * ExpectAppExit returns string with problem description
113  * ExpectAppExitOrDie aborts execution
115 ---------------------------------------------------------
117 `LogInfo("string")`
119 Writes given string to test output.
121 ---------------------------------------------------------
123 `LogFatal("string")`
125 Writes given string to test output and aborts tests.
127 ---------------------------------------------------------
129 `WriteTTY("string")`
131 Writes given string to stdin of pseudoterminal where tested far2l is running.
133 ---------------------------------------------------------
135 `CtrlC()`
137 Generates Ctrl+C for tested far2l.
139 ---------------------------------------------------------
141 `RunCmd(["prog", "arg1", "arg2" ...])`  
142 `RunCmdOrDie(["prog", "arg1", "arg2" ...])`
144 Runs given command, returns empty string if start succeeded and command returned zero code, otherwise returns error description or aborts if its RunCmdOrDie.  
145 Note that command is run NOT in pseudoterminal where tested far2l is running.
147 ---------------------------------------------------------
149 `Sleep(msec)`
151 Pauses execution for specified amount of milliseconds
153 ---------------------------------------------------------
155 `ToggleShift(pressed bool)`
156 `ToggleLCtrl(pressed bool)`
157 `ToggleRCtrl(pressed bool)`
158 `ToggleLAlt(pressed bool)`
159 `ToggleRAlt(pressed bool)`
161 Simulate changing state of specific named control key. Changed state affects all following keypresses.
163 ---------------------------------------------------------
165 `TypeBack`  
166 `TypeEnter`  
167 `TypeEscape`  
168 `TypePageUp`  
169 `TypePageDown`  
170 `TypeEnd`  
171 `TypeHome`  
172 `TypeLeft`  
173 `TypeUp`  
174 `TypeRight`  
175 `TypeDown`  
176 `TypeIns`  
177 `TypeDel`
179 Simulate typing of specific named key
181 ---------------------------------------------------------
183 `TypeAdd`  
184 `TypeSub`  
185 `TypeMul`  
186 `TypeDiv`  
187 `TypeSeparator`  
188 `TypeDecimal`
190 Simulate typing of specific named NumPad key
192 ---------------------------------------------------------
194 `TypeDigit(n)`
196 Simulates typing of specified NumPad digit, where n=0 means 0, n=1 means 1 and so on
198 ---------------------------------------------------------
200 `TypeFKey(n)`
202 Simulates typing of specified F-key, where n=1 means F1, n=2 means F2 and so on
204 ---------------------------------------------------------
206 `TypeText("someText to Type")`
208 Simulates typing of specified text char-by-char according