Skip to content

Commit

Permalink
test: Use input_text("\n") instead of key("Enter") in most places
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer authored and martinpitt committed Jul 18, 2024
1 parent d363278 commit 60ca4b4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 28 deletions.
3 changes: 1 addition & 2 deletions test/verify/check-pages
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ OnCalendar=daily

# b.wait_visible(".terminal .xterm-accessibility-tree")
# b.wait_in_text(line_sel(1), "admin")
# b.input_text("echo $LANG")
# b.key("Enter")
# b.input_text("echo $LANG\n")
# b.wait_in_text(line_sel(2), locale)

b.switch_to_top()
Expand Down
3 changes: 1 addition & 2 deletions test/verify/check-selinux
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ class TestSelinux(testlib.MachineCase):
b.go("/system/terminal")
b.enter_page("/system/terminal")
b.focus('.terminal')
b.input_text('"')
b.key("Enter")
b.input_text('"\n')
# Right click and paste
b.mouse(".terminal", "contextmenu", btn=2)
b.click('.contextMenu li:nth-child(2) button')
Expand Down
3 changes: 1 addition & 2 deletions test/verify/check-shell-active-pages
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class TestActivePages(testlib.MachineCase):
b.wait_in_text(line_sel(1), '$')

# run a command that we can easily identify, and which will die with the terminal
b.input_text("bash -c 'exec -a kitten cat'")
b.key("Enter")
b.input_text("bash -c 'exec -a kitten cat'\n")

# wait for command to run
m.execute("until pgrep -afx kitten; do sleep 1; done")
Expand Down
6 changes: 2 additions & 4 deletions test/verify/check-system-realms
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,7 @@ ipa-advise enable-admins-sudo | sh -ex
b.open("/system/terminal")
b.enter_page("/system/terminal")
b.wait_in_text(".terminal .xterm-accessibility-tree", "alice")
b.input_text("klist")
b.key("Enter")
b.input_text("klist\n")
b.wait_in_text(".terminal .xterm-accessibility-tree", "Ticket cache: FILE:/run/user")
b.wait_in_text(".terminal .xterm-accessibility-tree", "Default principal: [email protected]")
b.wait_in_text(".terminal .xterm-accessibility-tree", "for client HTTP/[email protected]")
Expand Down Expand Up @@ -1057,8 +1056,7 @@ class TestKerberos(testlib.MachineCase):
b.enter_page("/system/terminal")
# wait for prompt
b.wait_in_text(".terminal .xterm-accessibility-tree", "admin")
b.input_text("klist")
b.key("Enter")
b.input_text("klist\n")
b.wait_in_text(".terminal .xterm-accessibility-tree", "Ticket cache")
b.wait_in_text(".terminal .xterm-accessibility-tree", "Default principal: [email protected]")
b.wait_in_text(".terminal .xterm-accessibility-tree", "krbtgt/COCKPIT.LAN")
Expand Down
27 changes: 9 additions & 18 deletions test/verify/check-system-terminal
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,19 @@ PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/
self.assertIn("~]$", prompt)

# Run some commands
b.input_text("whoami")
b.key("Enter")
b.input_text("whoami\n")
wait_line(n + 1, "admin")

wait_line(n + 2, prompt)

b.input_text('echo -e "1\\u0041"')
b.key("Enter")
b.input_text('echo -e "1\\u0041"\n')
wait_line(n + 3, '1A')

# The '@' sign is in the default prompt
b.wait_in_text(".terminal-title", '@')

# output flooding
b.input_text("seq 1000000")
b.key("Enter")
b.input_text("seq 1000000\n")
with b.wait_timeout(300):
b.wait_in_text(".terminal .xterm-accessibility-tree", "9999989999991000000admin@")

Expand All @@ -114,8 +111,7 @@ PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/
self.assertNotIn('admin', b.text(line_sel(n + 1)))

# Check that when we `exit` we can still reconnect with the 'Reset' button
b.input_text("exit")
b.key("Enter")
b.input_text("exit\n")
b.wait_in_text(".terminal .xterm-accessibility-tree", "disconnected")
b.click('button:contains("Reset")')
wait_line(n, prompt)
Expand All @@ -139,8 +135,7 @@ PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/

# Execute command
wait_line(n, prompt)
b.input_text('echo "XYZ"')
b.key("Enter")
b.input_text('echo "XYZ"\n')
echo_result_line = n + 1

wait_line(echo_result_line, "XYZ")
Expand Down Expand Up @@ -173,8 +168,7 @@ PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/

# Execute another command
wait_line(n, prompt)
b.input_text('echo "foo"')
b.key("Enter")
b.input_text('echo "foo"\n')
echo_result_line = n + 1

wait_line(echo_result_line, "foo")
Expand All @@ -192,10 +186,8 @@ PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/

# check that we get a sensible $PATH; this varies across OSes, so don't be too strict about it
b.key("Enter")
b.input_text('clear')
b.key("Enter")
b.input_text("echo $PATH > /tmp/path")
b.key("Enter")
b.input_text('clear\n')
b.input_text("echo $PATH > /tmp/path\n")
# don't use wait_line() for the full match here, as line breaks get in the way; just wait until command has run
wait_line(echo_result_line, prompt)
path = m.execute("cat /tmp/path").strip()
Expand Down Expand Up @@ -266,8 +258,7 @@ PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/

# execute a command we can see the effect of
b.wait_js_cond("ph_text('.terminal').indexOf('uid=') == -1")
b.input_text("id")
b.key("Enter")
b.input_text("id\n")
b.wait_js_cond("ph_text('.terminal').indexOf('uid=') >= 0")


Expand Down

0 comments on commit 60ca4b4

Please sign in to comment.