libyui_client 0.4.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 +7 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/.rubocop.yml +41 -0
- data/.travis.yml +11 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +210 -0
- data/Rakefile +20 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/libyui_client.rb +42 -0
- data/lib/libyui_client/actions.rb +12 -0
- data/lib/libyui_client/app.rb +230 -0
- data/lib/libyui_client/error.rb +13 -0
- data/lib/libyui_client/filter_extractor.rb +28 -0
- data/lib/libyui_client/http/http_client.rb +36 -0
- data/lib/libyui_client/http/response.rb +21 -0
- data/lib/libyui_client/http/version_controller.rb +26 -0
- data/lib/libyui_client/http/widget_controller.rb +54 -0
- data/lib/libyui_client/local_process.rb +73 -0
- data/lib/libyui_client/logger.rb +32 -0
- data/lib/libyui_client/timer.rb +20 -0
- data/lib/libyui_client/version.rb +6 -0
- data/lib/libyui_client/wait.rb +21 -0
- data/lib/libyui_client/waitable.rb +39 -0
- data/lib/libyui_client/widgets.rb +30 -0
- data/lib/libyui_client/widgets/bargraph.rb +62 -0
- data/lib/libyui_client/widgets/base.rb +114 -0
- data/lib/libyui_client/widgets/button.rb +33 -0
- data/lib/libyui_client/widgets/checkbox.rb +53 -0
- data/lib/libyui_client/widgets/combobox.rb +95 -0
- data/lib/libyui_client/widgets/datefield.rb +47 -0
- data/lib/libyui_client/widgets/label.rb +41 -0
- data/lib/libyui_client/widgets/menubutton.rb +48 -0
- data/lib/libyui_client/widgets/multilinebox.rb +84 -0
- data/lib/libyui_client/widgets/numberbox.rb +76 -0
- data/lib/libyui_client/widgets/progressbar.rb +45 -0
- data/lib/libyui_client/widgets/radiobutton.rb +35 -0
- data/lib/libyui_client/widgets/richtext.rb +36 -0
- data/lib/libyui_client/widgets/selectionbox.rb +87 -0
- data/lib/libyui_client/widgets/tab.rb +81 -0
- data/lib/libyui_client/widgets/table.rb +154 -0
- data/lib/libyui_client/widgets/textbox.rb +94 -0
- data/lib/libyui_client/widgets/timefield.rb +45 -0
- data/lib/libyui_client/widgets/tree.rb +149 -0
- data/libyui_client.gemspec +44 -0
- metadata +135 -0
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LibyuiClient
|
4
|
+
module Widgets
|
5
|
+
# Class representing a numberbox in the UI. It can be YIntField.
|
6
|
+
class Numberbox < Widgets::Base
|
7
|
+
# Returns minimum value to set in the numberbox
|
8
|
+
# @return [Integer] with minimum value
|
9
|
+
# @example Get minimum value to set numberbox with id 'test'
|
10
|
+
# {
|
11
|
+
# "class": "YIntField",
|
12
|
+
# "debug_label": "label_test",
|
13
|
+
# "hstretch": true,
|
14
|
+
# "id": "test",
|
15
|
+
# "label": "label_test",
|
16
|
+
# "max_value": 65535,
|
17
|
+
# "min_value": 0,
|
18
|
+
# "value": 3260
|
19
|
+
# }
|
20
|
+
# @example
|
21
|
+
# app.numberbox(id: 'test').min_value
|
22
|
+
def min_value
|
23
|
+
property(:min_value)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns maximum value to set in the numberbox
|
27
|
+
# @return [Integer] with maximum value
|
28
|
+
# @example Get maximum value to set numberbox with id 'test'
|
29
|
+
# {
|
30
|
+
# "class": "YIntField",
|
31
|
+
# "debug_label": "label_test",
|
32
|
+
# "hstretch": true,
|
33
|
+
# "id": "test",
|
34
|
+
# "label": "label_test",
|
35
|
+
# "max_value": 65535,
|
36
|
+
# "min_value": 0,
|
37
|
+
# "value": 3260
|
38
|
+
# }
|
39
|
+
# @example
|
40
|
+
# app.numberbox(id: 'test').max_value
|
41
|
+
def max_value
|
42
|
+
property(:max_value)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Sends action to set the value of numberbox.
|
46
|
+
# @param value [Integer] to be set in numberbox
|
47
|
+
# @return [Numberbox] in case action is successful
|
48
|
+
# @example Set text in numberbox with id 'test' to 123
|
49
|
+
# app.numberbox(id: 'test').set(123)
|
50
|
+
def set(value)
|
51
|
+
action(action: Actions::ENTER_TEXT, value: value)
|
52
|
+
self
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns number that is currently set for numberbox.
|
56
|
+
# Gets value from 'value' parameter in JSON representation of YIntField.
|
57
|
+
# @return [Integer] value
|
58
|
+
# @example Get value from numberbox with id "test"
|
59
|
+
# {
|
60
|
+
# "class": "YIntField",
|
61
|
+
# "debug_label": "label_test",
|
62
|
+
# "hstretch": true,
|
63
|
+
# "id": "test",
|
64
|
+
# "label": "label_test",
|
65
|
+
# "max_value": 65535,
|
66
|
+
# "min_value": 0,
|
67
|
+
# "value": 3260
|
68
|
+
# }
|
69
|
+
# @example
|
70
|
+
# app.numberbox(id: 'address').value # 3260
|
71
|
+
def value
|
72
|
+
property(:value)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LibyuiClient
|
4
|
+
module Widgets
|
5
|
+
# Class representing a Progressbar in UI. It can be YProgressBar.
|
6
|
+
class Progressbar < Widgets::Base
|
7
|
+
# Returns the current value of progressbar.
|
8
|
+
# Gets value from 'value' parameter in JSON representation of YProgressBar.
|
9
|
+
# @return [Integer] current value of progressbar.
|
10
|
+
# @example Get progressbar value, with id 'initProg'
|
11
|
+
# {
|
12
|
+
# "class" : "YProgressBar",
|
13
|
+
# "hstretch" : true,
|
14
|
+
# "id" : "initProg",
|
15
|
+
# "label" : "Disk",
|
16
|
+
# "max_value" : 1000,
|
17
|
+
# "value" : 666
|
18
|
+
# }
|
19
|
+
# app.progressbar(id: 'initProg').value
|
20
|
+
# # 663
|
21
|
+
def value
|
22
|
+
property(:value)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns the max value of progressbar.
|
26
|
+
# Gets value from 'max_value' parameter in JSON representation of YProgressBar.
|
27
|
+
# @return [Integer] max value of the progressbar.
|
28
|
+
# @example Get progressbar max_value, with id 'initProg'
|
29
|
+
# {
|
30
|
+
# "class" : "YProgressBar",
|
31
|
+
# "hstretch" : true,
|
32
|
+
# "id" : "initProg",
|
33
|
+
# "label" : "Disk",
|
34
|
+
# "max_value" : 1000,
|
35
|
+
# "value" : 666
|
36
|
+
# }
|
37
|
+
# @example
|
38
|
+
# app.progressbar(id: 'initProg').max_value
|
39
|
+
# # 1000
|
40
|
+
def max_value
|
41
|
+
property(:max_value)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LibyuiClient
|
4
|
+
module Widgets
|
5
|
+
# Class representing a RadioButton in the UI. It can be YRadioButton.
|
6
|
+
class Radiobutton < Widgets::Base
|
7
|
+
# Sends action to select the radiobutton in UI.
|
8
|
+
# @return [Radiobutton] in case action is successful
|
9
|
+
# @example Select radiobutton with id 'test'
|
10
|
+
# app.radiobutton(id: 'test').select
|
11
|
+
def select
|
12
|
+
action(action: Actions::SELECT)
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns the state of radiobutton (selected or not).
|
17
|
+
# Gets value from 'value' parameter in JSON representation of YRadioButton.
|
18
|
+
# @return [Boolean] true if the radiobutton is selected, false otherwise.
|
19
|
+
# @example Get state for radiobutton with id "manual"
|
20
|
+
# {
|
21
|
+
# "class": "YRadioButton",
|
22
|
+
# "debug_label": "Manually",
|
23
|
+
# "id": "manual",
|
24
|
+
# "label": "&Manually",
|
25
|
+
# "notify": true,
|
26
|
+
# "value": false
|
27
|
+
# }
|
28
|
+
# @example
|
29
|
+
# app.radiobutton(id: 'manual').selected? # false
|
30
|
+
def selected?
|
31
|
+
property(:value)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LibyuiClient
|
4
|
+
module Widgets
|
5
|
+
# Class representing a richtext in the UI. It can be YRichText.
|
6
|
+
class Richtext < Widgets::Base
|
7
|
+
# Sends action to click a link inside a richtext control in the UI.
|
8
|
+
# @param value [String] href
|
9
|
+
# @return [Richtext] in case action is successful
|
10
|
+
# @example Click link with value 'test'
|
11
|
+
# items.click_link('test')
|
12
|
+
def click_link(value)
|
13
|
+
action(action: Actions::PRESS, value: value)
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns text value for the richtext.
|
18
|
+
# @return [String] value
|
19
|
+
# @example Get text value for YRichText
|
20
|
+
# {
|
21
|
+
# "class": "YRichText",
|
22
|
+
# "enabled": false,
|
23
|
+
# "hstretch": true,
|
24
|
+
# "id": "test",
|
25
|
+
# "text": "<small>Select something here</small>",
|
26
|
+
# "vstretch": true,
|
27
|
+
# "vweight": 25
|
28
|
+
# }
|
29
|
+
# @example
|
30
|
+
# text = app.richtext(id: 'test').text # "<small>Select something here</small>"
|
31
|
+
def text
|
32
|
+
property(:text)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LibyuiClient
|
4
|
+
module Widgets
|
5
|
+
# Class representing a selectionbox in the UI. It can be YSelectionBox.
|
6
|
+
class Selectionbox < Widgets::Base
|
7
|
+
# Returns the list of items available to select from selection box.
|
8
|
+
# @return [Array] array of String objects.
|
9
|
+
# @example Get items from selection box with id "test_id"
|
10
|
+
# {
|
11
|
+
# "class" : "YSelectionBox",
|
12
|
+
# "debug_label" : "selection box title",
|
13
|
+
# "hstretch" : true,
|
14
|
+
# "icon_base_path" : "",
|
15
|
+
# "id" : "test_id",
|
16
|
+
# "items" :
|
17
|
+
# [
|
18
|
+
# {
|
19
|
+
# "label" : "selection 1",
|
20
|
+
# "selected" : true
|
21
|
+
# },
|
22
|
+
# {
|
23
|
+
# "label" : "selection 2"
|
24
|
+
# },
|
25
|
+
# {
|
26
|
+
# "label" : "selection 3"
|
27
|
+
# }
|
28
|
+
# ],
|
29
|
+
# "items_count" : 3,
|
30
|
+
# "label" : "&selection box title",
|
31
|
+
# "vstretch" : true
|
32
|
+
# }
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# app.selectionbox(id: 'test_id').items
|
36
|
+
# # selection 1
|
37
|
+
# # selection 2
|
38
|
+
# # selection 3
|
39
|
+
def items
|
40
|
+
property(:items).map { |x| x[:label] }
|
41
|
+
end
|
42
|
+
|
43
|
+
# Sends action to click the selection in UI.
|
44
|
+
# @param item [String] value to select from items.
|
45
|
+
# @return [Selectionbox] in case action is successful
|
46
|
+
# @example Click selection with id 'test_id'
|
47
|
+
# app.selectionbox(id: 'test_id').select('item_id')
|
48
|
+
def select(item)
|
49
|
+
action(action: Actions::SELECT, value: item)
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returns selected item in selection box.
|
54
|
+
# @example Get selected item in selection box with id "test_id"
|
55
|
+
# {
|
56
|
+
# "class" : "YSelectionBox",
|
57
|
+
# "debug_label" : "selection box title",
|
58
|
+
# "hstretch" : true,
|
59
|
+
# "icon_base_path" : "",
|
60
|
+
# "id" : "test_id",
|
61
|
+
# "items" :
|
62
|
+
# [
|
63
|
+
# {
|
64
|
+
# "label" : "selection 1",
|
65
|
+
# "selected" : true
|
66
|
+
# },
|
67
|
+
# {
|
68
|
+
# "label" : "selection 2"
|
69
|
+
# },
|
70
|
+
# {
|
71
|
+
# "label" : "selection 3"
|
72
|
+
# }
|
73
|
+
# ],
|
74
|
+
# "items_count" : 3,
|
75
|
+
# "label" : "&selection box title",
|
76
|
+
# "vstretch" : true
|
77
|
+
# }
|
78
|
+
#
|
79
|
+
# @example
|
80
|
+
# app.selectionbox(id: 'test_id').selected_item
|
81
|
+
# # selection 1
|
82
|
+
def selected_item
|
83
|
+
property(:items).select { |x| x[:selected] }.first[:label]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LibyuiClient
|
4
|
+
module Widgets
|
5
|
+
# Class representing a tab in the UI. It can be YDumbTab.
|
6
|
+
class Tab < Widgets::Base
|
7
|
+
# Returns the list of items available to select from tab.
|
8
|
+
# @return [Array] array of String objects.
|
9
|
+
# @example Get items from tab with id "test_id"
|
10
|
+
# {
|
11
|
+
# "class": "YDumbTab",
|
12
|
+
# "debug_label": "YDumbTab [tab1] [tab2] [tab3]",
|
13
|
+
# "hstretch": true,
|
14
|
+
# "icon_base_path": "",
|
15
|
+
# "id": "test_id",
|
16
|
+
# "items": [
|
17
|
+
# {
|
18
|
+
# "label": "tab1"
|
19
|
+
# },
|
20
|
+
# {
|
21
|
+
# "label": "tab2",
|
22
|
+
# "selected": true
|
23
|
+
# },
|
24
|
+
# {
|
25
|
+
# "label": "tab3"
|
26
|
+
# }
|
27
|
+
# ],
|
28
|
+
# "items_count": 3,
|
29
|
+
# "vstretch": true
|
30
|
+
# }
|
31
|
+
# @example
|
32
|
+
# app.tab(id: 'test').items
|
33
|
+
# # tab1
|
34
|
+
# # tab2
|
35
|
+
# # tab3
|
36
|
+
def items
|
37
|
+
property(:items).map { |x| x[:label] }
|
38
|
+
end
|
39
|
+
|
40
|
+
# Sends action to click the tab in UI.
|
41
|
+
# @param item [String] value to select from items.
|
42
|
+
# @return [Tab] in case action is successful
|
43
|
+
# @example Click tab with id 'test'
|
44
|
+
# app.button(id: 'test', value: test_item).select
|
45
|
+
def select(item)
|
46
|
+
action(action: Actions::SELECT, value: item)
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns the label of the selected tab.
|
51
|
+
# @return [String] label of the tab selected
|
52
|
+
# @example Get items from tab with id "test_id"
|
53
|
+
# {
|
54
|
+
# "class": "YDumbTab",
|
55
|
+
# "debug_label": "YDumbTab [tab1] [tab2] [tab3]",
|
56
|
+
# "hstretch": true,
|
57
|
+
# "icon_base_path": "",
|
58
|
+
# "id": "test_id",
|
59
|
+
# "items": [
|
60
|
+
# {
|
61
|
+
# "label": "tab1"
|
62
|
+
# },
|
63
|
+
# {
|
64
|
+
# "label": "tab2",
|
65
|
+
# "selected": true
|
66
|
+
# },
|
67
|
+
# {
|
68
|
+
# "label": "tab3"
|
69
|
+
# }
|
70
|
+
# ],
|
71
|
+
# "items_count": 3,
|
72
|
+
# "vstretch": true
|
73
|
+
# }
|
74
|
+
# @example
|
75
|
+
# app.tab(id: 'test').selected_item # tab2
|
76
|
+
def selected_item
|
77
|
+
property(:items).select { |x| x[:selected] }.first[:label]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LibyuiClient
|
4
|
+
module Widgets
|
5
|
+
# Class representing a table in the UI. It can be YTable
|
6
|
+
class Table < Widgets::Base
|
7
|
+
# Returns whether the table contains any row or not
|
8
|
+
# @return [Boolean] true if table is empty, otherwise false
|
9
|
+
# @example Check if table with id "test_id" is empty
|
10
|
+
# {
|
11
|
+
# "class": "YTable",
|
12
|
+
# "columns": 4,
|
13
|
+
# "header": [
|
14
|
+
# "header1",
|
15
|
+
# "header2",
|
16
|
+
# "header3",
|
17
|
+
# "header4"
|
18
|
+
# ],
|
19
|
+
# "id": "test_id",
|
20
|
+
# "items": null,
|
21
|
+
# "items_count": 0
|
22
|
+
# }
|
23
|
+
# @example
|
24
|
+
# app.table(id: 'test_id').empty?
|
25
|
+
def empty?
|
26
|
+
property(:items).nil?
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns the list of items available to select from the table.
|
30
|
+
# @return [Array] array of [Array] objects containing values for each column
|
31
|
+
# @example Get items from the table with id "test_id"
|
32
|
+
# {
|
33
|
+
# "class": "YTable",
|
34
|
+
# "columns": 4,
|
35
|
+
# "header": [
|
36
|
+
# "header1",
|
37
|
+
# "header2",
|
38
|
+
# "header3",
|
39
|
+
# "header4"
|
40
|
+
# ],
|
41
|
+
# "id": "test_id",
|
42
|
+
# "items": [
|
43
|
+
# {
|
44
|
+
# "labels": [
|
45
|
+
# "test.item.1",
|
46
|
+
# "",
|
47
|
+
# "",
|
48
|
+
# ""
|
49
|
+
# ],
|
50
|
+
# "selected": true
|
51
|
+
# },
|
52
|
+
# {
|
53
|
+
# "labels": [
|
54
|
+
# "test.item.2",
|
55
|
+
# "",
|
56
|
+
# "",
|
57
|
+
# ""
|
58
|
+
# ]
|
59
|
+
# }
|
60
|
+
# ],
|
61
|
+
# "items_count": 2
|
62
|
+
# }
|
63
|
+
# @example
|
64
|
+
# app.table(id: 'test_id').items
|
65
|
+
# # [test.item.1, "", "", ""]
|
66
|
+
# # [test.item.2, "", "", ""]
|
67
|
+
def items
|
68
|
+
property(:items).map { |x| x[:labels] }
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns the list of column names.
|
72
|
+
# @return [Array] array of [String] objects containing names of the columns
|
73
|
+
# @example Get header column names from the table with id "test_id"
|
74
|
+
# app.table(id: 'test_id').header
|
75
|
+
def header
|
76
|
+
property(:header)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Sends action to select a row in a table. Row can be selected either by
|
80
|
+
# cell value in the column (first column will be used by default), or by
|
81
|
+
# row number directly. If both are provided, value will be used.
|
82
|
+
# NOTE: row number corresponds to the position of the
|
83
|
+
# item in the list of column values which might differ to the display order.
|
84
|
+
# @param value [String] value to select in the table.
|
85
|
+
# @param column [String] column name where value is present
|
86
|
+
# @param row [Numeric] row number to select in the table.
|
87
|
+
# @return [Table] in case action is successful
|
88
|
+
# @example Select row with value "test.item.2" for column "header1" in table with id 'test_id'
|
89
|
+
# app.table(id: 'test_id').select(value: 'test.item.2', column: 'header1')
|
90
|
+
# @example Select row number 3 in table with id 'test_id'
|
91
|
+
# app.table(id: 'test_id').select(row: 3)
|
92
|
+
def select(value: nil, column: nil, row: nil)
|
93
|
+
params = { action: Actions::SELECT }
|
94
|
+
if !value.nil?
|
95
|
+
params.merge!(value: value)
|
96
|
+
params.merge!(column: get_index(column)) unless column.nil?
|
97
|
+
elsif !row.nil?
|
98
|
+
params.merge!(row: row)
|
99
|
+
end
|
100
|
+
action(params)
|
101
|
+
self
|
102
|
+
end
|
103
|
+
|
104
|
+
# Returns the list of items currently selected from the table.
|
105
|
+
# @return [Array] array of [Array] objects containing values for each column
|
106
|
+
# @example Get items from the table with id "test_id"
|
107
|
+
# {
|
108
|
+
# "class": "YTable",
|
109
|
+
# "columns": 4,
|
110
|
+
# "header": [
|
111
|
+
# "header1",
|
112
|
+
# "header2",
|
113
|
+
# "header3",
|
114
|
+
# "header4"
|
115
|
+
# ],
|
116
|
+
# "id": "test_id",
|
117
|
+
# "items": [
|
118
|
+
# {
|
119
|
+
# "labels": [
|
120
|
+
# "test.item.1",
|
121
|
+
# "",
|
122
|
+
# "",
|
123
|
+
# ""
|
124
|
+
# ],
|
125
|
+
# "selected": true
|
126
|
+
# },
|
127
|
+
# {
|
128
|
+
# "labels": [
|
129
|
+
# "test.item.2",
|
130
|
+
# "",
|
131
|
+
# "",
|
132
|
+
# ""
|
133
|
+
# ],
|
134
|
+
# "selected": true
|
135
|
+
# }
|
136
|
+
# ],
|
137
|
+
# "items_count": 2
|
138
|
+
# }
|
139
|
+
# @example
|
140
|
+
# app.table(id: 'test_id').selected_items
|
141
|
+
# # [test.item.1, "", "", ""]
|
142
|
+
# # [test.item.2, "", "", ""]
|
143
|
+
def selected_items
|
144
|
+
property(:items).map { |x| x[:labels] if x[:selected] }.compact
|
145
|
+
end
|
146
|
+
|
147
|
+
private
|
148
|
+
|
149
|
+
def get_index(column)
|
150
|
+
header.index(column)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|