1 # Copyright
2020-2024 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this
program.
If not
, see
<http
://www.gnu.org
/licenses
/>.
16 # Test
"tui new-layout".
20 standard_testfile tui
-layout.c
22 if {[build_executable
"failed to prepare" ${testfile} ${srcfile}] == -1} {
26 # Make sure TUI is supported before continuing.
27 with_test_prefix
"initial check" {
28 Term
::clean_restart
24 80 $testfile
29 if {![Term
::enter_tui
]} {
30 unsupported
"TUI not supported"
35 Term
::clean_restart
24 80 $testfile
37 gdb_test
"tui new-layout" \
38 "No layout name specified"
39 gdb_test
"tui new-layout example" \
40 "New layout does not contain any windows"
41 gdb_test
"tui new-layout example zzq" \
42 "Unknown window \"zzq\""
43 gdb_test
"tui new-layout example src 1 src 1" \
44 "Window \"src\" seen twice in layout"
45 gdb_test
"tui new-layout example src 1" \
46 "New layout does not contain the \"cmd\" window"
48 # Avoid unbalanced curly braces problems with tcl
8.5.
49 if { [tcl_version_at_least
8 6] } {
50 gdb_test
"tui new-layout example src 1\}" \
51 "Extra '\}' in layout specification"
52 gdb_test
"tui new-layout example {src 1} 1\}" \
53 "Extra '\}' in layout specification"
54 gdb_test
"tui new-layout example \{src 1" \
55 "Missing '\}' in layout specification"
58 # Each entry of this list describes a layout
, and some associated
59 # tests. The items within each entry are
:
61 #
2. a string used to create the layout
,
62 #
3. a list of boxes to check
for once the layout is selected
,
63 #
4. a regexp to match against the whole screen contents
, this
64 # can be empty to skip this check.
67 [list example
"asm 1 status 0 cmd 1" \
68 {{0 0 80 15}} "$hex <main>"] \
69 [list example2
"{asm 1 status 0} 1 cmd 1" \
71 [list h
"{-horizontal asm 1 src 1} 1 status 0 cmd 1" \
72 {{0 0 40 15} {39 0 41 15}} \
73 "$hex <main>.*21.*return 0"] \
74 [list example3
"{-horizontal src 1 cmd 1} 1 status 0 asm 1" \
75 {{0 0 40 11} {0 12 80 12}} \
76 "21.*return 0.*$hex <main>"] \
77 [list example4
"src 1 status 0 {-horizontal cmd 1 regs 1} 1" \
78 {{0 0 80 11} {40 12 40 12}} ""] \
79 [list example5
"{-horizontal src 1 cmd 1} 1 status 0" \
81 [list cmd_only
"cmd 1" {} ""]]
83 # Helper function to verify a list of boxes.
84 proc check_boxes
{boxes
} {
87 eval Term
::check_box
[list
"box $boxno"] $box
92 # Now create the layouts.
93 foreach layout $layouts
{
94 lassign $layout
name desc
95 gdb_test_no_output
"tui new-layout $name $desc"
96 gdb_test
"help layout $name" \
97 "Apply the \"$name\" layout.*tui new-layout $name $desc"
100 if {![Term
::enter_tui
]} {
101 unsupported
"TUI not supported"
105 set text [Term
::get_all_lines
]
106 gdb_assert
{![string match
"No Source Available" $text]} \
107 "initial source listing"
109 foreach_with_prefix layout $layouts
{
110 lassign $layout
name desc boxes content_pattern
112 # Reset the layout to a known starting configuration.
113 Term
::command
"layout src"
114 Term
::command
"winheight cmd 8"
116 # Apply our test layout.
117 Term
::command
"layout $name"
120 if {$content_pattern
!= ""} {
121 Term
::check_contents
"contents in layout $name" \
125 # Some additional tests
for the
'h' layout.
127 Term
::command
"winheight src - 5"
128 Term
::check_box
"left window box after shrink" 0 0 40 10
129 Term
::check_box
"right window box after shrink" 39 0 41 10
131 Term
::command
"winheight src + 5"
132 Term
::check_box
"left window box after grow" 0 0 40 15
133 Term
::check_box
"right window box after grow" 39 0 41 15
134 } elseif
{$
name == "cmd_only"} {
135 Term
::check_region_contents
"bottom of cmd window is blank" \
137 Term
::command
"info win"
138 Term
::check_region_contents
"info win output" \
139 0 0 80 24 [multi_line
"info win\\s+" \
140 "Name\\s+Lines\\s+Columns\\s+Focus\\s+" \
141 "cmd\\s+24\\s+80\\s+\\(has focus\\)\\s+" \
146 Term
::command
"layout src"
147 Term
::command
"winheight cmd 8"
148 Term
::check_box
"before cmd_only: src box in src layout" 0 0 80 15
150 Term
::command
"layout cmd_only"
152 Term
::command
"layout src"
153 Term
::check_box
"after cmd_only: src box in src layout" 0 0 80 15