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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
/* global describe it cy beforeEach require afterEach expect*/
var helper = require('../../common/helper');
var mobileHelper = require('../../common/mobile_helper');
describe('Focus tests', function() {
var testFileName = 'focus.odt';
beforeEach(function() {
helper.beforeAll(testFileName, 'writer');
});
afterEach(function() {
helper.afterAll(testFileName, this.currentTest.state);
});
it('Basic document focus.', function() {
// Click on edit button
mobileHelper.enableEditingMobile();
// Click in the document
cy.get('#document-container').click();
helper.assertFocus('className', 'clipboard');
});
it('Focus with opened mobile wizard.', function() {
// Click on edit button
mobileHelper.enableEditingMobile();
// Click in the document
cy.get('#document-container')
.click();
// Clipboard has the focus -> can type in the document
helper.assertFocus('className', 'clipboard');
mobileHelper.openMobileWizard();
// Body should have the focus (no focus on document)
helper.assertFocus('tagName', 'BODY');
mobileHelper.closeMobileWizard();
});
it('Focus inside mobile wizard.', function() {
// Click on edit button
mobileHelper.enableEditingMobile();
mobileHelper.openMobileWizard();
// Open paragraph properties
helper.clickOnIdle('#Paragraph');
cy.get('#aboveparaspacing .spinfield')
.should('have.attr', 'value', '0');
helper.clickOnIdle('#aboveparaspacing .spinfield');
// The spinfield should have the focus now.
helper.assertFocus('className', 'spinfield');
mobileHelper.closeMobileWizard();
});
it('Focus after insertion.', function() {
// Click on edit button
mobileHelper.enableEditingMobile();
mobileHelper.openInsertionWizard();
// Select More Fields
cy.contains('.ui-header.level-0.mobile-wizard.ui-widget', 'More Fields...')
.click();
// Insert a field
cy.contains('.menu-entry-with-icon', 'Page Number')
.click();
cy.get('#mobile-wizard')
.should('not.be.visible');
// After insertion the document gets the focus
helper.assertFocus('className', 'clipboard');
});
it('Shape related focus.', function() {
// Click on edit button
mobileHelper.enableEditingMobile();
mobileHelper.openInsertionWizard();
// Do insertion
cy.contains('.menu-entry-with-icon', 'Shape')
.click();
cy.get('.col.w2ui-icon.basicshapes_rectangle').
click();
// Check that the shape is there
cy.get('.leaflet-pane.leaflet-overlay-pane svg g')
.should('exist');
// One tap on the shape
cy.get('.leaflet-pane.leaflet-overlay-pane svg')
.then(function(svg) {
expect(svg[0].getBBox().width).to.be.greaterThan(0);
expect(svg[0].getBBox().height).to.be.greaterThan(0);
var posX = svg[0].getBBox().x + svg[0].getBBox().width / 2;
var posY = svg[0].getBBox().y + svg[0].getBBox().height / 2;
cy.get('#document-container')
.click(posX, posY);
});
// No focus on the document
helper.assertFocus('tagName', 'BODY');
// Double tap on the shape
cy.get('.leaflet-pane.leaflet-overlay-pane svg')
.then(function(svg) {
expect(svg[0].getBBox().width).to.be.greaterThan(0);
expect(svg[0].getBBox().height).to.be.greaterThan(0);
var posX = svg[0].getBBox().x + svg[0].getBBox().width / 2;
var posY = svg[0].getBBox().y + svg[0].getBBox().height / 2;
cy.get('#document-container')
.dblclick(posX, posY);
});
cy.get('.blinking-cursor')
.should('be.visible');
// Document still has the focus
helper.assertFocus('className', 'clipboard');
helper.assertHaveKeyboardInput();
});
it('Focus with hamburger menu.', function() {
// Click on edit button
mobileHelper.enableEditingMobile();
// Click in the document
cy.get('#document-container')
.click();
// Clipboard has the focus -> can type in the document
helper.assertFocus('className', 'clipboard');
// Open hamburger menu
mobileHelper.openHamburgerMenu();
// Close hamburger menu
mobileHelper.closeHamburgerMenu();
});
it('Focus after applying font change.', function() {
// Click on edit button
mobileHelper.enableEditingMobile();
// Click in the document
cy.get('#document-container')
.click();
// Clipboard has the focus -> can type in the document
helper.assertFocus('className', 'clipboard');
mobileHelper.openMobileWizard();
// No focus
helper.assertFocus('tagName', 'BODY');
// Apply bold
helper.clickOnIdle('#Bold');
cy.get('#Boldimg')
.should('have.class', 'selected');
// No focus
helper.assertFocus('tagName', 'BODY');
mobileHelper.closeMobileWizard();
});
it('Apply bold, check keyboard.', function() {
// Click on edit button
mobileHelper.enableEditingMobile();
// Grab focus to the document
helper.typeIntoDocument('x');
helper.selectAllText();
cy.get('#tb_editbar_item_bold div table')
.should('not.have.class', 'checked');
helper.assertHaveKeyboardInput();
cy.get('#tb_editbar_item_bold')
.click();
cy.get('#tb_editbar_item_bold div table')
.should('have.class', 'checked');
helper.assertHaveKeyboardInput();
});
it('Apply italic, check keyboard.', function() {
// Click on edit button
mobileHelper.enableEditingMobile();
// Grab focus to the document
helper.typeIntoDocument('x');
helper.selectAllText();
cy.get('#tb_editbar_item_italic div table')
.should('not.have.class', 'checked');
helper.assertHaveKeyboardInput();
cy.get('#tb_editbar_item_italic')
.click();
cy.get('#tb_editbar_item_italic div table')
.should('have.class', 'checked');
helper.assertHaveKeyboardInput();
});
it('Apply underline, check keyboard.', function() {
// Click on edit button
mobileHelper.enableEditingMobile();
// Grab focus to the document
helper.typeIntoDocument('x');
helper.selectAllText();
cy.get('#tb_editbar_item_underline div table')
.should('not.have.class', 'checked');
helper.assertHaveKeyboardInput();
cy.get('#tb_editbar_item_underline')
.click();
cy.get('#tb_editbar_item_underline div table')
.should('have.class', 'checked');
helper.assertHaveKeyboardInput();
});
});
|