summaryrefslogtreecommitdiff
path: root/testautomation/framework/optional/includes/basic_formcontrols.inc
blob: 36a4ae35e1ab209d21a2cd7dca4032acc4d1cc34 (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
'encoding UTF-8  Do not remove or change this line!
'**************************************************************************
' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'
' Copyright 2000, 2010 Oracle and/or its affiliates.
'
' OpenOffice.org - a multi-platform office productivity suite
'
' 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 : gregor.hartmann@oracle.com
'*
'* short description : Basic form-controls
'*
'\******************************************************************************

private const ICONTROLCOUNT = 22

testcase tAllControlsOnDialog( cMajor as string )

    printlog( "Insert all available controls into a BASIC dialog and verify that changed settings persist a save/load cycle" )
    
    'qaerrorlog( "#i105685# - Test disabled" )
    'goto endsub

    dim iApplication as Integer ' numeric expression for gApplication
    dim cApplication as string  ' Name of the current application
    
    ' number of controls and the name of the current control
    dim iCurrentControl as integer
    dim sCurrentControl as string

    ' the workfile and the filter (Tested for 569, 645, 680)
    dim sFile as string

    const CMODULE = "tacod" ' abbreviation for tAllControlsOnDialog
    const BUTTON_TIMEOUT = -1
    const UPPER_BOUNDARY = 1 ' 1 = only writer, increase to add Calc, Impress, Draw...

    ' Currently set to test writer only. Increase upper boundary to add applications
    ' Up to 4 should be useful
    for iApplication = 1 to UPPER_BOUNDARY
    
        cApplication = hNumericDoctype( iApplication )
        printlog( "Document type: " & cApplication )

        sFile = convertpath( hGetWorkPath() & "basic" & hGetSuffix( cMajor ) )
        printlog( "Using file: " & sFile )
        
        printlog( "Delete the file, if it exists" )
        hDeleteFile( sFile )
                
        printlog( "Open a second document" )
        hCreateDocument()

        printlog( "Create a new module for the new document, new dialog, open macro controls" )
        if ( not hInitFormControls( CMODULE ) ) then
            printlog( "Aborting due to previous errors" )
            hDestroyDocument()
            goto endsub
        endif

        printlog( "Insert all controls into the dialog" )
        for iCurrentControl = 1 to ICONTROLCOUNT

            sCurrentControl = hDrawControlOnDialog( iCurrentControl )
            hUseAsyncSlot( "ContextProperties" )
            kontext "ControlPropertiesTabControl"
            if ( ControlPropertiesTabControl.exists( 1 ) ) then
                hPBSetControlName( sCurrentControl )
                hUseAsyncSlot( "ContextProperties" )
            else
                warnlog( "Property browser not open" )
            endif

        next iCurrentControl
        
        Kontext "BASICIDE"
        printlog( "close the BASIC-IDE" )
        hCloseBasicIde()
        
        printlog( "" )
        printlog( "Test case 1: Verify that settings survive a close and reopen of the BASIC IDE" )
        
        ToolsMacro_uno
        kontext "Makro"
        if ( hSelectNodeByName( MakroAus , CMODULE ) ) then
            printlog( "The node was found. Good." )
        else
            qaerrorlog( "Searching node by name failed. Using fallback" )
            hSelectTheLastnode( MakroAus )
        endif
        
        printlog( "Edit the module" )
        if ( hClickButton( Bearbeiten ) = BUTTON_TIMEOUT ) then
            warnlog( "Edit-Button is not enabled, the test cannot continue" )
            kontext "Makro"
            hCloseDialog( Makro, "cancel" )
            hDestroyDocument()
            goto endsub
        endif

        kontext "BasicIDE"
        printlog( "Find the dialog we created before" )
        if ( hFindFirstDialog() ) then
            printlog( "First dialog found. Good." )
        else
            warnlog( "#i115117 - Could not access dialog, accelerator not working? (Test interrupted)" )
            hCloseBasicIde()
            hDestroyDocument()
            goto endsub
        endif

        printlog( "Select every control, open its properties and verify its name, close properties" )
        for iCurrentControl = 1 to ICONTROLCOUNT

            sCurrentControl = hGetControlName( iCurrentControl )
            if ( hSelectControl( iCurrentControl ) ) then
                kontext "ControlPropertiesTabControl"
                if ( ControlPropertiesTabControl.exists( 5 ) ) then
                    wait( 300 )
                    hPBGetControlName( sCurrentControl )
                    hUseAsyncSlot( "ContextProperties" )
                    kontext "ControlPropertiesTabControl" : ControlPropertiesTabControl.notExists( 3 )
                else
                    warnlog( "Property browser not open for " & sCurrentControl )
                endif
            else
                warnlog( "Failed to select control: " & sCurrentControl )
            endif
            
        next iCurrentControl
       
        printlog( "Close the BASIC-IDE" )
        hCloseBasicIde()        
        
        if ( getDocumentCount <> 1 ) then warnlog( "Number of open documents is incorrect, expected one only" )

        printlog( "Save the document" )
        Call hFileSaveAsKill( sFile )

        printlog( "Close the document" )
        hDestroyDocument()

        printlog( "" ) 
        printlog( "Test case 2: Verify that all items keep their names after close and reload of the document" )
        
        printlog( "Open the file again" )
        hFileOpen( sFile )

        printlog( "Open the basic-IDE from this document, open controls, activate 'Select-mode' and open the properties" )
        ToolsMacro_uno

        kontext "Makro"
        if ( hSelectNodeByName( MakroAus , CMODULE ) ) then
            printlog( "The node was found. Good." )
        else
            qaerrorlog( "Searching node by name failed. Using fallback" )
            hSelectTheLastnode( MakroAus )
        endif
        
        printlog( "Edit the module" )
        if ( hClickButton( Bearbeiten ) = BUTTON_TIMEOUT ) then
            warnlog( "Edit-Button is not enabled, the test cannot continue" )
            kontext "Makro"
            hCloseDialog( Makro, "cancel" )
            hDestroyDocument()
            goto endsub
        endif

        kontext "BasicIDE"
        printlog( "Find the dialog we created before" )
        if ( hFindFirstDialog() ) then
            printlog( "First dialog found. Good." )
        else
            warnlog( "Could not access dialog, aborting test" )
            hCloseBasicIde()
            hDestroyDocument()
            goto endsub
        endif

        printlog( "Select every control, open its properties and verify its name, close properties" )
        for iCurrentControl = 1 to ICONTROLCOUNT

            sCurrentControl = hGetControlName( iCurrentControl )
            if ( hSelectControl( iCurrentControl ) ) then
                kontext "ControlPropertiesTabControl"
                if ( ControlPropertiesTabControl.exists( 5 ) ) then
                    wait( 300 )
                    hPBGetControlName( sCurrentControl )
                    hUseAsyncSlot( "ContextProperties" )
                    kontext "ControlPropertiesTabControl" : ControlPropertiesTabControl.notExists( 3 )
                else
                    warnlog( "Property browser not open for " & sCurrentControl )
                endif
            else
                warnlog( "Failed to select control: " & sCurrentControl )
            endif
            
        next iCurrentControl
            
        printlog( "Cleanup: Close the BASIC-IDE" )
        hCloseBasicIde()
        
        printlog( "Cleanup: Close the document" )
        hDestroyDocument()
        
        printlog( "Cleanup: Delete the file we created" )
        hDeleteFile( sFile )
        
    next iApplication

endcase