test_URIHelper.cxx (40df464e) test_URIHelper.cxx (2958961e)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 36 unchanged lines hidden (view full) ---

45#include "com/sun/star/uno/Reference.hxx"
46#include "com/sun/star/uno/RuntimeException.hpp"
47#include "com/sun/star/uno/Sequence.hxx"
48#include "com/sun/star/uno/XComponentContext.hpp"
49#include "com/sun/star/uri/XUriReference.hpp"
50#include "cppuhelper/bootstrap.hxx"
51#include "cppuhelper/implbase1.hxx"
52#include "cppuhelper/implbase2.hxx"
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 36 unchanged lines hidden (view full) ---

45#include "com/sun/star/uno/Reference.hxx"
46#include "com/sun/star/uno/RuntimeException.hpp"
47#include "com/sun/star/uno/Sequence.hxx"
48#include "com/sun/star/uno/XComponentContext.hpp"
49#include "com/sun/star/uri/XUriReference.hpp"
50#include "cppuhelper/bootstrap.hxx"
51#include "cppuhelper/implbase1.hxx"
52#include "cppuhelper/implbase2.hxx"
53#include "testshl/simpleheader.hxx"
54#include "osl/diagnose.h"
55#include "rtl/strbuf.hxx"
56#include "rtl/string.h"
57#include "rtl/string.hxx"
58#include "rtl/textenc.h"
59#include "rtl/ustring.h"
60#include "rtl/ustring.hxx"
61#include "sal/types.h"
62#include "tools/solar.h"
63#include "unotools/charclass.hxx"
53#include "osl/diagnose.h"
54#include "rtl/strbuf.hxx"
55#include "rtl/string.h"
56#include "rtl/string.hxx"
57#include "rtl/textenc.h"
58#include "rtl/ustring.h"
59#include "rtl/ustring.hxx"
60#include "sal/types.h"
61#include "tools/solar.h"
62#include "unotools/charclass.hxx"
63#include "gtest/gtest.h"
64
65#include "urihelper.hxx"
66
64
65#include "urihelper.hxx"
66
67// FIXME:
68#define RUN_OLD_FAILING_TESTS 0
69
67// This test needs a UNO component context that supports various services (the
68// UCB, an UriReferenceFactory, ...), so it is best executed within an OOo
69// installation.
70
71namespace com { namespace sun { namespace star { namespace ucb {
72 class XCommandEnvironment;
73 class XContentEventListener;
74} } } }

--- 124 unchanged lines hidden (view full) ---

199 throw (css::uno::RuntimeException)
200 {
201 OSL_ASSERT(id1.is() && id2.is());
202 return
203 id1->getContentIdentifier().compareTo(id2->getContentIdentifier());
204 }
205};
206
70// This test needs a UNO component context that supports various services (the
71// UCB, an UriReferenceFactory, ...), so it is best executed within an OOo
72// installation.
73
74namespace com { namespace sun { namespace star { namespace ucb {
75 class XCommandEnvironment;
76 class XContentEventListener;
77} } } }

--- 124 unchanged lines hidden (view full) ---

