summaryrefslogtreecommitdiff
path: root/testautomation/dbaccess/optional/includes/wiz_TableWizard.inc
blob: b802e105b9d4e0053e9c20ed98a7ff5aa16e3939 (plain)
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
'encoding UTF-8  Do not remove or change this line!
'**************************************************************************
'* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'* 
'* Copyright 2008 by Sun Microsystems, Inc.
'*
'* OpenOffice.org - a multi-platform office productivity suite
'*
'* $RCSfile: wiz_TableWizard.inc,v $
'*
'* $Revision: 1.1 $
'*
'* last change: $Author: jsi $ $Date: 2008-06-16 07:43:42 $
'*
'* This file is part of OpenOffice.org.
'*
'* OpenOffice.org is free software: you can redistribute it and/or modify
'* it under the terms of the GNU Lesser General Public License version 3
'* only, as published by the Free Software Foundation.
'*
'* OpenOffice.org is distributed in the hope that it will be useful,
'* but WITHOUT ANY WARRANTY; without even the implied warranty of
'* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'* GNU Lesser General Public License version 3 for more details
'* (a copy is included in the LICENSE file that accompanied this code).
'*
'* You should have received a copy of the GNU Lesser General Public License
'* version 3 along with OpenOffice.org.  If not, see
'* <http://www.openoffice.org/license.html>
'* for a copy of the LGPLv3 License.
'*
'/************************************************************************
'*
'* owner : marc.neumann@sun.com
'*
'* short description : Table Wizard
'*
'\***********************************************************************
sub wiz_TableWizard
    
    call tNewTable        
    call tStartFormWizardFromTableWizard
    call tCreateAllTables   

    call tCheckSampleTables
    call tChangeFieldName

end sub
'-------------------------------------------------------------------------
testcase tNewTable  

    if bAsianLan = true then
        qaerrorlog "#i62665# Table wizard doesn't work in CJK versions. So some test are left out."
        goto endsub
    endif

    if (iSprache = 7) then
        qaerrorlog "due to issue i94730 this testcase does not work under russian."
        goto endsub
    endif 
    
    'hold a table name
    Dim sTableName as String 

    '/// open Bibliography database
    printlog "open Bibliography database"
    if not fOpenDataBase(gOfficePath + ConvertPath("user/database/biblio.odb")) then
        warnlog "Database " + gOfficePath + ConvertPath("user/database/biblio.odb") + " could not be open."
        goto endsub
    end if

    '/// start the table wizard
    printlog "start the table wizard"
    if not fStartTableWizard() then
        warnlog "The table wizard doesn't start. TEST STOPPED"
        goto endsub
    endif

    Kontext "TableWizard"
        '/// add all fields from the displayed table
        printlog "add all fields from the displayed table"
        AddAll.click
        '/// click NEXT
        printlog "click NEXT"
        NextBtn.click
             
        '/// click NEXT
        printlog "click NEXT"
        NextBtn.click

        'remember the table, because we want to delete it later
        sTableName = TableName.getText                    
        '/// click Finish
        printlog "click Finish"       
        FinishBtn.Click
    
    sleep(1)

    '/// close the open table
    printlog "close the open table"
    call fCloseTableView()
    
    '/// delete the created table
    printlog "delete the created table"
    call fDeleteTable sTableName

    '/// close the database
    printlog "close the database"
    call fClosedatabase()
    
endcase   
'-------------------------------------------------------------------------
testcase tCheckSampleTables

    dim iTablesCount as Integer
    dim iFieldsCount as Integer
    dim i as Integer
    dim ii as Integer        

    '/// open Bibliography database
    printlog "open Bibliography database"
    if not fOpenDataBase(gOfficePath + ConvertPath("user/database/biblio.odb")) then
        warnlog "Database " + gOfficePath + ConvertPath("user/database/biblio.odb") + " could not be open."
        goto endsub
    end if

    '/// start the table wizard
    printlog "start the table wizard"
    if not fStartTableWizard() then
        warnlog "The table wizard doesn't start. TEST STOPPED"
        goto endsub
    endif
    
    Kontext "TableWizard"        
        '/// check if there are 22 table in the business category
        printlog "check if there are 22 table in the business category"
        iTablesCount = Tables.GetItemCount()
        if ( iTablesCount <> 22 ) then
            warnlog "the number of tables in the business category should be 22 but it is : " + iTablesCount
        endif

        '/// check the count of all fields in all table in the business category
        printlog "check the count of all fields in all table in the business category"
        for i = 1 to iTablesCount 
            Tables.select i
            'printlog Tables.getseltext
            iFieldsCount = iFieldsCount + Fields.getItemCount
	            for ii = 1 to Fields.getItemCount
					Fields.select ii
	            	'printlog "          " + Fields.getSelText
	            next
        next

        if ( iFieldsCount <> 318 AND iFieldsCount <> 290 ) then
            warnlog "the number of all fields should be 318 or 290 but it is : " + iFieldsCount
        endif
    
    Kontext "TableWizard"
        '/// check the personal radio button
        Personal.Check            
        '/// check if there are 15 table in the personal category
        printlog "check if there are 15 table in the personal category"
        iTablesCount = Tables.GetItemCount()
        if ( iTablesCount <> 15 ) then
            warnlog "the number of tables in the personal category should be 15 but it is : " + iTablesCount
        endif

        '/// check the count of all fields in all table in the personal category
        printlog "check the count of all fields in all table in the personal category"
        for i = 1 to iTablesCount 
            Tables.select i
            'printlog Tables.getseltext
            iFieldsCount = iFieldsCount + Fields.getItemCount
	            for ii = 1 to Fields.getItemCount
					Fields.select ii
	            	'printlog "          " + Fields.getSelText
	            next
        next

        if ( iFieldsCount <> 480 AND iFieldsCount <> 508 ) then            
            warnlog "the number of all fields should be 480 or 508 but it is : " + iFieldsCount
        endif
        if (iFieldsCount = 480) then
            qaerrorlog "There have to be 508 fields. Please contact msc."
        endif
            
        '/// click CANCEL
        printlog "click CANCEL"       
        CancelBtn.Click
    
        '///close the database
        printlog "close the database"
        call fClosedatabase()
    
