Home | History | Annotate | Line # | Download | only in gdb.tui
resize-2.exp revision 1.1
      1 # Copyright 2023-2024 Free Software Foundation, Inc.
      2 
      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.
      7 #
      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.
     12 #
     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/>.
     15 
     16 # Test TUI resizing using maint screen info command.
     17 
     18 require allow_tui_tests
     19 
     20 tuiterm_env
     21 
     22 Term::clean_restart 24 80
     23 set screen_dim { 0 0 80 24 }
     24 
     25 # Use a layout with just a command window.
     26 gdb_test "tui new-layout command-layout cmd 1"
     27 
     28 if {![Term::prepare_for_tui]} {
     29     unsupported "TUI not supported"
     30     return 0
     31 }
     32 
     33 # Enter TUI.
     34 Term::command_no_prompt_prefix "layout command-layout"
     35 
     36 proc check_width { what n } {
     37     set re "Number of characters $what thinks are in a line is $n"
     38     Term::check_region_contents "$what width $n" {*}$::screen_dim $re
     39 }
     40 
     41 # Check that curses has the correct notion of screen width.
     42 Term::command "maint info screen"
     43 check_width curses 80
     44 check_width gdb 80
     45 
     46 # Resize with TUI enabled, wait for the resize message.
     47 Term::resize 40 90
     48 set screen_dim { 0 0 90 40 }
     49 
     50 # Check that curses has the correct notion of screen width after resize.
     51 Term::command "maint info screen"
     52 check_width curses 90
     53 check_width gdb 90
     54 
     55 # Temporarily disable TUI.
     56 gdb_test_multiple "tui disable" "" {
     57     -re "$gdb_prompt $" {
     58 	pass $gdb_test_name
     59     }
     60 }
     61 
     62 # Resize with TUI disabled, so don't wait for the resize message.
     63 Term::resize 24 80 0
     64 set screen_dim { 0 0 80 24 }
     65 gdb_test_multiple "" "two prompt redisplays after resize" {
     66     -re "\r.*$gdb_prompt \r.*$gdb_prompt $" {
     67 	pass $gdb_test_name
     68     }
     69 }
     70 
     71 # At this point, curses still thinks the width is 90.  This doesn't look
     72 # harmful because TUI is disabled.
     73 gdb_test "maint info screen" \
     74     "\r\nNumber of characters curses thinks are in a line is 90.\\r\n.*" \
     75     "curses width after resize with TUI disabled"
     76 
     77 # Re-enable TUI.
     78 send_gdb "tui enable\n"
     79 # The "tui enable" command is issued on the CLI screen, on the TUI we have the
     80 # last command issued there: "tui disable".
     81 Term::wait_for "tui disable"
     82 
     83 # Check that curses has the correct notion of screen width after screen resize
     84 # with TUI disabled.
     85 Term::command "maint info screen"
     86 with_test_prefix again {
     87     check_width curses 80
     88     check_width gdb 80
     89 }
     90