'encoding UTF-8 Do not remove or change this line! '************************************************************************* ' ' Licensed to the Apache Software Foundation (ASF) under one ' or more contributor license agreements. See the NOTICE file ' distributed with this work for additional information ' regarding copyright ownership. The ASF licenses this file ' to you under the Apache License, Version 2.0 (the ' "License"); you may not use this file except in compliance ' with the License. You may obtain a copy of the License at ' ' http://www.apache.org/licenses/LICENSE-2.0 ' ' Unless required by applicable law or agreed to in writing, ' software distributed under the License is distributed on an ' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ' KIND, either express or implied. See the License for the ' specific language governing permissions and limitations ' under the License. ' '************************************************************************* '* '* short description : Fields - Variables '* '\*********************************************************************** sub w_fields5 Call tVariablesSetValueToText Call tVariablesSetValueToNumber Call tVariablesSetFormats Call tVariablesShowVariable1 Call tVariablesShowVariable2 Call tVariablesInsertFormula Call tVariablesNumberRange Call tVariablesInputfield Call tVariablesUserfield Call tVariablesDDEFieldManual Call tVariablesDDEFieldAutomatic end sub '----------------------------------------------------------------- testcase tVariablesSetValueToText if bAsianLan = true then QaErrorLog "No testing with Asian language. Aborting." exit sub end if Dim sName() as String Dim sValue as String Dim sResult() as String Dim i as Integer Dim j as Integer sValue = "This is a test!" sName = Array( _ "myTest1" , _ "myTest2" , _ "myTest3" , _ "myTest4" , _ "myTest5" , _ "myTest6" , _ ) sResult = Array( _ "This is a test!" , _ "1" , _ "1" , _ "1" & gSeperator & "00" , _ "1" , _ "1" & gSeperator & "00" , _ ) j = UBound(sResult) printlog "Set value to text" '/// Set value to text Call hNewDocument '/// Insert/Fields/Other/Variables / Select "set Variable" , '/// Set Name and Value(text) , then choose Text , General , '/// + -1234 , -1234.12 , -1,234 , -1,234,12 separately Call fInsertFieldsOther("TabVariablen") for i = 0 to j Feldtyp.Select 1 Sleep 1 NameText.SetText sName(i) Wert.SetText sValue Zahlenformat.Select i+1 Einfuegen.Click sleep 1 Call wTypeKeys "" Kontext "TabVariablen" next i Kontext "TabVariablen" TabVariablen.Close '/// Check if the insertion is correct Call wTypeKeys "" for i = 0 to j Call wTypeKeys "" if fGetFieldContent() <> sResult(i) then Warnlog i & "Should get " & sResult(i) & " but get " & fGetFieldContent() end if Call wTypeKeys "" next i Call hCloseDocument endcase '----------------------------------------------------------------- testcase tVariablesSetValueToNumber if bAsianLan = true then QaErrorLog "No testing with Asian language. Aborting." exit sub end if Dim sName() as String Dim sValue as String Dim sResult() as String Dim i as Integer Dim j as Integer sValue = "1234,567" sName = Array( _ "myTest1" , _ "myTest2" , _ "myTest3" , _ "myTest4" , _ "myTest5" , _ "myTest6" , _ ) sResult = Array( _ "1234,567" , _ "1234,57" , _ "1235" , _ "1234,57" , _ "1.235" , _ "1.234,57" , _ ) j = UBound(sResult) printlog "Set value to number" '/// Set value to number Call hNewDocument '/// Insert/Fields/Other/Variables / Select "set Variable" , '/// Set Name and Value(number) , then choose Text , General , '/// + -1234 , -1234.12 , -1,234 , -1,234,12 separately Call fInsertFieldsOther("TabVariablen") for i = 0 to j Feldtyp.Select 1 Sleep 1 NameText.SetText sName(i) Wert.SetText sValue Zahlenformat.Select i+1 Einfuegen.Click sleep 1 Call wTypeKeys "" Kontext "TabVariablen" next i Kontext "TabVariablen" TabVariablen.Close '/// Check if the insertion is correct Call wTypeKeys "" for i = 0 to j Call wTypeKeys "" if fGetFieldContent() <> sResult(i) then Warnlog i & "Should get " & sResult(i) & " but get " & fGetFieldContent() end if Call wTypeKeys "" next i Call hCloseDocument endcase '----------------------------------------------------------------- testcase tVariablesSetFormats Dim sName as String Dim sValue as String Dim iFormat() as Integer Dim sResult() as String Dim i as Integer Dim j as Integer Dim mUnit as String sName = "myTest" sValue = "1234.567" iFormat = Array( 8, 10 , 52 , 55 , 56) sResult = Array( _ "123456.70%" , _ "$1,234.57" , _ "1.23E+003" , _ "1234 55/97" , _ "TRUE" , _ ) j = UBound(sResult) printlog "Set format as 'Additional formats...'" '/// Set format as 'Additional formats...' Call hNewDocument CALL GetLanguageText (01) mUnit = fSetMeasurementToCM() ' Set measurement unit to cm '/// Insert/Fields/Other/Variables / Select "set Variable" , '/// Set Name and Value(number) , then choose format as 'Additional formats...' '/// In the number format dialog , select 'All' in Category '/// + Select some different formats ... Call fInsertFieldsOther("TabVariablen") Feldtyp.Select 1 Sleep 1 NameText.SetText sName Wert.SetText sValue for i = 0 to j Zahlenformat.Select Zahlenformat.GetItemCount Sleep 3 Kontext "Zahlenformat" Sprache.Select fGetLanguageName(01) Sleep 2 Kategorie.Select 1 Sleep 1 KategorieFormat.Select iFormat(i) Sleep 1 Zahlenformat.OK Kontext "TabVariablen" Einfuegen.Click Call wTypeKeys "" sleep 1 if fGetFieldContent() <> sResult(i) then Warnlog i & ": Should get " & sResult(i) & " but get " & fGetFieldContent() end if Kontext "TabVariablen" next i TabVariablen.Close Call hCloseDocument endcase '----------------------------------------------------------------- testcase tVariablesShowVariable1 Dim sName() as String Dim sResult() as String Dim i as Integer Dim j as Integer sName = Array( _ "myTest1" , _ "myTest2" , _ "myTest3" , _ ) sResult = Array( _ "1" , _ "10" , _ "100" , _ ) j = UBound(sResult) printlog "Show Variable - 1" '/// Show Variable - 2 Call hNewDocument '/// Insert/Fields/Other/Variables / Select "set Variable" , '/// Set Name and Value , then choose General , add 3 variables '/// + then select Show Variable , insert 3 variables Call fInsertFieldsOther("TabVariablen") for i = 0 to j Feldtyp.Select 1 Sleep 1 NameText.SetText sName(i) Wert.SetText sResult(i) Zahlenformat.Select 2 Einfuegen.Click sleep 1 next i for i = 0 to j Call wTypeKeys "" Kontext "TabVariablen" Feldtyp.Select 2 Sleep 1 Auswahl.Select i+1 Einfuegen.Click sleep 1 next i TabVariablen.Close '/// Check if the insertion is correct Call wTypeKeys "" for i = 0 to j Call wTypeKeys "" Call wTypeKeys "" if fGetFieldContent() <> sResult(i) then Warnlog "Should get " & sResult(i) & " but get " & fGetFieldContent() end if next i '/// Delete the 1st line Call wTypeKeys "" Call wTypeKeys "" for i = 0 to j Call wTypeKeys "" Call wTypeKeys "" if fGetFieldContent() <> "0" then Warnlog i & "Should get 0 but get " & fGetFieldContent() end if next i Call hCloseDocument endcase '----------------------------------------------------------------- testcase tVariablesShowVariable2 Dim sName as String Dim sValue as String Dim sResult() as String Dim i as Integer Dim j as Integer sResult = Array( _ "100" , _ "100" , _ "200" , _ "200" , _ ) j = UBound(sResult) sName = "myTest" printlog "Show Variable - 2" '/// Show Variable - 2 Call hNewDocument '/// Insert/Fields/Other/Variables / Select "set Variable" , '/// Set Name and Value , then choose General , insert a variable Call fInsertFieldsOther("TabVariablen") sValue = "100" Feldtyp.Select 1 Sleep 1 NameText.SetText sName Wert.SetText sValue Zahlenformat.Select 2 Einfuegen.Click '/// Then select Show Variable , insert this variable Call wTypeKeys "" Kontext "TabVariablen" Feldtyp.Select 2 Sleep 1 Auswahl.Select 1 Einfuegen.Click '/// Insert a same name variable again , but set to another number Call wTypeKeys "" sValue = "200" Kontext "TabVariablen" Feldtyp.Select 1 Sleep 1 NameText.SetText sName Wert.SetText sValue Zahlenformat.Select 2 Einfuegen.Click '/// Then select Show Variable , insert this variable again Call wTypeKeys "" Kontext "TabVariablen" Feldtyp.Select 2 Sleep 1 Auswahl.Select 1 Einfuegen.Click TabVariablen.Close '/// Check if the insertion is correct Call wTypeKeys "" for i = 0 to j Call wTypeKeys "" if fGetFieldContent() <> sResult(i) then Warnlog i & "Should get " & sResult(i) & " but get " & fGetFieldContent() end if Call wTypeKeys "" next i Call hCloseDocument endcase '----------------------------------------------------------------- testcase tVariablesInsertFormula Dim sName() as String Dim sValue() as String Dim sResult as String Dim i as Integer Dim j as Integer sName = Array( _ "myTest1" , _ "myTest2" , _ ) sValue = Array( _ "10" , _ "100" , _ ) sResult = "110" j = UBound(sName) printlog "Insert formula" '/// Insert formula Call hNewDocument '/// Insert/Fields/Other/Variables / Select "set Variable" , add 2 variables - A and B Call fInsertFieldsOther("TabVariablen") for i = 0 to j Feldtyp.Select 1 Sleep 1 NameText.SetText sName(i) Wert.SetText sValue(i) Zahlenformat.Select 2 Einfuegen.Click sleep 1 next i '/// Then select 'Insert formula' , A+B Call wTypeKeys "" Kontext "TabVariablen" Feldtyp.Select 4 Wert.SetText (sName(0) & "+" & sName(1)) Einfuegen.Click TabVariablen.Close Call wTypeKeys "" if fGetFieldContent() <> sResult then Warnlog "Should get " & sResult & " but get " & fGetFieldContent() end if Call hCloseDocument endcase '----------------------------------------------------------------- testcase tVariablesNumberRange Dim sResult() as String Dim i as Integer Dim x as Integer printlog "Number range" '/// Number range Call hNewDocument Call wTypeKeys "" '/// Insert/Fields/Other/Variables / Select "Number range" , insert 4 numbers for '/// + Table , text , drawing and illustration Call fInsertFieldsOther("TabVariablen") for i = 1 to 4 Feldtyp.Select 6 Sleep 1 Auswahl.Select i Einfuegen.Click Call wTypeKeys "" Kontext "TabVariablen" sleep 1 next i '/// Then insert Table , text , drawing and illustration separately '/// + Check if the result is correct Call wTypeKeys "" Kontext "TabVariablen" for i = 1 to 4 Feldtyp.Select 6 Sleep 1 Auswahl.Select i Einfuegen.Click Sleep 2 Call wTypeKeys "" sResult = Array("1" , "1" , "1" , "1" , "1") sResult(i) = "2" for x = 0 to 4 Call wTypeKeys "" if fGetFieldContent() <> sResult(x) then Warnlog "Should get " & sResult(x) & " but get " & fGetFieldContent() end if Call wTypeKeys "" next x Call wTypeKeys "" sleep 1 Kontext "TabVariablen" next i TabVariablen.Close Call hCloseDocument endcase '----------------------------------------------------------------- testcase tVariablesInputfield Dim sName as String Dim sValue as String Dim sReference as String Dim sFieldContent as String sName = "myTest" : sValue = "100" sReference = "NewTest" sFieldContent = "10000" printlog "Input field" '/// Input field Call hNewDocument '/// Insert/Fields/Other/Variables / Select "set Variable" , add 1 variable - A Call fInsertFieldsOther("TabVariablen") Feldtyp.Select 1 Sleep 1 NameText.SetText sName Wert.SetText sValue Zahlenformat.Select 2 Einfuegen.Click Call wTypeKeys "" Sleep 1 '/// Select "Input field" , set reference , press insert , '/// + a dialog should pop up , insert field content '/// + Table , text , drawing and illustration Kontext "TabVariablen" Feldtyp.Select 5 Wert.SetText sReference Einfuegen.Click Kontext "Eingabefeld" if Titel.GetText <> sReference then Warnlog "Reference should be " & sReference & " but get " & Titel.GetText end if EingabeText.SetText sFieldContent Eingabefeld.OK Kontext "TabVariablen" TabVariablen.Close '/// Check if the insertion is correct Call wTypeKeys "" Call wTypeKeys "" if fGetFieldContent() <> sValue then Warnlog "Should get " & sValue & " but get " & fGetFieldContent() end if Call wTypeKeys "" Call wTypeKeys "" if fGetFieldContent() <> sFieldContent then Warnlog "Should get " & sFieldContent & " but get " & fGetFieldContent() end if '/// Delete variable A in the document , Check if the insertion is still correct Call wTypeKeys "" Call wTypeKeys "" Call wTypeKeys "" Call wTypeKeys "" if fGetFieldContent() <> sFieldContent then Warnlog "2-Should get " & sFieldContent & " but get " & fGetFieldContent() end if Call hCloseDocument endcase '----------------------------------------------------------------- testcase tVariablesUserfield Dim sName() as String Dim sValue() as String Dim sResult1() as String Dim sResult2() as String Dim i as Integer Dim j as Integer sName = Array("U1" , "UserField" , "U2") sValue = Array("UserField - 10" , "100" , "UserField + 10") sResult1 = Array("-10" , "100" , "110") sResult2 = Array("90" , "100" , "110") j = UBound(sResult1) printlog "User field" '/// User field Call hNewDocument '/// Insert/Fields/Other/Variables / Select "User Field" Call fInsertFieldsOther("TabVariablen") for i = 0 to j Feldtyp.Select 9 Sleep 1 NameText.SetText sName(i) Wert.SetText sValue(i) Zahlenformat.Select 3 Einfuegen.Click Sleep 2 Call wTypeKeys "" if fGetFieldContent() <> sResult1(i) then Warnlog "Should get " & sResult1(i) & " but get " & fGetFieldContent() end if Call wTypeKeys "" sleep 1 Kontext "TabVariablen" next i TabVariablen.Close '/// Check if the result is OK. Call wTypeKeys "" Call wTypeKeys "" Sleep 1 for i = 0 to j Call wTypeKeys "" if fGetFieldContent() <> sResult2(i) then Warnlog "Should get " & sResult2(i) & " but get " & fGetFieldContent() end if Call wTypeKeys "" next i Call hCloseDocument endcase '----------------------------------------------------------------- testcase tVariablesDDEFieldManual qaerrorlog "#i112079#testcase must be reworked" goto endsub Dim sDDEFile as String Dim sContent as String Dim sName as String Dim sDDEStatement as String Dim sSectionName as String sDDEFile = Convertpath ( gOfficePath + "\user\work\dde_test.odt") sContent = "DDE" sName = "myTest" sSectionName = "Section1" sDDEStatement = "soffice " & sDDEFile & " " & sSectionName printlog "DDE field - manual" '/// DDE field - manual if FileExists ( sDDEFile ) then app.kill ( sDDEFile ) Call hNewDocument '/// Input something , insert a section , then save it and close the file Call wTypeKeys sContent Call wTypeKeys "" Call fInsertSection("TabBereiche") Bereichsliste.Settext sSectionName TabBereiche.OK Sleep 1 Call hFileSaveAsKill(sDDEFile) Call hCloseDocument '/// Opan a new document Call hNewDocument '/// Insert/Fields/Other/Variables / Select "DDE Field" '/// Set DDE name and DDE statement , select "DDE manual" Call fInsertFieldsOther("TabVariablen") Feldtyp.Select 3 Sleep 1 NameText.SetText sName Wert.SetText sDDEStatement Formatliste.Select 1 Einfuegen.Click Sleep 2 TabVariablen.Close Sleep 2 Call wTypeKeys "" Call wTypeKeys "" if fGetFieldContent() <> sContent then Warnlog "Should get " & sContent & " but get " & fGetFieldContent() end if '/// Open the test file which you just closed , add something , '/// Save the file hFileOpenLocally( sDDEFile) Call wTypeKeys "" Call wTypeKeys "XYZ" FileSave Call hCloseDocument '/// Check if the content is changed -- Should NOT Sleep 2 Call wTypeKeys "" Call wTypeKeys "" if fGetFieldContent() <> sContent then Warnlog "Should get " & sContent & " but get " & fGetFieldContent() end if '/// Edit/Fields , press update button EditFields Kontext "VerknuepfungenBearbeiten" Aktualisieren.Click VerknuepfungenBearbeiten.Close '/// Check if the content is changed -- Should NOT Sleep 1 Call wTypeKeys "" Call wTypeKeys "" if fGetFieldContent() <> ("XYZ" & sContent) then Warnlog "Should get XYZ" & sContent & " but get " & fGetFieldContent() end if Call hCloseDocument if FileExists( sDDEFile ) then app.kill ( sDDEFile ) endcase '----------------------------------------------------------------- testcase tVariablesDDEFieldAutomatic qaerrorlog "#i112079#testcase must be reworked" goto endsub qaerrorlog "#i102792# - tVariablesDDEFieldAutomatic outcommented. Fields not updated." goto endsub Dim sDDEFile as String Dim sContent as String Dim sName as String Dim sDDEStatement as String Dim sSectionName as String sDDEFile = Convertpath ( gNetzOfficePath + "dde_test.oxt") sContent = "DDE" sName = "myTest" sSectionName = "Section1" sDDEStatement = "soffice " & sDDEFile & " " & sSectionName printlog "DDE field - automatic" '/// DDE field - automatic if FileExists ( sDDEFile ) then app.kill ( sDDEFile ) Call hNewDocument '/// Input something , insert a section , then save it and close the file Call wTypeKeys sContent Call wTypeKeys "" Call fInsertSection("TabBereiche") Bereichsliste.Settext sSectionName TabBereiche.OK Sleep 1 Call hFileSaveAsKill(sDDEFile) Call hCloseDocument '/// Opan a new document Call hNewDocument '/// Insert/Fields/Other/Variables / Select "DDE Field" '/// Set DDE name and DDE statement , select "DDE automatic" Call fInsertFieldsOther("TabVariablen") Feldtyp.Select 3 Sleep 1 NameText.SetText sName Wert.SetText sDDEStatement Formatliste.Select 2 Einfuegen.Click Sleep 2 TabVariablen.Close Sleep 2 Call wTypeKeys "" Call wTypeKeys "" if fGetFieldContent() <> sContent then Warnlog "Should get " & sContent & " but get " & fGetFieldContent() end if '/// Open the test file which you just closed , add something , '/// Save the file hFileOpenLocally( sDDEFile) Call wTypeKeys "" Call wTypeKeys "XYZ" FileSave Call hCloseDocument '/// Check if the content is changed -- Should Sleep 2 Call wTypeKeys "" Call wTypeKeys "" if fGetFieldContent() <> ("XYZ" & sContent) then Warnlog "Should get XYZ" & sContent & " but get " & fGetFieldContent() end if Call hCloseDocument if FileExists ( sDDEFile ) then app.kill ( sDDEFile ) endcase '-----------------------------------------------------------------