1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 '* Copyright 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: g_find_replace.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 10:42:40 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/************************************************************************
34 '* Owner : wolfram.garten@sun.com
36 '* short description : Edit -> Find & Replace
38 '***********************************************************************************
40 ' #1 tiEditSearchAndReplace
41 ' #1 tiEditSearchAndReplaceBUGS
43 '\**********************************************************************************
44 testcase tiEditSearchAndReplace
45 '/// This test tests the 'Search and Replace' -dialogue. ///'
47 Dim sExpression(2) as string ' Expression to look for: ... Replace with
50 Select Case Ucase(gApplication)
51 case "DRAW" : sExt = ".odg"
52 case "IMPRESS" : sExt = ".odp"
55 'First we need some errornes words to replace. (sExpression)
56 'sExpression(1) has to be 3 times in the document
58 case 01 : sExpression(1) = "Alle" : sExpression(2) = "Allz"
59 case 03 : sExpression(1) = "empreza" : sExpression(2) = "Emperor" ' Portuguese
60 case 07 : qaerrorlog "No files for Russian yet, will use english instead."
61 sExpression(1) = "Alle" : sExpression(2) = "Allz"
63 case 31 : sExpression(1) = "bedoeling" : sExpression(2) = "Bedoling" ' Netherlands
64 case 33 : sExpression(1) = "projjet" : sExpression(2) = "projete" ' French
65 case 34 : sExpression(1) = "lazsos" : sExpression(2) = "Lazsi" ' Spanish
67 case 36 : sExpression(1) = "Bozniai" : sExpression(2) = "Boszniai" ' Hungaria
69 case 39 : sExpression(1) = "Presentazione" : sExpression(2) = "Raggazi" ' Italian
72 case 44 : ' English (GB)
73 case 45 : sExpression(1) = "installlere" : sExpression(2) = "installer" ' Danish
74 case 46 : sExpression(1) = "desa" : sExpression(2) = "ased" ' Swedish
76 case 48 : sExpression(1) = "programmu" : sExpression(2) = "programu" ' Polish
77 case 49 : sExpression(1) = "Texxt" : sExpression(2) = "Schrieb" ' German
78 case 55 : sExpression(1) = "esktava" : sExpression(2) = "norte" ' Portuguese (Brazil)
80 ' case 81 : sExpression(1) = "���" : sExpression(2) = "���" ' Japanese
82 ' case 86 : ' Chinese (simplified)
83 ' case 88 : ' Chinese (traditional)
89 ' Warnlog "For the language " + iSprache +" nothing is prepared yet: insert text here and create the file"
90 printlog " :-) Will use English instead"
91 sExpression(1) = "Alle" : sExpression(2) = "Allz"
94 if ((bAsianLan) OR (iSprache = 07)) then
95 Call hFileOpen (gTesttoolpath + "graphics\required\input\recht_"+"1"+sExt)
97 Call hFileOpen (gTesttoolpath + "graphics\required\input\recht_"+iSprache+sExt)
99 ' check if the document is writable
100 if fIsDocumentWritable = false then
101 ' make the document writable and check if it's succesfull
102 if fMakeDocumentWritable = false then
103 warnlog "The document can't be make writeable. Test stopped."
111 if Messagebox.Exists then
112 Warnlog Messagebox.GetText
116 hTypeKeys "<MOD1 HOME>" '/// Select the text ///'
118 '/// Edit-Find & Replace I///'
121 Kontext "FindAndReplace"
122 '/// Clap the 'more options'-part open ///'
124 '/// verify, that search is done without 'similarity search' !!! ///'
125 if SimilaritySearch.IsChecked = TRUE then
126 SimilaritySearch.UnCheck
127 warnlog "'Similar search' checkbox was enabled! It shouldn't be the default!"
129 SearchFor.SetText sExpression(1) '/// set Search text ///'
130 ReplaceWith.SetText sExpression(2) '/// set Replace text///'
132 '/// Word has to be there ONLY three times ///'
133 SearchNow.Click '/// 1st search for text ///'
135 if Messagebox.Exists(2) then
136 Printlog Messagebox.GetText
140 Kontext "FindAndReplace"
142 SearchNow.Click '/// 2nd search for text ///'
144 if Messagebox.Exists(2) then
145 Printlog Messagebox.GetText
149 Kontext "FindAndReplace"
151 SearchNow.Click '/// 3th search for text///'
153 if Messagebox.Exists(2) then
154 Printlog Messagebox.GetText
158 Kontext "FindAndReplace"
160 SearchNow.Click '/// 4th search for text; but it is no more available!///'
163 if Messagebox.Exists Then
164 Printlog "- The word was found 3 times: '" + messagebox.gettext + "'"
167 SearchNow.Click '/// 5th search for word 1///'
169 if Messagebox.Exists (5) Then
170 Printlog "?: "+Messagebox.gettext
171 Warnlog "- No MsgBox appeared: 'changed'"
174 Warnlog "- No MsgBox appeared: 'changed'"
177 '/// Replace all ///'
178 Kontext "FindAndReplace"
182 if Not Messagebox.Exists (2) then
183 ' Warnlog " Not all words are replaced" ' there never was a mesagebox ! (compared to 5.2)
185 printlog messagebox.gettext
186 qaerrorlog "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
189 Kontext "FindAndReplace"
191 SearchNow.Click '/// Search for word 1 to check if all words are replaced ///'
193 if Not Messagebox.Exists then
194 Warnlog " Not all words are replaced (Replace All)"
196 printlog "Search key not found!: '" + messagebox.gettext + "'"
199 Kontext "FindAndReplace"
203 '/// Edit-Find & Replace II ///'
206 hTypeKeys "<MOD1 HOME>"
209 Kontext "FindAndReplace"
210 SearchFor.SetText sExpression(2) '/// Search for word 2 ///'
211 ReplaceWith.SetText sExpression(1) '/// Replace with word 1 ///'
213 Replace.Click '/// Replace 1 ///'
215 if Messagebox.Exists(4) Then
218 Printlog " Clicked 'OK' in the messagebox after searching and replacing the word(s)"
220 Printlog " Word replaced, no messagebox appeared afterwards"
222 Kontext "FindAndReplace"
225 SearchNow.Click '/// 2nd search for word 2 ///'
227 if Messagebox.Exists(2) Then
228 Warnlog " All words got replaced, but only the 1st should have been"
231 Kontext "FindAndReplace"
233 Printlog " Word replaced"
236 '/// Replace all ///'
237 Kontext "FindAndReplace"
240 if Messagebox.Exists(4) Then
243 Printlog "- No messagebox after replace all"
246 '/// Search for word 2 to check if all are replaced ///'
247 Kontext "FindAndReplace"
250 if Messagebox.Exists(2) Then
251 printlog "Search key not found!: " + messagebox.gettext +"'"
254 Warnlog "- Replace all does not work properly"
257 Kontext "FindAndReplace"
261 '/// Close document ///'
264 endcase 'tiEditSearchAndReplace
265 '--------------------------------------------------------
266 testcase tiEditSearchAndReplaceBUGS
268 '/// inspired by bugs: 101974, 101975, 101976 ///'
272 '/// open application ///'
275 '/// Edit->Search and Replace ///'
277 Kontext "FindAndReplace"
278 if FindAndReplace.Exists (5) then
279 Printlog "Dialog for Search&Replace could be opened :-)"
281 Warnlog "Dialog for Search&Replace could NOT be opened :-("
284 '/// for al 5 views in 'View->Workspace->...' do: ///'
286 Printlog "- " + i + " View->Workspace->... ------------------------------------------------------"
289 case 1:Printlog " Drawing"
290 ViewWorkspaceDrawingView
291 case 2:Printlog " Outline"
292 ViewWorkspaceOutlineView
293 case 3:Printlog " Slides"
294 ViewWorkspaceSlidesView
295 case 4:Printlog " Notes"
296 ViewWorkspaceNotesView
297 case 5:Printlog " Handout"
298 ' this is done this way, to regcognize BUGID:101975
299 ViewWorkspaceHandoutView
300 case 6:Printlog " Drawing"
301 ViewWorkspaceDrawingView
304 Warnlog "Couldn't excecute the last view ^^^^^^^^^ :-("
305 Printlog "Will close the search&replace dialog as a workaround and then try to switch to the view again"
306 Kontext "FindAndReplace"
311 case 1:ViewWorkspaceDrawingView
312 case 2:ViewWorkspaceOutlineView
313 case 3:ViewWorkspaceSlidesView
314 case 4:ViewWorkspaceNotesView
315 case 5:ViewWorkspaceHandoutView
318 Warnlog "Couldn't really switch the view :-("
322 Kontext "FindAndReplace"
323 '///+ if not already open, open. edit->search and replace ///'
324 if (FindAndReplace.exists <> TRUE) then
330 if (FindAndReplace.exists <> TRUE) then
334 Warnlog "Search and replace was not open, and could not be opened :-("
337 Kontext "FindAndReplace"
338 '///+ set text to look for to "a" ///'
339 SearchFor.SetText "a"
340 Printlog "'///+ click button 'find' ///'"
344 '///+ if active exists 'wrap/not found...' say OK ///'
345 if active.exists(5) then
346 Printlog "Active: '" + active.GetText + "'"
352 if active.exists(5) then
353 Printlog "Active: '" + active.GetText + "'"
358 ' this is done this way, to regcognize BUGID:101974
359 Warnlog "No message about 'search key not found' :-("
363 Kontext "FindAndReplace"
364 FindAndReplace.cancel
365 '/// close application ///'
368 endcase 'tiEditSearchAndReplaceBUGS