-
Notifications
You must be signed in to change notification settings - Fork 266
/
WebSocketsTest.pm
64 lines (52 loc) · 1.72 KB
/
WebSocketsTest.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# SUSE's openQA tests
#
# Copyright 2019 SUSE LLC
# SPDX-License-Identifier: FSFAP
# Summary: Test the tomcat WebSocket examples
# Maintainer: George Gkioulis <ggkioulis@suse.com>
package Tomcat::WebSocketsTest;
use base "x11test";
use strict;
use warnings;
use testapi;
use utils;
use Tomcat::Utils;
# allow a 60 second timeout for asserting needles
use constant TIMEOUT => 90;
# test all WebSocket examples
sub test_all_examples() {
my ($self) = shift;
# array with example test function and number of tabs required to select the example
my @websocket_examples = ([\&echo, 1], [\&chat, 1], [\&snake, 1]);
# access the tomcat websocket examples page
$self->firefox_open_url('localhost:8080/examples/websocket');
send_key_until_needlematch('tomcat-websocket-examples', 'ret');
# Navigate with keyboard to each example and test it
for my $i (0 .. $#websocket_examples) {
Tomcat::Utils->browse_with_keyboard('tomcat-websocket-examples', $websocket_examples[$i][0], $websocket_examples[$i][1]);
}
}
# test echo example
sub echo() {
assert_screen('tomcat-echo-example-loaded', TIMEOUT);
assert_and_click('tomcat-echo-example-select');
assert_and_click('tomcat-echo-example-connect');
assert_and_click('tomcat-echo-example-message');
assert_screen('tomcat-echo-example', TIMEOUT);
}
# test chat example
sub chat() {
assert_screen('tomcat-chat-example-loaded', TIMEOUT);
send_key('tab');
type_string('test');
send_key('ret');
assert_screen('tomcat-chat-example', TIMEOUT);
}
# test snake example
sub snake() {
assert_screen('tomcat-snake-example-loaded', TIMEOUT);
send_key('right');
send_key('down');
assert_screen('tomcat-snake-example', TIMEOUT);
}
1;