endcase   
'-------------------------------------------------------------------------
testcase tChangeFieldName

    if (iSprache = 7) then
        qaerrorlog "due to issue i94730 this testcase does not work under russian."
        goto endsub
    endif

    '/// open Bibliography database
    printlog "open Bibliography database"
    if not fOpenDataBase(gOfficePath + ConvertPath("user/database/biblio.odb")) then
        warnlog "Database " + gOfficePath + ConvertPath("user/database/biblio.odb") + " could not be open."
        goto endsub
    end if

    '/// delete the table t_wizard if it's allready exists
    printlog "delete the table t_wizard if it's allready exists"
    call fDeleteTable ("t_wizard")

    '/// start the table wizard
    printlog "start the table wizard"
    if not fStartTableWizard() then
        warnlog "The table wizard doesn't start. TEST STOPPED"
        goto endsub
    endif
    
    Kontext "TableWizard"
        '/// select the first field
        printlog "select the first field"
        Fields.Select 1
        '/// click the add button
        printlog "click the add button"
        Add.click        
        '/// click NEXT
        printlog "click NEXT"
        NextBtn.click

        '/// select the first field
        printlog "select the first field"		
        FieldNames.select 1
        '/// change the field name for the first field to field_test
        FieldName.setText("field_test")              
        '/// click the add fields button (the + sign)
        printlog "click the add fields button (the + sign)"                 
        FieldsAdd.Click()
        '/// select the second field
        printlog "select the second field"
        FieldNames.select 2
        '/// change the field name for the second field to field_2
        printlog "change the field name for the second field to field_2"
        FieldName.setText("field_2")
        '/// click on field move up button to move the second filed to the first position
        printlog "click on field move up button to move the second filed to the first position"        
        FieldsUp.click()        
        '/// click NEXT
        printlog "click NEXT"
        NextBtn.click

        '/// change table name to t_wizard
        printlog "change table name to t_wizard"
        TableName.settext "t_wizard"            
        '/// click Finish
        printlog "click Finish"
        FinishBtn.Click
    
    sleep(1)

    '/// close the table view
    printlog "close the table view"
    call fCloseTableView()

    '/// open the table t_wizard in the design view
    printlog "open the table t_wizard in the design view"
    call fOpenTableInDesign("t_wizard")

    Kontext "TableDesignTable"
        '/// check if the first field is field_2
        printlog "check if the first field is field_2"
        Dim s as String
        s = Fieldname.getText
        if s <> "field_2" then
            printlog "the field name of the first field is not 'field_2' it is '" + s + "'."
            warnlog "the renaming or moving of a field in the wizard doesn't work"
        else
            printlog "==>> the first field name is field_2 => OK"            
        endif
        '/// check the second field
        TableDesignTable.typeKeys("<DOWN>")
        s = Fieldname.getText
        if s <> "field_test" then
            printlog "the field name of the second field is not 'field_test' it is '" + s + "'."
            warnlog "the renaming or moving of a field in the wizard doesn't work"
        else
            printlog "==>> the second field name is field_test => OK"            
        endif
        
    '/// close the table design
    printlog "close the table design"
    call fCloseTableDesign

    '/// delete the table t_wizard we dont't need it anymore
    printlog "delete the table t_wizard we dont't need it anymore"
    call fDeleteTable ("t_wizard")

    '/// close the database
    printlog "close the database"
    call fClosedatabase()
    
