te3270 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/Gemfile +1 -2
- data/README.md +2 -2
- data/lib/te3270.rb +5 -3
- data/lib/te3270/emulator_factory.rb +3 -1
- data/lib/te3270/emulators/virtel.rb +210 -0
- data/lib/te3270/version.rb +1 -1
- data/spec/lib/te3270/accessors_spec.rb +8 -8
- data/spec/lib/te3270/emulators/extra_spec.rb +143 -133
- data/spec/lib/te3270/emulators/quick3270_spec.rb +125 -118
- data/spec/lib/te3270/emulators/x3270_spec.rb +47 -49
- data/spec/lib/te3270/screen_factory_spec.rb +3 -3
- data/spec/lib/te3270/screen_populator_spec.rb +4 -4
- data/spec/lib/te3270_spec.rb +19 -19
- data/spec/spec_helper.rb +16 -20
- data/te3270.gemspec +5 -2
- metadata +35 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a98a2c51a06119ab5ff8660994f1cbf352356d9
|
4
|
+
data.tar.gz: dd0cc3dda81267b7408b80e745b3de6adf7ecb78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d019afdd33a9b46215f887c3983bce5bb86911e5fb2ceb5c1fabcfb97f683028117da4321aaf91bbd110683c8ad35512b64bce79a6d68f4cfe7b46e6b2cd3b1e
|
7
|
+
data.tar.gz: 4638275f200b51447eab85aa35b859a23a445a6fc3501485f4cb94572811f09e29f988515b32e5f8774c5b2329c7e7ec6678456791d90b8809b71163202e4441
|
data/ChangeLog
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
This gem can be used to drive a 3270 terminal emulator. You have to have a supported emulator installed on the
|
4
4
|
machines on which you use the gem. Currently the supported emulators are
|
5
5
|
[EXTRA! X-treme](http://www.attachmate.com/Products/Terminal+Emulation/Extra/xtreme/extra-x-treme.htm) by
|
6
|
-
Attachmate, [Quick3270](http://www.dn-computing.com/Quick3270.htm) by DN-Computing,
|
6
|
+
Attachmate, [Quick3270](http://www.dn-computing.com/Quick3270.htm) by DN-Computing, [Virtel Web Access](http://www.virtelweb.com/solutions/3270-terminal-emulation.html),
|
7
7
|
and [X3270](http://x3270.bgp.nu/).
|
8
|
-
The first
|
8
|
+
The first three are commercial products and need to be purchased.
|
9
9
|
X3270 is open source. Support for other
|
10
10
|
emulators will be added as time permits.
|
11
11
|
|
data/lib/te3270.rb
CHANGED
@@ -7,8 +7,9 @@ require 'te3270/emulator_factory'
|
|
7
7
|
|
8
8
|
#
|
9
9
|
# This gem can be used to drive a 3270 terminal emulator. You have to have a supported emulator installed on the
|
10
|
-
# machines on which you use the gem. Currently the
|
11
|
-
# Quick3270 by DN-Computing. These are commercial products
|
10
|
+
# machines on which you use the gem. Currently the supported emulators are EXTRA! X-treme by Attachmate,
|
11
|
+
# Quick3270 by DN-Computing, Virtel Web Access and X3270. These are commercial products, with the exception of X3270,
|
12
|
+
# and you will need to purchase one of them in order to
|
12
13
|
# use this gem. We do plan to support other emulators as time permits.
|
13
14
|
#
|
14
15
|
# This gem has been designed to work very similar to the page-object gem. You will use it to create screen objects
|
@@ -65,7 +66,8 @@ module TE3270
|
|
65
66
|
# To know what information you should provide in the block please see the classes in
|
66
67
|
# the TE3270::Emulators package.
|
67
68
|
#
|
68
|
-
#@param platform =[:extra,:quick3270] use :extra for Extra emulator
|
69
|
+
#@param platform =[:extra,:quick3270, :virtel] use :extra for Extra emulator, :quick3270 for quick emulator, :virtel
|
70
|
+
#for Virtel Web access, and :x3270 for X3270
|
69
71
|
#
|
70
72
|
def self.emulator_for(platform, &block)
|
71
73
|
platform_class = TE3270::EmulatorFactory.emulator_for(platform)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'te3270/emulators/extra'
|
2
2
|
require 'te3270/emulators/quick3270'
|
3
3
|
require 'te3270/emulators/x3270'
|
4
|
+
require 'te3270/emulators/virtel'
|
4
5
|
|
5
6
|
module TE3270
|
6
7
|
#
|
@@ -12,7 +13,8 @@ module TE3270
|
|
12
13
|
EMULATORS = {
|
13
14
|
extra: TE3270::Emulators::Extra,
|
14
15
|
quick3270: TE3270::Emulators::Quick3270,
|
15
|
-
x3270: TE3270::Emulators::X3270
|
16
|
+
x3270: TE3270::Emulators::X3270,
|
17
|
+
virtel: TE3270::Emulators::Virtel
|
16
18
|
}
|
17
19
|
|
18
20
|
def self.emulator_for(platform)
|
@@ -0,0 +1,210 @@
|
|
1
|
+
module TE3270
|
2
|
+
module Emulators
|
3
|
+
#
|
4
|
+
# This class has the code necessary to communicate with the terminal emulator called Virtel.
|
5
|
+
# It is a browser based terminal emulator. Watir webdriver (chrome only) is used to drive a browser with VWS (Virtel Web Access)
|
6
|
+
# You can use this emulator by providing the +:virtel+ parameter to the constructor of your screen
|
7
|
+
# object or by passing the same value to the +emulator_for+ method on the +TE3270+ module.
|
8
|
+
#
|
9
|
+
class Virtel
|
10
|
+
|
11
|
+
attr_writer :url, :max_wait_time
|
12
|
+
WAIT_SLEEP_INTERVAL = 0.2 # How long should we sleep during the wait loop.
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
require 'watir-webdriver'
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# Creates a method to connect to Virtel System. This method expects a block in which certain
|
20
|
+
# platform specific values can be set. Extra can take the following parameters.
|
21
|
+
#
|
22
|
+
# * url - this value is required and should be the url of the session.
|
23
|
+
# * max_wait_time - max time to wait in wait_for_string (defaults to 10 if not specified)
|
24
|
+
#
|
25
|
+
# @example Example calling screen object constructor with a block
|
26
|
+
# screen_object = MyScreenObject.new(:virtel)
|
27
|
+
# screen_object.connect do |emulator|
|
28
|
+
# emulator.url = 'http://mainframe:41001/w2h/WEB2AJAX.htm+Sessmgr'
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
def connect
|
32
|
+
@max_wait_time = 10
|
33
|
+
yield self if block_given?
|
34
|
+
start_virtel_browser
|
35
|
+
|
36
|
+
raise 'The url must be set in a block when calling connect with the Virtel emulator.' if @url.nil?
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Disconnects the Virtel System connection
|
41
|
+
#
|
42
|
+
def disconnect
|
43
|
+
@browser.close
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# Extracts text of specified length from a start point.
|
48
|
+
#
|
49
|
+
# @param [Fixnum] row the x coordinate of location on the screen.
|
50
|
+
# @param [Fixnum] column the y coordinate of location on the screen.
|
51
|
+
# @param [Fixnum] length the length of string to extract
|
52
|
+
# @return [String]
|
53
|
+
#
|
54
|
+
def get_string(row, column, length)
|
55
|
+
@browser.execute_script <<-JS
|
56
|
+
return VIR3270.getBoxedText("#{row}", "#{column}", 1, "#{length}");
|
57
|
+
JS
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Puts string at the coordinates specified.
|
62
|
+
#
|
63
|
+
# @param [String] str the string to set
|
64
|
+
# @param [Fixnum] row the x coordinate of the location on the screen.
|
65
|
+
# @param [Fixnum] column the y coordinate of the location on the screen.
|
66
|
+
#
|
67
|
+
def put_string(str, row, column)
|
68
|
+
move_to(row, column)
|
69
|
+
@browser.execute_script <<-JS
|
70
|
+
VIR3270.pasteByTyping("#{str}");
|
71
|
+
JS
|
72
|
+
quiet_period
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# Moves string at the coordinates specified.
|
77
|
+
#
|
78
|
+
# @param [Fixnum] row the x coordinate of the location on the screen.
|
79
|
+
# @param [Fixnum] column the y coordinate of the location on the screen.
|
80
|
+
#
|
81
|
+
def move_to(row, column)
|
82
|
+
@browser.execute_script <<-JS
|
83
|
+
var row = parseInt("#{row}", 10);
|
84
|
+
var col = parseInt("#{column}", 10);
|
85
|
+
|
86
|
+
VIR3270.moveCursorToPos(VIR3270.posFromRowCol(row, col));
|
87
|
+
JS
|
88
|
+
end
|
89
|
+
|
90
|
+
#
|
91
|
+
# Sends keystrokes to the host, including function keys.
|
92
|
+
#
|
93
|
+
# @param [String] keys keystokes up to 255 in length
|
94
|
+
#
|
95
|
+
def send_keys(keys)
|
96
|
+
char_input_keys = ['ErEof','Reset']
|
97
|
+
if char_input_keys.include?(keys)
|
98
|
+
@browser.execute_script <<-JS
|
99
|
+
VIR3270.charInput("#{keys}");
|
100
|
+
JS
|
101
|
+
else
|
102
|
+
@browser.execute_script <<-JS
|
103
|
+
sendWithSpecialKey("#{keys}");
|
104
|
+
JS
|
105
|
+
end
|
106
|
+
quiet_period
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# Wait for the string to appear at the specified location
|
111
|
+
#
|
112
|
+
# @param [String] str the string to wait for
|
113
|
+
# @param [Fixnum] row the x coordinate of location
|
114
|
+
# @param [Fixnum] column the y coordinate of location
|
115
|
+
#
|
116
|
+
def wait_for_string(str, row, column)
|
117
|
+
total_time = 0.0
|
118
|
+
sleep_time = 0.5
|
119
|
+
while get_string(row, column, str.length) != str do
|
120
|
+
sleep sleep_time
|
121
|
+
total_time = total_time + sleep_time
|
122
|
+
break if total_time >= @max_wait_time
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# Waits for the host to not send data for a specified number of seconds
|
128
|
+
#
|
129
|
+
# @param [Fixnum] seconds the maximum number of seconds to wait
|
130
|
+
#
|
131
|
+
def wait_for_host(seconds)
|
132
|
+
milliseconds = seconds * 1000
|
133
|
+
sleep(WAIT_SLEEP_INTERVAL)
|
134
|
+
@browser.execute_script <<-JS
|
135
|
+
function virtelWaiting(){
|
136
|
+
if (VIR3270.waitlocked === false)
|
137
|
+
{return true;}
|
138
|
+
else
|
139
|
+
{return false;}
|
140
|
+
};
|
141
|
+
|
142
|
+
function waitOnVirtel(){
|
143
|
+
for (var count = 1; ; count++) {
|
144
|
+
if (setInterval(virtelWaiting(), 200))
|
145
|
+
{
|
146
|
+
return true;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
setTimeout(waitOnVirtel(), "#{milliseconds}");
|
151
|
+
JS
|
152
|
+
end
|
153
|
+
|
154
|
+
#
|
155
|
+
# Waits until the cursor is at the specified location.
|
156
|
+
#
|
157
|
+
# @param [Fixnum] row the x coordinate of the location
|
158
|
+
# @param [Fixnum] column the y coordinate of the location
|
159
|
+
#
|
160
|
+
def wait_until_cursor_at(row, column)
|
161
|
+
wait_until do
|
162
|
+
@browser.execute_script <<-JS
|
163
|
+
return (VIR3270.rowFromPos(VIR3270.cursorPosn) === parseInt("#{row}", 10)) && (VIR3270.colFromPos(VIR3270.cursorPosn) === parseInt("#{column}", 10))
|
164
|
+
JS
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
#
|
169
|
+
# Returns the text of the active screen
|
170
|
+
#
|
171
|
+
# @return [String]
|
172
|
+
#
|
173
|
+
def text
|
174
|
+
@browser.execute_script <<-JS
|
175
|
+
VIR3270.collectText(1,1,VIR3270.rows,VIR3270.cols)
|
176
|
+
JS
|
177
|
+
end
|
178
|
+
|
179
|
+
#
|
180
|
+
# Creates a method to take screenshot of the active screen.
|
181
|
+
#
|
182
|
+
# @param [String] filename the path and name of the screenshot file to be saved
|
183
|
+
#
|
184
|
+
def screenshot(filename)
|
185
|
+
File.delete(filename) if File.exists?(filename)
|
186
|
+
|
187
|
+
@browser.screenshot.save(filename)
|
188
|
+
end
|
189
|
+
|
190
|
+
def start_virtel_browser
|
191
|
+
begin
|
192
|
+
@browser = Watir::Browser.new :chrome
|
193
|
+
@browser.goto(@url)
|
194
|
+
rescue Exception => e
|
195
|
+
$stderr.puts e
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
private
|
200
|
+
|
201
|
+
def quiet_period
|
202
|
+
wait_for_host(max_wait_time)
|
203
|
+
end
|
204
|
+
|
205
|
+
def max_wait_time
|
206
|
+
@max_wait_time ||= 10
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
data/lib/te3270/version.rb
CHANGED
@@ -14,34 +14,34 @@ describe TE3270::Accessors do
|
|
14
14
|
let(:screen_object) { AccessorsTestScreen.new platform }
|
15
15
|
|
16
16
|
before(:each) do
|
17
|
-
screen_object.
|
17
|
+
allow(screen_object).to receive(:platform).and_return platform
|
18
18
|
end
|
19
19
|
|
20
20
|
describe "text_field accessors" do
|
21
21
|
|
22
22
|
it 'should generate a method to retrieve the value' do
|
23
|
-
screen_object.
|
23
|
+
expect(screen_object).to respond_to(:method_name)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should generate a method to set the value' do
|
27
|
-
screen_object.
|
27
|
+
expect(screen_object).to respond_to(:method_name=)
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should not generate a method to set the value if it is not editable' do
|
31
|
-
screen_object.
|
31
|
+
expect(screen_object).not_to respond_to(:read_only=)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should default to being editable when it is not specified' do
|
35
|
-
screen_object.
|
35
|
+
expect(screen_object).to respond_to :default_editable=
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should use the platform to get the text value' do
|
39
|
-
platform.
|
40
|
-
screen_object.method_name.
|
39
|
+
expect(platform).to receive(:get_string).with(1, 2, 10).and_return('abc')
|
40
|
+
expect(screen_object.method_name).to eql 'abc'
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should use the platform to set the text value' do
|
44
|
-
platform.
|
44
|
+
expect(platform).to receive(:put_string).with('abc', 1, 2)
|
45
45
|
screen_object.method_name = 'abc'
|
46
46
|
end
|
47
47
|
|
@@ -1,162 +1,171 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
require 'spec_helper'
|
4
3
|
|
5
|
-
|
4
|
+
describe TE3270::Emulators::Extra do
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
before(:each) do
|
10
|
-
WIN32OLE.stub(:new).and_return extra_system
|
11
|
-
extra.instance_variable_set(:@session_file, 'the_file')
|
12
|
-
File.stub(:exists).and_return false
|
6
|
+
unless Gem.win_platform?
|
7
|
+
class WIN32OLE
|
13
8
|
end
|
9
|
+
end
|
14
10
|
|
11
|
+
let(:extra) do
|
12
|
+
allow_any_instance_of(TE3270::Emulators::Extra).to receive(:require) unless Gem.win_platform?
|
13
|
+
TE3270::Emulators::Extra.new
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
before(:each) do
|
17
|
+
allow(WIN32OLE).to receive(:new).and_return extra_system
|
18
|
+
extra.instance_variable_set(:@session_file, 'the_file')
|
19
|
+
allow(File).to receive(:exists).and_return false
|
20
|
+
end
|
21
21
|
|
22
|
-
it 'should open a session' do
|
23
|
-
extra_sessions.should_receive(:Open).and_return(extra_session)
|
24
|
-
extra.connect
|
25
|
-
end
|
26
22
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
describe "global behaviors" do
|
24
|
+
it 'should start a new terminal' do
|
25
|
+
expect(WIN32OLE).to receive(:new).and_return(extra_system)
|
26
|
+
extra.connect
|
27
|
+
end
|
32
28
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
29
|
+
it 'should open a session' do
|
30
|
+
expect(extra_sessions).to receive(:Open).and_return(extra_session)
|
31
|
+
extra.connect
|
32
|
+
end
|
39
33
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
34
|
+
it 'should not display the splash screen if version is higher than 9' do
|
35
|
+
expect(extra_system).to receive(:Version).and_return("9.2")
|
36
|
+
expect(extra_sessions).to receive(:VisibleOnStartup=).with(true)
|
37
|
+
extra.connect
|
38
|
+
end
|
44
39
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
40
|
+
it 'should call a block allowing the session file to be set' do
|
41
|
+
expect(extra_sessions).to receive(:Open).with('blah.edp').and_return(extra_session)
|
42
|
+
extra.connect do |platform|
|
43
|
+
platform.session_file = 'blah.edp'
|
50
44
|
end
|
45
|
+
end
|
51
46
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
47
|
+
it 'should raise an error when the session file is not set' do
|
48
|
+
extra.instance_variable_set(:@session_file, nil)
|
49
|
+
expect { extra.connect }.to raise_error('The session file must be set in a block when calling connect with the Extra emulator.')
|
50
|
+
end
|
56
51
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
52
|
+
it 'should take the visible value from a block' do
|
53
|
+
expect(extra_session).to receive(:Visible=).with(false)
|
54
|
+
extra.connect do |platform|
|
55
|
+
platform.visible = false
|
62
56
|
end
|
57
|
+
end
|
63
58
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
59
|
+
it 'should default to visible when not specified' do
|
60
|
+
expect(extra_session).to receive(:Visible=).with(true)
|
61
|
+
extra.connect
|
62
|
+
end
|
68
63
|
|
69
|
-
|
70
|
-
|
71
|
-
|
64
|
+
it 'should take the window state value from the block' do
|
65
|
+
expect(extra_session).to receive(:WindowState=).with(2)
|
66
|
+
extra.connect do |platform|
|
67
|
+
platform.window_state = :maximized
|
72
68
|
end
|
69
|
+
end
|
73
70
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
it 'should default to window state normal when not specified' do
|
72
|
+
expect(extra_session).to receive(:WindowState=).with(1)
|
73
|
+
extra.connect
|
74
|
+
end
|
78
75
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
76
|
+
it 'should default to being visible' do
|
77
|
+
expect(extra_session).to receive(:Visible=).with(true)
|
78
|
+
extra.connect
|
79
|
+
end
|
83
80
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
extra.disconnect
|
88
|
-
end
|
81
|
+
it 'should get the screen for the active session' do
|
82
|
+
expect(extra_session).to receive(:Screen).and_return(extra_screen)
|
83
|
+
extra.connect
|
89
84
|
end
|
90
85
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
extra.get_string(1, 2, 10).should == 'blah'
|
96
|
-
end
|
86
|
+
it 'should get the area from the screen' do
|
87
|
+
expect(extra_screen).to receive(:SelectAll).and_return(extra_area)
|
88
|
+
extra.connect
|
89
|
+
end
|
97
90
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
wait_collection.should_receive(:Wait).with(1000)
|
103
|
-
extra.connect
|
104
|
-
extra.put_string('blah', 1, 2)
|
105
|
-
end
|
91
|
+
it 'should disconnect from a session' do
|
92
|
+
expect(extra_session).to receive(:Close)
|
93
|
+
extra.connect
|
94
|
+
extra.disconnect
|
106
95
|
end
|
96
|
+
end
|
107
97
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
extra.connect
|
115
|
-
extra.send_keys(TE3270.Clear)
|
116
|
-
end
|
98
|
+
describe "interacting with text fields" do
|
99
|
+
it 'should get the value from the screen' do
|
100
|
+
expect(extra_screen).to receive(:GetString).with(1, 2, 10).and_return('blah')
|
101
|
+
extra.connect
|
102
|
+
expect(extra.get_string(1, 2, 10)).to eql 'blah'
|
103
|
+
end
|
117
104
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
105
|
+
it 'should put the value on the screen' do
|
106
|
+
wait_collection = double('wait')
|
107
|
+
expect(extra_screen).to receive(:PutString).with('blah', 1, 2)
|
108
|
+
expect(extra_screen).to receive(:WaitHostQuiet).and_return(wait_collection)
|
109
|
+
expect(wait_collection).to receive(:Wait).with(1000)
|
110
|
+
extra.connect
|
111
|
+
extra.put_string('blah', 1, 2)
|
112
|
+
end
|
113
|
+
end
|
126
114
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
115
|
+
describe "interacting with the screen" do
|
116
|
+
it 'should know how to send function keys' do
|
117
|
+
wait_collection = double('wait')
|
118
|
+
expect(extra_screen).to receive(:SendKeys).with('<Clear>')
|
119
|
+
expect(extra_screen).to receive(:WaitHostQuiet).and_return(wait_collection)
|
120
|
+
expect(wait_collection).to receive(:Wait).with(1000)
|
121
|
+
extra.connect
|
122
|
+
extra.send_keys(TE3270.Clear)
|
123
|
+
end
|
134
124
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
125
|
+
it 'should wait for a string to appear' do
|
126
|
+
wait_col = double('wait')
|
127
|
+
expect(extra_screen).to receive(:WaitForString).with('The String', 3, 10).and_return(wait_col)
|
128
|
+
expect(extra_system).to receive(:TimeoutValue).and_return(30000)
|
129
|
+
expect(wait_col).to receive(:Wait).with(30000)
|
130
|
+
extra.connect
|
131
|
+
extra.wait_for_string('The String', 3, 10)
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should wait for the host to be quiet' do
|
135
|
+
wait_col = double('wait')
|
136
|
+
expect(extra_screen).to receive(:WaitHostQuiet).and_return(wait_col)
|
137
|
+
expect(wait_col).to receive(:Wait).with(4000)
|
138
|
+
extra.connect
|
139
|
+
extra.wait_for_host(4)
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should wait until the cursor is at a position' do
|
143
|
+
wait_col = double('wait')
|
144
|
+
expect(extra_screen).to receive(:WaitForCursor).with(5, 8).and_return(wait_col)
|
145
|
+
expect(extra_system).to receive(:TimeoutValue).and_return(30000)
|
146
|
+
expect(wait_col).to receive(:Wait).with(30000)
|
147
|
+
extra.connect
|
148
|
+
extra.wait_until_cursor_at(5, 8)
|
149
|
+
end
|
150
|
+
|
151
|
+
if Gem.win_platform?
|
143
152
|
|
144
153
|
it 'should take screenshots' do
|
145
154
|
take = double('Take')
|
146
|
-
extra_session.
|
147
|
-
Win32::Screenshot::Take.
|
148
|
-
take.
|
155
|
+
expect(extra_session).to receive(:WindowHandle).and_return(123)
|
156
|
+
expect(Win32::Screenshot::Take).to receive(:of).with(:window, hwnd: 123).and_return(take)
|
157
|
+
expect(take).to receive(:write).with('image.png')
|
149
158
|
extra.connect
|
150
159
|
extra.screenshot('image.png')
|
151
160
|
end
|
152
161
|
|
153
162
|
it 'should make the window visible before taking a screenshot' do
|
154
163
|
take = double('Take')
|
155
|
-
extra_session.
|
156
|
-
Win32::Screenshot::Take.
|
157
|
-
take.
|
158
|
-
extra_session.
|
159
|
-
extra_session.
|
164
|
+
expect(extra_session).to receive(:WindowHandle).and_return(123)
|
165
|
+
expect(Win32::Screenshot::Take).to receive(:of).with(:window, hwnd: 123).and_return(take)
|
166
|
+
expect(take).to receive(:write).with('image.png')
|
167
|
+
expect(extra_session).to receive(:Visible=).once.with(true)
|
168
|
+
expect(extra_session).to receive(:Visible=).twice.with(false)
|
160
169
|
extra.connect do |emulator|
|
161
170
|
emulator.visible = false
|
162
171
|
end
|
@@ -164,23 +173,24 @@ if Gem.win_platform?
|
|
164
173
|
end
|
165
174
|
|
166
175
|
it 'should delete the file for the screenshot if it already exists' do
|
167
|
-
File.
|
168
|
-
File.
|
176
|
+
expect(File).to receive(:exists?).and_return(true)
|
177
|
+
expect(File).to receive(:delete)
|
169
178
|
take = double('Take')
|
170
|
-
extra_session.
|
171
|
-
Win32::Screenshot::Take.
|
172
|
-
take.
|
179
|
+
expect(extra_session).to receive(:WindowHandle).and_return(123)
|
180
|
+
expect(Win32::Screenshot::Take).to receive(:of).with(:window, hwnd: 123).and_return(take)
|
181
|
+
expect(take).to receive(:write).with('image.png')
|
173
182
|
extra.connect
|
174
183
|
extra.screenshot('image.png')
|
175
184
|
end
|
185
|
+
end
|
176
186
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
end
|
182
|
-
|
187
|
+
it "should get the screen text" do
|
188
|
+
expect(extra_area).to receive(:Value).and_return('blah')
|
189
|
+
extra.connect
|
190
|
+
expect(extra.text).to eql 'blah'
|
183
191
|
end
|
184
|
-
end
|
185
192
|
|
193
|
+
end
|
186
194
|
end
|
195
|
+
|
196
|
+
|