202 throw (css::uno::RuntimeException)
203 {
204 OSL_ASSERT(id1.is() && id2.is());
205 return
206 id1->getContentIdentifier().compareTo(id2->getContentIdentifier());
207 }
208};
209
207class Test: public CppUnit::TestFixture {
210class Test: public ::testing::Test {
208public:
211public:
209 virtual void setUp();
212 virtual void SetUp();
210
211 void finish();
212
213
214 void finish();
215
213 void testNormalizedMakeRelative();
214
215 void testFindFirstURLInText();
216
217 CPPUNIT_TEST_SUITE(Test);
218 CPPUNIT_TEST(testNormalizedMakeRelative);
219 CPPUNIT_TEST(testFindFirstURLInText);
220 CPPUNIT_TEST(finish);
221 CPPUNIT_TEST_SUITE_END();
222
223private:
216protected:
224 static css::uno::Reference< css::uno::XComponentContext > m_context;
225};
226
217 static css::uno::Reference< css::uno::XComponentContext > m_context;
218};
219
227void Test::setUp() {
220void Test::SetUp() {
228 // For whatever reason, on W32 it does not work to create/destroy a fresh
229 // component context for each test in Test::setUp/tearDown; therefore, a
230 // single component context is used for all tests and destroyed in the last
231 // pseudo-test "finish":
232 if (!m_context.is()) {
233 m_context = cppu::defaultBootstrap_InitialComponentContext();
234 }
235}
236
237void Test::finish() {
238 css::uno::Reference< css::lang::XComponent >(
239 m_context, css::uno::UNO_QUERY_THROW)->dispose();
240}
241
221 // For whatever reason, on W32 it does not work to create/destroy a fresh
222 // component context for each test in Test::setUp/tearDown; therefore, a
223 // single component context is used for all tests and destroyed in the last
224 // pseudo-test "finish":
225 if (!m_context.is()) {
226 m_context = cppu::defaultBootstrap_InitialComponentContext();
227 }
228}
229
230void Test::finish() {
231 css::uno::Reference< css::lang::XComponent >(
232 m_context, css::uno::UNO_QUERY_THROW)->dispose();
233}
234
242void Test::testNormalizedMakeRelative() {
235#if RUN_OLD_FAILING_TESTS
236
237TEST_F(Test, testNormalizedMakeRelative) {
243 css::uno::Sequence< css::uno::Any > args(2);
244 args[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
245 args[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
246 css::uno::Reference< css::ucb::XContentProviderManager >(
247 (css::uno::Reference< css::lang::XMultiComponentFactory >(
248 m_context->getServiceManager(), css::uno::UNO_QUERY_THROW)->
249 createInstanceWithArgumentsAndContext(
250 rtl::OUString(

--- 59 unchanged lines hidden (view full) ---

310 buf.append(RTL_CONSTASCII_STRINGPARAM("none"));
311 } else {
312 buf.append('<');
313 buf.append(tests[i].relative);
314 buf.append('>');
315 }
316 msg = buf.makeStringAndClear();
317 }
238 css::uno::Sequence< css::uno::Any > args(2);
239 args[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
240 args[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
241 css::uno::Reference< css::ucb::XContentProviderManager >(
242 (css::uno::Reference< css::lang::XMultiComponentFactory >(
243 m_context->getServiceManager(), css::uno::UNO_QUERY_THROW)->
244 createInstanceWithArgumentsAndContext(
245 rtl::OUString(

--- 59 unchanged lines hidden (view full) ---

305 buf.append(RTL_CONSTASCII_STRINGPARAM("none"));
306 } else {
307 buf.append('<');
308 buf.append(tests[i].relative);
309 buf.append('>');
310 }
311 msg = buf.makeStringAndClear();
312 }
318 CPPUNIT_ASSERT_MESSAGE(msg.getStr(), ok);
313 ASSERT_TRUE(ok) << msg.getStr();
319 }
320}
321
314 }
315}
316
322void Test::testFindFirstURLInText() {
317#endif
318
319TEST_F(Test, testFindFirstURLInText) {
323 struct Test {
324 char const * input;
325 char const * result;
326 xub_StrLen begin;
327 xub_StrLen end;
328 };
329 static Test const tests[] = {
330 { "...ftp://bla.bla.bla/blubber/...",

--- 106 unchanged lines hidden (view full) ---

437 buf.append(rtl::OUStringToOString(result, RTL_TEXTENCODING_UTF8));
438 buf.append(RTL_CONSTASCII_STRINGPARAM(" ("));
439 buf.append(static_cast< sal_Int32 >(begin));
440 buf.append(RTL_CONSTASCII_STRINGPARAM(", "));
441 buf.append(static_cast< sal_Int32 >(end));
442 buf.append(')');
443 msg = buf.makeStringAndClear();
444 }
320 struct Test {
321 char const * input;
322 char const * result;
323 xub_StrLen begin;
324 xub_StrLen end;
325 };
326 static Test const tests[] = {
327 { "...ftp://bla.bla.bla/blubber/...",

--- 106 unchanged lines hidden (view full) ---

434 buf.append(rtl::OUStringToOString(result, RTL_TEXTENCODING_UTF8));
435 buf.append(RTL_CONSTASCII_STRINGPARAM(" ("));
436 buf.append(static_cast< sal_Int32 >(begin));
437 buf.append(RTL_CONSTASCII_STRINGPARAM(", "));
438 buf.append(static_cast< sal_Int32 >(end));
439 buf.append(')');
440 msg = buf.makeStringAndClear();
441 }
445 CPPUNIT_ASSERT_MESSAGE(msg.getStr(), ok);
442 ASSERT_TRUE(ok) << msg.getStr();
446 }
447}
448
449css::uno::Reference< css::uno::XComponentContext > Test::m_context;
450
443 }
444}
445
446css::uno::Reference< css::uno::XComponentContext > Test::m_context;
447
451CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltests");
452
453}
454
448
449}
450
455NOADDITIONAL;
451int main(int argc, char **argv)
452{
453 ::testing::InitGoogleTest(&argc, argv);
454 return RUN_ALL_TESTS();
455}