endcase   
'-------------------------------------------------------------------------
testcase tStartFormWizardFromTableWizard
    
    if bAsianLan = true then
        qaerrorlog "#i62665# Table wizard doesn't work in CJK versions. So some test are left out."
        goto endsub
    endif
    
    if (iSprache = 7) then
        qaerrorlog "due to issue i94730 this testcase does not work under russian."
        goto endsub
    endif
    
    'hold a table name
    Dim sTableName as String 

    '/// open Bibliography database
    printlog "open Bibliography database"
    if not fOpenDataBase(gOfficePath + ConvertPath("user/database/biblio.odb")) then
        warnlog "Database " + gOfficePath + ConvertPath("user/database/biblio.odb") + " could not be open."
        goto endsub
    end if

    '/// start the table wizard
    printlog "start the table wizard"
    if not fStartTableWizard() then
        warnlog "The table wizard doesn't start. TEST STOPPED"
        goto endsub
    endif

    Kontext "TableWizard"
        '/// add all fields from the displayed table
        printlog "add all fields from the displayed table"
        AddAll.click
        '/// click NEXT
        printlog "click NEXT"
        NextBtn.click
             
        '/// click NEXT
        printlog "click NEXT"
        NextBtn.click

        'remember the table, because we want to delete it later
        sTableName = TableName.getText  
                  
        CreateForm.Check

        '/// click Finish
        printlog "click Finish"       
        FinishBtn.Click
    
    sleep(10)
    
    '/// check if the form wizard appear
    printlog "check if the form wizard appear"
    Kontext "FormWizard"
        if FormWizard.exists(1) then
            printlog "The formwizard appear ==>> OK"
            CancelBtn.Click
        else
            warnlog "The Form Wizard doesn't appear."
        endif
    
    '/// delete the created table
    printlog "delete the created table"
    call fDeleteTable sTableName

    '/// close the database
    printlog "close the database"
    call fClosedatabase()
    
endcase
'-------------------------------------------------------------------------
testcase tCreateAllTables

    if bAsianLan = true then
        qaerrorlog "#i62665# Table wizard doesn't work in CJK versions. So some test are left out."
        goto endsub
    endif

    '/// create all tables form the business and personal category
    printlog "create all tables form the business and personal category"

    Dim i as integer 

    'copy the hsqldb database file to a local path    
    app.FileCopy gTesttoolPath + ConvertPath("dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb"),gOfficePath + ConvertPath("user/work/TT_hsqldb.odb")

    '/// open a hsql database
    printlog "open a hsql database"
    call fOpendatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb"))
    sleep(5)  

    '/// check if there are 22 items in the business categoriy 
    if not fStartTableWizard() then
        warnlog "The table wizard doesn't start. TEST STOPPED"
        goto endsub
    endif    

    Kontext "TableWizard"
    dim iCount as integer
    iCount = Tables.GetItemCount
    if(iCount <> 22 ) then
        warnlog "#102019# there are not 22 table in the category business. There are " + iCount
        CancelBtn.Click
        call fCloseDatabase()
        goto endsub
    endif
    CancelBtn.Click        
    
    for i = 1 to 22

        '/// start the table wizard
        printlog "start the table wizard"
        if not fStartTableWizard() then
            warnlog "The table wizard doesn't start. TEST STOPPED"
            goto endsub
        endif    

        Kontext "TableWizard"
        Tables.select i
        dim sTableName as String
        sTableName = Tables.getSelText
        printlog "Create table " + sTableName 
        '/// add all fields
        printlog "   add all fields"
        AddAll.click
        '/// click Finish
        printlog "   click Finish"       
        FinishBtn.Click
        
        Kontext "MessageBox"
        if ( MessageBox.exists(3) ) then
            warnlog "error while creating table: " + sTableName
            MessageBox.OK
            Kontext "TableWizard"
                CancelBtn.Click
        else
            '/// close the open table
            printlog "   close the open table"
            call fCloseTableView()
        endif
    next
    
    '/// now create all tables from the personal tables
    printlog "now create all tables from the personal tables"
    
    if not fStartTableWizard() then
        warnlog "The table wizard doesn't start. TEST STOPPED"
        goto endsub
    endif  
    
    Kontext "TableWizard"            
        Personal.Check 
        iCount = Tables.GetItemCount
        if(iCount <> 15 ) then
            warnlog "#102019# there are not 15 table in the category business. There are " + iCount
            CancelBtn.Click
            call fCloseDatabase()
            goto endsub
        endif
        CancelBtn.Click
    
    for i = 1 to 15
        '/// start the table wizard
        printlog "start the table wizard"
        if not fStartTableWizard() then
            warnlog "The table wizard doesn't start. TEST STOPPED"
            goto endsub
        endif    
        Kontext "TableWizard"        
        Personal.Check 
        Tables.select i        
        sTableName = Tables.getSelText
        printlog "Create table " + sTableName
        '/// add all fields
        printlog "   add all fields"
        AddAll.click                            
        '/// click Finish
        printlog "   click Finish"       
        FinishBtn.Click

        Kontext "MessageBox"
        if ( MessageBox.exists(3) ) then
            warnlog "error while creating table: " + sTableName
            MessageBox.OK
            Kontext "TableWizard"
                CancelBtn.Click
        else
            '/// close the open table
            printlog "   close the open table"
            call fCloseTableView()
        endif
    next    
    sleep(1)

    '/// close the database
    printlog "close the database"
    call fClosedatabase()

endcase