Home | History | Annotate | Line # | Download | only in gdb.tui
      1      1.1  christos # Copyright 2023-2024 Free Software Foundation, Inc.
      2      1.1  christos 
      3      1.1  christos # This program is free software; you can redistribute it and/or modify
      4      1.1  christos # it under the terms of the GNU General Public License as published by
      5      1.1  christos # the Free Software Foundation; either version 3 of the License, or
      6      1.1  christos # (at your option) any later version.
      7      1.1  christos #
      8      1.1  christos # This program is distributed in the hope that it will be useful,
      9      1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10      1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11      1.1  christos # GNU General Public License for more details.
     12      1.1  christos #
     13      1.1  christos # You should have received a copy of the GNU General Public License
     14      1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15      1.1  christos 
     16      1.1  christos # Test TUI resizing using maint screen info command.
     17      1.1  christos 
     18      1.1  christos require allow_tui_tests
     19      1.1  christos 
     20      1.1  christos tuiterm_env
     21      1.1  christos 
     22      1.1  christos Term::clean_restart 24 80
     23      1.1  christos set screen_dim { 0 0 80 24 }
     24      1.1  christos 
     25      1.1  christos # Use a layout with just a command window.
     26      1.1  christos gdb_test "tui new-layout command-layout cmd 1"
     27      1.1  christos 
     28      1.1  christos if {![Term::prepare_for_tui]} {
     29      1.1  christos     unsupported "TUI not supported"
     30      1.1  christos     return 0
     31      1.1  christos }
     32      1.1  christos 
     33      1.1  christos # Enter TUI.
     34      1.1  christos Term::command_no_prompt_prefix "layout command-layout"
     35      1.1  christos 
     36      1.1  christos proc check_width { what n } {
     37      1.1  christos     set re "Number of characters $what thinks are in a line is $n"
     38      1.1  christos     Term::check_region_contents "$what width $n" {*}$::screen_dim $re
     39      1.1  christos }
     40      1.1  christos 
     41      1.1  christos # Check that curses has the correct notion of screen width.
     42      1.1  christos Term::command "maint info screen"
     43      1.1  christos check_width curses 80
     44      1.1  christos check_width gdb 80
     45      1.1  christos 
     46      1.1  christos # Resize with TUI enabled, wait for the resize message.
     47      1.1  christos Term::resize 40 90
     48      1.1  christos set screen_dim { 0 0 90 40 }
     49      1.1  christos 
     50      1.1  christos # Check that curses has the correct notion of screen width after resize.
     51      1.1  christos Term::command "maint info screen"
     52      1.1  christos check_width curses 90
     53      1.1  christos check_width gdb 90
     54      1.1  christos 
     55      1.1  christos # Temporarily disable TUI.
     56      1.1  christos gdb_test_multiple "tui disable" "" {
     57      1.1  christos     -re "$gdb_prompt $" {
     58      1.1  christos 	pass $gdb_test_name
     59      1.1  christos     }
     60      1.1  christos }
     61      1.1  christos 
     62  1.1.1.2  christos # Resize with TUI disabled, so don't wait for the resize message.  Instead,
     63  1.1.1.2  christos # do it in two steps, and wait for a prompt redisplay for each.  If we do
     64  1.1.1.2  christos # this in one step, it's unpredictable how may prompt redisplays we'll get.
     65  1.1.1.2  christos Term::resize 24 90 0
     66  1.1.1.2  christos set screen_dim { 0 0 90 24 }
     67  1.1.1.2  christos 
     68  1.1.1.2  christos gdb_test_multiple "" "prompt redisplays after first resize" {
     69  1.1.1.2  christos     -re "\r.*$gdb_prompt $" {
     70  1.1.1.2  christos 	pass $gdb_test_name
     71  1.1.1.2  christos     }
     72  1.1.1.2  christos }
     73  1.1.1.2  christos 
     74      1.1  christos Term::resize 24 80 0
     75      1.1  christos set screen_dim { 0 0 80 24 }
     76  1.1.1.2  christos 
     77  1.1.1.2  christos gdb_test_multiple "" "prompt redisplays after second resize" {
     78  1.1.1.2  christos     -re "\r.*$gdb_prompt $" {
     79      1.1  christos 	pass $gdb_test_name
     80      1.1  christos     }
     81      1.1  christos }
     82      1.1  christos 
     83      1.1  christos # At this point, curses still thinks the width is 90.  This doesn't look
     84      1.1  christos # harmful because TUI is disabled.
     85      1.1  christos gdb_test "maint info screen" \
     86      1.1  christos     "\r\nNumber of characters curses thinks are in a line is 90.\\r\n.*" \
     87      1.1  christos     "curses width after resize with TUI disabled"
     88      1.1  christos 
     89      1.1  christos # Re-enable TUI.
     90      1.1  christos send_gdb "tui enable\n"
     91      1.1  christos # The "tui enable" command is issued on the CLI screen, on the TUI we have the
     92      1.1  christos # last command issued there: "tui disable".
     93      1.1  christos Term::wait_for "tui disable"
     94      1.1  christos 
     95      1.1  christos # Check that curses has the correct notion of screen width after screen resize
     96      1.1  christos # with TUI disabled.
     97      1.1  christos Term::command "maint info screen"
     98      1.1  christos with_test_prefix again {
     99      1.1  christos     check_width curses 80
    100      1.1  christos     check_width gdb 80
    101      1.1  christos }
    102