starter-kit/test/check-application
Benjamin Graham 5283e234a1 Fixed and simplified tests
Gave buttons IDs for ease of access, fixed `fit-to` testing to
better reflect purpose, and fixed occasional timing error in
`testSkipFrame` caused by call overlap
2020-06-03 10:00:11 -04:00

138 lines
5 KiB
Python
Executable file

#!/usr/bin/python3
# Run this with --help to see available options for tracing and debugging
# See https://github.com/cockpit-project/cockpit/blob/master/test/common/testlib.py
# "class Browser" and "class MachineCase" for the available API.
import os
import sys
# import Cockpit's machinery for test VMs and its browser test API
TEST_DIR = os.path.dirname(__file__)
sys.path.append(os.path.join(TEST_DIR, "common"))
sys.path.append(os.path.join(os.path.dirname(TEST_DIR), "bots/machine"))
from testlib import *
# Test with pre-recorded journal with tlog UID 981
class TestApplication(MachineCase):
def testPlay(self):
term_first_line = ".xterm-accessibility-tree div:nth-child(1)"
b = self.browser
m = self.machine
self.login_and_go("/session-recording")
b.wait_present(".content-header-extra")
b.wait_present("#user")
b.click(".listing-ct-item")
b.click("#player-play-pause")
b.wait_timeout(30000)
b.wait_in_text(term_first_line, "localhost")
def testFastforwardControls(self):
last_term_line = ".xterm-accessibility-tree > div:nth-child(26)"
slider = ".slider > .min-slider-handle"
b = self.browser
m = self.machine
self.login_and_go("/session-recording")
b.wait_present(".content-header-extra")
b.wait_present("#user")
b.click(".listing-ct-item")
b.click("#player-fast-forward")
b.wait_in_text(last_term_line, "logout")
b.wait_attr(slider, "style", "left: 100%;")
# test restart playback
b.click("#player-restart")
b.wait_text(".xterm-accessibility-tree > div:nth-child(1)", "Blank line")
b.wait_attr(slider, "style", "left: 100%;")
def testSpeedControls(self):
speed_val = "#player-speed"
b = self.browser
m = self.machine
self.login_and_go("/session-recording")
b.wait_present(".content-header-extra")
b.wait_present("#user")
b.click(".listing-ct-item")
# increase speed
b.wait_present("#player-speed-up")
b.click("#player-speed-up")
b.wait_present(speed_val)
b.wait_text(speed_val, "x2")
b.click("#player-speed-up")
b.wait_text(speed_val, "x4")
b.click("#player-speed-up")
b.wait_text(speed_val, "x8")
b.click("#player-speed-up")
b.wait_text(speed_val, "x16")
# decrease speed
b.click("#player-speed-down")
b.wait_text(speed_val, "x8")
b.click("#player-speed-down")
b.wait_text(speed_val, "x4")
b.click("#player-speed-down")
b.wait_text(speed_val, "x2")
b.click("#player-speed-down")
b.wait_present(speed_val)
b.click("#player-speed-down")
b.wait_text(speed_val, "/2")
b.click("#player-speed-down")
b.wait_text(speed_val, "/4")
b.click("#player-speed-down")
b.wait_text(speed_val, "/8")
b.click("#player-speed-down")
b.wait_text(speed_val, "/16")
# restore speed
b.click("#player-speed-reset")
b.wait_present(speed_val)
b.click("#player-speed-down")
b.wait_text(speed_val, "/2")
def testZoomControls(self):
default_scale_sel = '.console-ct[style^="transform: scale(1)"]'
zoom_one_scale_sel = '.console-ct[style^="transform: scale(1.1)"]'
zoom_two_scale_sel = '.console-ct[style^="transform: scale(1.2)"]'
zoom_three_scale_sel = '.console-ct[style^="transform: scale(1.3)"]'
b = self.browser
m = self.machine
zoom_fit_to = (
'.console-ct[style*="translate(-50%, -50%)"]'
'[style*="top: 50%"]'
'[style*="left: 50%"]'
)
self.login_and_go("/session-recording")
b.wait_present(".content-header-extra")
b.wait_present("#user")
b.click(".listing-ct-item")
# Wait for terminal with scale(1)
b.wait_present(default_scale_sel)
# Zoom in x3
b.click("#player-zoom-in")
b.wait_present(zoom_one_scale_sel)
b.click("#player-zoom-in")
b.wait_present(zoom_two_scale_sel)
b.click("#player-zoom-in")
b.wait_present(zoom_three_scale_sel)
# Zoom Out
b.click("#player-zoom-out")
b.wait_present(zoom_two_scale_sel)
# Fit zoom to screen
b.click("#player-fit-to")
b.wait_present(zoom_fit_to)
def testSkipFrame(self):
term_first_line = ".xterm-accessibility-tree div:nth-child(1)"
b = self.browser
m = self.machine
self.login_and_go("/session-recording")
b.wait_present(".content-header-extra")
b.wait_present("#user")
b.click(".listing-ct-item")
b.wait_present(term_first_line)
# loop until 3 valid frames have passed
while "localhost" not in b.text(term_first_line):
b.click("#player-skip-frame")
b.wait_timeout(20)
b.wait_in_text(term_first_line, "localhost")
if __name__ == "__main__":
test_main()