xref: /trunk/main/basic/inc/basic/testtool.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _BASIC_TESTTOOL_HXX_
28*cdf0e10cSrcweir #define _BASIC_TESTTOOL_HXX_
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <svl/smplhint.hxx>
31*cdf0e10cSrcweir #include <tools/string.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #define TESTTOOL_DEFAULT_PORT 12479
34*cdf0e10cSrcweir #define UNO_DEFAULT_PORT 12480
35*cdf0e10cSrcweir #define DEFAULT_HOST "localhost"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #define TT_SIGNATURE_FOR_UNICODE_TEXTFILES "'encoding UTF-8  Do not remove or change this line!"
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #define ASSERTION_STACK_PREFIX "Backtrace:"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir // #94145# Due to a tab in TT_SIGNATURE_FOR_UNICODE_TEXTFILES which is changed to blanks by some editors
42*cdf0e10cSrcweir // this routine became necessary
43*cdf0e10cSrcweir sal_Bool IsTTSignatureForUnicodeTextfile( String aLine );
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir //#include "testapp.hxx"
46*cdf0e10cSrcweir #define ADD_ERROR_QUIET(nNr, aStr)                                      \
47*cdf0e10cSrcweir {                                                                       \
48*cdf0e10cSrcweir     ErrorEntry *pErr;                                                   \
49*cdf0e10cSrcweir     if ( BasicRuntimeAccess::HasRuntime() )                             \
50*cdf0e10cSrcweir     {                                                                   \
51*cdf0e10cSrcweir         BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();           \
52*cdf0e10cSrcweir         xub_StrLen aErrLn = StarBASIC::GetErl();                        \
53*cdf0e10cSrcweir         if ( 0 == aErrLn )                                              \
54*cdf0e10cSrcweir             aErrLn = aRun.GetLine();                                    \
55*cdf0e10cSrcweir         pErr = new ErrorEntry(nNr, aStr,                                \
56*cdf0e10cSrcweir             aErrLn, aRun.GetCol1(), aRun.GetCol2());                    \
57*cdf0e10cSrcweir     }                                                                   \
58*cdf0e10cSrcweir     else                                                                \
59*cdf0e10cSrcweir     {                                                                   \
60*cdf0e10cSrcweir         pErr = new ErrorEntry(nNr, aStr);                               \
61*cdf0e10cSrcweir     }                                                                   \
62*cdf0e10cSrcweir     P_FEHLERLISTE->C40_INSERT(ErrorEntry, pErr, P_FEHLERLISTE->Count());\
63*cdf0e10cSrcweir }
64*cdf0e10cSrcweir // ??? Irgendwann noch was mit der UID anfangen !!
65*cdf0e10cSrcweir #define ADD_ERROR(nNr, aStr) { \
66*cdf0e10cSrcweir         if ( !SbxBase::IsError() )              \
67*cdf0e10cSrcweir             SbxBase::SetError( nNr );           \
68*cdf0e10cSrcweir         ADD_ERROR_QUIET(nNr, aStr); \
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir #define POP_ERROR() P_FEHLERLISTE->DeleteAndDestroy(0)
72*cdf0e10cSrcweir #define GET_ERROR() P_FEHLERLISTE->GetObject(0)
73*cdf0e10cSrcweir #define IS_ERROR() ( P_FEHLERLISTE->Count() > 0 )
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir // Transmission of error logs
76*cdf0e10cSrcweir enum TTLogType { LOG_RUN, LOG_TEST_CASE, LOG_ERROR, LOG_CALL_STACK, LOG_MESSAGE, LOG_WARNING, LOG_ASSERTION, LOG_QA_ERROR, LOG_ASSERTION_STACK };
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir struct TTDebugData
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir public:
81*cdf0e10cSrcweir     TTLogType aLogType;
82*cdf0e10cSrcweir     String aMsg;
83*cdf0e10cSrcweir     String aFilename;
84*cdf0e10cSrcweir     xub_StrLen nLine;
85*cdf0e10cSrcweir     xub_StrLen nCol1;
86*cdf0e10cSrcweir     xub_StrLen nCol2;
87*cdf0e10cSrcweir };
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir struct TTLogMsg
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir public:
92*cdf0e10cSrcweir     String aLogFileName;
93*cdf0e10cSrcweir     TTDebugData aDebugData;
94*cdf0e10cSrcweir };
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir // For transmission of window information from the Testapp
97*cdf0e10cSrcweir struct WinInfoRec
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir public:
100*cdf0e10cSrcweir     String aUId;
101*cdf0e10cSrcweir     String aKurzname;
102*cdf0e10cSrcweir     String aSlotname;
103*cdf0e10cSrcweir     String aLangname;
104*cdf0e10cSrcweir     sal_uInt16 nRType;
105*cdf0e10cSrcweir     String aRName;
106*cdf0e10cSrcweir     sal_Bool bIsReset;
107*cdf0e10cSrcweir };
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir // Defines for syntax Highlighting
110*cdf0e10cSrcweir #define TT_KEYWORD      ((SbTextType)100)   // Including locally executed commands like 'use' ...
111*cdf0e10cSrcweir #define TT_REMOTECMD    ((SbTextType)101)   // Remotely executed commands like 'nodebug'
112*cdf0e10cSrcweir #define TT_LOCALCMD     ((SbTextType)102)   // Locally executed commands like 'use'
113*cdf0e10cSrcweir #define TT_CONTROL      ((SbTextType)103)   // Possibly available control loaded by 'use'
114*cdf0e10cSrcweir #define TT_SLOT         ((SbTextType)104)   // Available Slots loaded by 'use'
115*cdf0e10cSrcweir #define TT_METHOD       ((SbTextType)105)   // Possibly allowed Method for controls
116*cdf0e10cSrcweir #define TT_NOMETHOD     ((SbTextType)106)   // No Possibly allowed Method for controls
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir #define FILELIST1       ((SbTextType)111)   // Symbols in file 1
119*cdf0e10cSrcweir #define FILELIST2       ((SbTextType)112)   // Symbols in file 2
120*cdf0e10cSrcweir #define FILELIST3       ((SbTextType)113)   // Symbols in file 3
121*cdf0e10cSrcweir #define FILELIST4       ((SbTextType)114)   // Symbols in file 4
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir /// defines for hints from TestToolObj to the Application
124*cdf0e10cSrcweir #define SBX_HINT_LANGUAGE_EXTENSION_LOADED      SFX_HINT_USER06
125*cdf0e10cSrcweir #define SBX_HINT_EXECUTION_STATUS_INFORMATION   SFX_HINT_USER07
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir #define TT_EXECUTION_ENTERWAIT  0x01
128*cdf0e10cSrcweir #define TT_EXECUTION_LEAVEWAIT  0x02
129*cdf0e10cSrcweir #define TT_EXECUTION_SHOW_ACTION    0x03
130*cdf0e10cSrcweir #define TT_EXECUTION_HIDE_ACTION    0x04
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir class TTExecutionStatusHint : public SfxSimpleHint
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir private:
135*cdf0e10cSrcweir     sal_uInt16 mnType;
136*cdf0e10cSrcweir     String maExecutionStatus;
137*cdf0e10cSrcweir     String maAdditionalExecutionStatus;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir public:
140*cdf0e10cSrcweir             TYPEINFO();
141*cdf0e10cSrcweir             TTExecutionStatusHint( sal_uInt16 nType, sal_Char *pExecutionStatus, const sal_Char *pAdditionalExecutionStatus = "" )
142*cdf0e10cSrcweir                 : SfxSimpleHint(SBX_HINT_EXECUTION_STATUS_INFORMATION)
143*cdf0e10cSrcweir                 , mnType( nType )
144*cdf0e10cSrcweir                 , maExecutionStatus( pExecutionStatus, RTL_TEXTENCODING_ASCII_US )
145*cdf0e10cSrcweir                 , maAdditionalExecutionStatus( pAdditionalExecutionStatus, RTL_TEXTENCODING_ASCII_US )
146*cdf0e10cSrcweir                 {;}
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir             TTExecutionStatusHint( sal_uInt16 nType, const String &aExecutionStatus = String(), const String &aAdditionalExecutionStatus = String() )
149*cdf0e10cSrcweir                 : SfxSimpleHint(SBX_HINT_EXECUTION_STATUS_INFORMATION)
150*cdf0e10cSrcweir                 , mnType( nType )
151*cdf0e10cSrcweir                 , maExecutionStatus( aExecutionStatus )
152*cdf0e10cSrcweir                 , maAdditionalExecutionStatus( aAdditionalExecutionStatus )
153*cdf0e10cSrcweir                 {;}
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     const String& GetExecutionStatus() const { return maExecutionStatus; }
156*cdf0e10cSrcweir     const String& GetAdditionalExecutionStatus() const { return maAdditionalExecutionStatus; }
157*cdf0e10cSrcweir     sal_uInt16 GetType(){ return mnType; }
158*cdf0e10cSrcweir };
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir #endif // _BASIC_TESTTOOL_HXX_
161