Home | History | Annotate | Line # | Download | only in gdb.python
      1  1.1.1.3  christos # Copyright (C) 2020-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 a TUI window implemented in Python.
     17      1.1  christos 
     18      1.1  christos load_lib gdb-python.exp
     19  1.1.1.3  christos require allow_python_tests allow_tui_tests
     20      1.1  christos tuiterm_env
     21      1.1  christos 
     22      1.1  christos # This test doesn't care about the inferior.
     23      1.1  christos standard_testfile py-arch.c
     24      1.1  christos 
     25      1.1  christos if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
     26      1.1  christos     return -1
     27      1.1  christos }
     28      1.1  christos 
     29  1.1.1.2  christos clean_restart
     30  1.1.1.2  christos 
     31      1.1  christos Term::clean_restart 24 80 $testfile
     32      1.1  christos 
     33      1.1  christos set remote_python_file [gdb_remote_download host \
     34      1.1  christos 			    ${srcdir}/${subdir}/${testfile}.py]
     35      1.1  christos gdb_test_no_output "source ${remote_python_file}" \
     36      1.1  christos     "source ${testfile}.py"
     37      1.1  christos 
     38      1.1  christos gdb_test_no_output "tui new-layout test test 1 status 0 cmd 1"
     39      1.1  christos gdb_test_no_output "tui new-layout fail fail 1 status 0 cmd 1"
     40      1.1  christos 
     41      1.1  christos if {![Term::enter_tui]} {
     42      1.1  christos     unsupported "TUI not supported"
     43  1.1.1.3  christos     return
     44      1.1  christos }
     45      1.1  christos 
     46  1.1.1.4  christos Term::command "python print('tui_enabled=' + str(tui_enabled))"
     47  1.1.1.4  christos Term::check_contents "tui start event" "tui_enabled=True"
     48  1.1.1.4  christos 
     49      1.1  christos Term::command "layout test"
     50      1.1  christos Term::check_contents "test title" \
     51      1.1  christos     "This Is The Title"
     52      1.1  christos Term::check_contents "Window display" "Test: 0"
     53      1.1  christos 
     54  1.1.1.2  christos Term::command "python delete_window_title ()"
     55  1.1.1.2  christos Term::check_contents "error message after trying to delete title" \
     56  1.1.1.3  christos     "TypeError.*: Cannot delete \"title\" attribute\\."
     57  1.1.1.2  christos Term::check_contents "title is unchanged" \
     58  1.1.1.2  christos     "This Is The Title"
     59  1.1.1.2  christos 
     60  1.1.1.3  christos Term::command "python change_window_title ()"
     61  1.1.1.3  christos Term::check_contents "test new title" \
     62  1.1.1.3  christos     "New Title"
     63  1.1.1.3  christos 
     64      1.1  christos Term::resize 51 51
     65      1.1  christos # Remember that a resize request actually does two resizes...
     66      1.1  christos Term::check_contents "Window was updated" "Test: 2"
     67      1.1  christos 
     68      1.1  christos Term::command "layout fail"
     69  1.1.1.4  christos 
     70  1.1.1.4  christos Term::command "tui disable"
     71  1.1.1.4  christos gdb_test "python print('tui_enabled=' + str(tui_enabled))" \
     72  1.1.1.4  christos     "tui_enabled=False" \
     73  1.1.1.4  christos     "tui disable event"
     74