update dev300-m58
[ooovba.git] / applied_patches / 0089-tools-qa-urlobj-unittest.diff
blobaf60c65e771043f02ed9c159fa354bcee0cc639a
1 diff -Ncr tools_orig/qa/urlobj/export.map tools/qa/urlobj/export.map
2 --- tools_orig/qa/urlobj/export.map 1970-01-01 01:00:00.000000000 +0100
3 +++ tools/qa/urlobj/export.map 2007-06-14 16:40:41.000000000 +0200
4 @@ -0,0 +1,7 @@
5 + UDK_3.0 {
6 + global:
7 + registerAllTestFunction;
8 +
9 + local:
10 + *;
11 + };
12 diff -Ncr tools_orig/qa/urlobj/makefile.mk tools/qa/urlobj/makefile.mk
13 --- tools_orig/qa/urlobj/makefile.mk 1970-01-01 01:00:00.000000000 +0100
14 +++ tools/qa/urlobj/makefile.mk 2007-06-14 16:50:28.000000000 +0200
15 @@ -0,0 +1,72 @@
16 + #*************************************************************************
17 + #
18 + # OpenOffice.org - a multi-platform office productivity suite
19 + #
20 + # $RCSfile: makefile.mk,v $
21 + #
22 + # $Revision: 1.3 $
23 + #
24 + # last change: $Author: rt $ $Date: 2005/09/08 15:49:44 $
25 + #
26 + # The Contents of this file are made available subject to
27 + # the terms of GNU Lesser General Public License Version 2.1.
28 + #
29 + #
30 + # GNU Lesser General Public License Version 2.1
31 + # =============================================
32 + # Copyright 2005 by Sun Microsystems, Inc.
33 + # 901 San Antonio Road, Palo Alto, CA 94303, USA
34 + #
35 + # This library is free software; you can redistribute it and/or
36 + # modify it under the terms of the GNU Lesser General Public
37 + # License version 2.1, as published by the Free Software Foundation.
38 + #
39 + # This library is distributed in the hope that it will be useful,
40 + # but WITHOUT ANY WARRANTY; without even the implied warranty of
41 + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
42 + # Lesser General Public License for more details.
43 + #
44 + # You should have received a copy of the GNU Lesser General Public
45 + # License along with this library; if not, write to the Free Software
46 + # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
47 + # MA 02111-1307 USA
48 + #
49 + #*************************************************************************
50 + PRJ=..$/..
52 + PRJNAME=tools
53 + TARGET=qa_tools_urlobj_test
54 + # this is removed at the moment because we need some enhancements
55 + # TESTDIR=TRUE
57 + ENABLE_EXCEPTIONS=TRUE
59 + # --- Settings -----------------------------------------------------
61 + .INCLUDE : settings.mk
63 + # BEGIN ----------------------------------------------------------------
64 + # auto generated Target:job by codegen.pl
65 + SHL1OBJS= \
66 + $(SLO)$/tools_urlobj_test.obj
68 + SHL1TARGET= tools_urlobj
69 + SHL1STDLIBS=\
70 + $(SALLIB) \
71 + $(CPPUNITLIB) \
72 + $(TOOLSLIB)
74 + SHL1IMPLIB= i$(SHL1TARGET)
75 + DEF1NAME =$(SHL1TARGET)
76 + SHL1VERSIONMAP= export.map
77 + # auto generated Target:job
78 + # END ------------------------------------------------------------------
80 + #------------------------------- All object files -------------------------------
81 + # do this here, so we get right dependencies
82 + # SLOFILES=$(SHL1OBJS)
84 + # --- Targets ------------------------------------------------------
86 + .INCLUDE : target.mk
87 + .INCLUDE : _cppunit.mk
88 diff -Ncr tools_orig/qa/urlobj/tools_urlobj_test.cxx tools/qa/urlobj/tools_urlobj_test.cxx
89 --- tools_orig/qa/urlobj/tools_urlobj_test.cxx 1970-01-01 01:00:00.000000000 +0100
90 +++ tools/qa/urlobj/tools_urlobj_test.cxx 2007-06-14 18:33:36.000000000 +0200
91 @@ -0,0 +1,191 @@
92 + /*************************************************************************
93 + *
94 + * OpenOffice.org - a multi-platform office productivity suite
95 + *
96 + * $RCSfile: $
97 + *
98 + * $Revision: $
99 + *
100 + * last change: $Author: $ $Date: $
102 + * The Contents of this file are made available subject to
103 + * the terms of GNU Lesser General Public License Version 2.1.
106 + * GNU Lesser General Public License Version 2.1
107 + * =============================================
108 + * Copyright 2005 by Sun Microsystems, Inc.
109 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
111 + * This library is free software; you can redistribute it and/or
112 + * modify it under the terms of the GNU Lesser General Public
113 + * License version 2.1, as published by the Free Software Foundation.
115 + * This library is distributed in the hope that it will be useful,
116 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
117 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
118 + * Lesser General Public License for more details.
120 + * You should have received a copy of the GNU Lesser General Public
121 + * License along with this library; if not, write to the Free Software
122 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
123 + * MA 02111-1307 USA
125 + ************************************************************************/
127 + #include <cppunit/simpleheader.hxx>
129 + #include <urlobj.hxx>
131 + namespace tools_urlobj
134 + class urlobjTest : public CppUnit::TestFixture
137 + public:
138 + // initialise your test code values here.
139 + void setUp()
143 + void tearDown()
147 + // insert your test code here.
148 + // this is only demonstration code
149 + void urlobjTest_001()
151 + INetURLObject aUrl(rtl::OUString::createFromAscii("file://10.10.1.1/sampledir/sample.file"));
152 + #ifdef LINUX
153 + CPPUNIT_ASSERT(aUrl.GetMainURL(INetURLObject::NO_DECODE).compareToAscii("smb://10.10.1.1/sampledir/sample.file")==0);
154 + CPPUNIT_ASSERT(aUrl.GetProtocol()==INET_PROT_SMB);
155 + #endif
156 + #ifdef WIN
157 + CPPUNIT_ASSERT(aUrl.GetMainURL(INetURLObject::NO_DECODE).compareToAscii("file://10.10.1.1/sampledir/sample.file")==0);
158 + CPPUNIT_ASSERT(aUrl.GetProtocol()==INET_PROT_FILE);
159 + #endif
160 + CPPUNIT_ASSERT(aUrl.GetHost(INetURLObject::NO_DECODE).compareToAscii("10.10.1.1")==0);
161 + CPPUNIT_ASSERT(aUrl.GetURLPath(INetURLObject::NO_DECODE).compareToAscii("/sampledir/sample.file")==0);
162 + CPPUNIT_ASSERT(aUrl.getName().compareToAscii("sample.file")==0);
163 + CPPUNIT_ASSERT(aUrl.getBase().compareToAscii("sample")==0);
164 + CPPUNIT_ASSERT(aUrl.getExtension().compareToAscii("file")==0);
167 + void urlobjTest_002()
169 + INetURLObject aUrl;
170 + aUrl.setFSysPath(rtl::OUString::createFromAscii("\\\\137.65.170.24\\c$\\Img0001.jpg"), INetURLObject::FSYS_DETECT);
171 + #ifdef LINUX
172 + CPPUNIT_ASSERT(aUrl.GetMainURL(INetURLObject::NO_DECODE).compareToAscii("smb://137.65.170.24/c$/Img0001.jpg")==0);
173 + CPPUNIT_ASSERT(aUrl.GetProtocol()==INET_PROT_SMB);
174 + #endif
175 + #ifdef WIN
176 + CPPUNIT_ASSERT(aUrl.GetMainURL(INetURLObject::NO_DECODE).compareToAscii("file://137.65.170.24/c$/Img0001.jpg")==0);
177 + CPPUNIT_ASSERT(aUrl.GetProtocol()==INET_PROT_FILE);
178 + #endif
179 + CPPUNIT_ASSERT(aUrl.GetHost(INetURLObject::NO_DECODE).compareToAscii("137.65.170.24")==0);
180 + CPPUNIT_ASSERT(aUrl.GetURLPath(INetURLObject::NO_DECODE).compareToAscii("/c$/Img0001.jpg")==0);
181 + CPPUNIT_ASSERT(aUrl.getName().compareToAscii("Img0001.jpg")==0);
182 + CPPUNIT_ASSERT(aUrl.getBase().compareToAscii("Img0001")==0);
183 + CPPUNIT_ASSERT(aUrl.getExtension().compareToAscii("jpg")==0);
187 + void urlobjTest_003()
189 + INetURLObject aUrl;
190 + aUrl.setFSysPath(rtl::OUString::createFromAscii("\\\\hive-winxp-x86\\pmladek\\test2.odt"), INetURLObject::FSYS_DETECT);
191 + #ifdef LINUX
192 + CPPUNIT_ASSERT(aUrl.GetMainURL(INetURLObject::NO_DECODE).compareToAscii("smb://hive-winxp-x86/pmladek/test2.odt")==0);
193 + CPPUNIT_ASSERT(aUrl.GetProtocol()==INET_PROT_SMB);
194 + #endif
195 + #ifdef WIN
196 + CPPUNIT_ASSERT(aUrl.GetMainURL(INetURLObject::NO_DECODE).compareToAscii("file://hive-winxp-x86/pmladek/test2.odt")==0);
197 + CPPUNIT_ASSERT(aUrl.GetProtocol()==INET_PROT_FILE);
198 + #endif
199 + CPPUNIT_ASSERT(aUrl.GetHost(INetURLObject::NO_DECODE).compareToAscii("hive-winxp-x86")==0);
200 + CPPUNIT_ASSERT(aUrl.GetURLPath(INetURLObject::NO_DECODE).compareToAscii("/pmladek/test2.odt")==0);
203 + void urlobjTest_004()
205 + INetURLObject aUrl(rtl::OUString::createFromAscii("smb://10.10.1.1/sampledir/sample.file"));
206 + #ifdef LINUX
207 + CPPUNIT_ASSERT(aUrl.GetMainURL(INetURLObject::NO_DECODE).compareToAscii("smb://10.10.1.1/sampledir/sample.file")==0);
208 + CPPUNIT_ASSERT(aUrl.GetProtocol()==INET_PROT_SMB);
209 + #endif
210 + #ifdef WIN
211 + CPPUNIT_ASSERT(aUrl.GetMainURL(INetURLObject::NO_DECODE).compareToAscii("file://10.10.1.1/sampledir/sample.file")==0);
212 + CPPUNIT_ASSERT(aUrl.GetProtocol()==INET_PROT_FILE);
213 + #endif
214 + CPPUNIT_ASSERT(aUrl.GetHost(INetURLObject::NO_DECODE).compareToAscii("10.10.1.1")==0);
215 + CPPUNIT_ASSERT(aUrl.GetURLPath(INetURLObject::NO_DECODE).compareToAscii("/sampledir/sample.file")==0);
216 + CPPUNIT_ASSERT(aUrl.getName().compareToAscii("sample.file")==0);
217 + CPPUNIT_ASSERT(aUrl.getBase().compareToAscii("sample")==0);
218 + CPPUNIT_ASSERT(aUrl.getExtension().compareToAscii("file")==0);
221 + void urlobjTest_005()
223 + INetURLObject aUrl;
224 + aUrl.setFSysPath(rtl::OUString::createFromAscii("//137.65.170.24/c$/Img0001.jpg"), INetURLObject::FSYS_DETECT);
225 + #ifdef LINUX
226 + CPPUNIT_ASSERT(aUrl.GetMainURL(INetURLObject::NO_DECODE).compareToAscii("smb://137.65.170.24/c$/Img0001.jpg")==0);
227 + CPPUNIT_ASSERT(aUrl.GetProtocol()==INET_PROT_SMB);
228 + #endif
229 + #ifdef WIN
230 + CPPUNIT_ASSERT(aUrl.GetMainURL(INetURLObject::NO_DECODE).compareToAscii("file://137.65.170.24/c$/Img0001.jpg")==0);
231 + CPPUNIT_ASSERT(aUrl.GetProtocol()==INET_PROT_FILE);
232 + #endif
233 + CPPUNIT_ASSERT(aUrl.GetHost(INetURLObject::NO_DECODE).compareToAscii("137.65.170.24")==0);
234 + CPPUNIT_ASSERT(aUrl.GetURLPath(INetURLObject::NO_DECODE).compareToAscii("/c$/Img0001.jpg")==0);
235 + CPPUNIT_ASSERT(aUrl.getName().compareToAscii("Img0001.jpg")==0);
236 + CPPUNIT_ASSERT(aUrl.getBase().compareToAscii("Img0001")==0);
237 + CPPUNIT_ASSERT(aUrl.getExtension().compareToAscii("jpg")==0);
241 + void urlobjTest_006()
243 + INetURLObject aUrl;
244 + aUrl.setFSysPath(rtl::OUString::createFromAscii("//hive-winxp-x86/pmladek/test2.odt"), INetURLObject::FSYS_DETECT);
245 + #ifdef LINUX
246 + CPPUNIT_ASSERT(aUrl.GetMainURL(INetURLObject::NO_DECODE).compareToAscii("smb://hive-winxp-x86/pmladek/test2.odt")==0);
247 + CPPUNIT_ASSERT(aUrl.GetProtocol()==INET_PROT_SMB);
248 + #endif
249 + #ifdef WIN
250 + CPPUNIT_ASSERT(aUrl.GetMainURL(INetURLObject::NO_DECODE).compareToAscii("file://hive-winxp-x86/pmladek/test2.odt")==0);
251 + CPPUNIT_ASSERT(aUrl.GetProtocol()==INET_PROT_FILE);
252 + #endif
253 + CPPUNIT_ASSERT(aUrl.GetHost(INetURLObject::NO_DECODE).compareToAscii("hive-winxp-x86")==0);
254 + CPPUNIT_ASSERT(aUrl.GetURLPath(INetURLObject::NO_DECODE).compareToAscii("/pmladek/test2.odt")==0);
259 + // Change the following lines only, if you add, remove or rename
260 + // member functions of the current class,
261 + // because these macros are need by auto register mechanism.
263 + CPPUNIT_TEST_SUITE(urlobjTest);
264 + CPPUNIT_TEST(urlobjTest_001);
265 + CPPUNIT_TEST(urlobjTest_002);
266 + CPPUNIT_TEST(urlobjTest_003);
267 + CPPUNIT_TEST(urlobjTest_004);
268 + CPPUNIT_TEST(urlobjTest_005);
269 + CPPUNIT_TEST(urlobjTest_006);
270 + CPPUNIT_TEST_SUITE_END();
271 + }; // class createPool
274 + CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(tools_urlobj::urlobjTest, "tools_urlobj");
275 + } // namespace rtl_random
278 + // -----------------------------------------------------------------------------
280 + // this macro creates an empty function, which will called by the RegisterAllFunctions()
281 + // to let the user the possibility to also register some functions by hand.
282 + NOADDITIONAL;