test.cxx (3a7cf181) test.cxx (7231f715)
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

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

20 *************************************************************/
21
22
23
24#include "precompiled_configmgr.hxx"
25#include "sal/config.h"
26
27#include <cstddef>
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

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

20 *************************************************************/
21
22
23
24#include "precompiled_configmgr.hxx"
25#include "sal/config.h"
26
27#include <cstddef>
28#include <cstdlib>
28
29#include "com/sun/star/beans/NamedValue.hpp"
30#include "com/sun/star/beans/PropertyChangeEvent.hpp"
31#include "com/sun/star/beans/XPropertyChangeListener.hpp"
32#include "com/sun/star/beans/XPropertySet.hpp"
33#include "com/sun/star/beans/XPropertyState.hpp"
34#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
35#include "com/sun/star/container/XNameReplace.hpp"

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

42#include "com/sun/star/uno/RuntimeException.hpp"
43#include "com/sun/star/uno/Sequence.hxx"
44#include "com/sun/star/uno/XComponentContext.hpp"
45#include "com/sun/star/uno/XInterface.hpp"
46#include "com/sun/star/util/XChangesBatch.hpp"
47#include "cppuhelper/implbase1.hxx"
48#include "cppuhelper/servicefactory.hxx"
49#include "osl/conditn.hxx"
29
30#include "com/sun/star/beans/NamedValue.hpp"
31#include "com/sun/star/beans/PropertyChangeEvent.hpp"
32#include "com/sun/star/beans/XPropertyChangeListener.hpp"
33#include "com/sun/star/beans/XPropertySet.hpp"
34#include "com/sun/star/beans/XPropertyState.hpp"
35#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
36#include "com/sun/star/container/XNameReplace.hpp"

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

43#include "com/sun/star/uno/RuntimeException.hpp"
44#include "com/sun/star/uno/Sequence.hxx"
45#include "com/sun/star/uno/XComponentContext.hpp"
46#include "com/sun/star/uno/XInterface.hpp"
47#include "com/sun/star/util/XChangesBatch.hpp"
48#include "cppuhelper/implbase1.hxx"
49#include "cppuhelper/servicefactory.hxx"
50#include "osl/conditn.hxx"
51#include "osl/process.h"
50#include "osl/thread.h"
51#include "osl/thread.hxx"
52#include "osl/time.h"
53#include "rtl/ref.hxx"
54#include "rtl/string.h"
55#include "rtl/textcvt.h"
56#include "rtl/ustrbuf.hxx"
57#include "rtl/ustring.h"
58#include "rtl/ustring.hxx"
59#include "sal/types.h"
52#include "osl/thread.h"
53#include "osl/thread.hxx"
54#include "osl/time.h"
55#include "rtl/ref.hxx"
56#include "rtl/string.h"
57#include "rtl/textcvt.h"
58#include "rtl/ustrbuf.hxx"
59#include "rtl/ustring.h"
60#include "rtl/ustring.hxx"
61#include "sal/types.h"
60#include "testshl/simpleheader.hxx"
62#include "gtest/gtest.h"
61
62namespace {
63
64namespace css = com::sun::star;
65
66void normalize(
67 rtl::OUString const & path, rtl::OUString const & relative,
68 rtl::OUString * normalizedPath, rtl::OUString * name)

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

75 rtl::OUStringBuffer buf(path);
76 buf.append(sal_Unicode('/'));
77 buf.append(relative.copy(0, i));
78 *normalizedPath = buf.makeStringAndClear();
79 *name = relative.copy(i + 1);
80 }
81}
82
63
64namespace {
65
66namespace css = com::sun::star;
67
68void normalize(
69 rtl::OUString const & path, rtl::OUString const & relative,
70 rtl::OUString * normalizedPath, rtl::OUString * name)

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

77 rtl::OUStringBuffer buf(path);
78 buf.append(sal_Unicode('/'));
79 buf.append(relative.copy(0, i));
80 *normalizedPath = buf.makeStringAndClear();
81 *name = relative.copy(i + 1);
82 }
83}
84
83class Test: public CppUnit::TestFixture {
85class Test: public ::testing::Test {
84public:
86public:
85 virtual void setUp();
87 virtual void SetUp();
86
88
87 virtual void tearDown();
89 virtual void TearDown();
88
90
89 void testKeyFetch();
90
91 void testKeySet();
92
93 void testKeyReset();
94
95 void testSetSetMemberName();
96
97 void testReadCommands();
98
99 void testThreads();
100
101 void testRecursive();
102
103 void testCrossThreads();
104
105 css::uno::Any getKey(
106 rtl::OUString const & path, rtl::OUString const & relative) const;
107
108 void setKey(
109 rtl::OUString const & path, rtl::OUString const & name,
110 css::uno::Any const & value) const;
111
112 bool resetKey(rtl::OUString const & path, rtl::OUString const & name) const;
113
114 css::uno::Reference< css::uno::XInterface > createViewAccess(
115 rtl::OUString const & path) const;
116
117 css::uno::Reference< css::uno::XInterface > createUpdateAccess(
118 rtl::OUString const & path) const;
119
91 css::uno::Any getKey(
92 rtl::OUString const & path, rtl::OUString const & relative) const;
93
94 void setKey(
95 rtl::OUString const & path, rtl::OUString const & name,
96 css::uno::Any const & value) const;
97
98 bool resetKey(rtl::OUString const & path, rtl::OUString const & name) const;
99
100 css::uno::Reference< css::uno::XInterface > createViewAccess(
101 rtl::OUString const & path) const;
102
103 css::uno::Reference< css::uno::XInterface > createUpdateAccess(
104 rtl::OUString const & path) const;
105
120 CPPUNIT_TEST_SUITE(Test);
121 CPPUNIT_TEST(testKeyFetch);
122 CPPUNIT_TEST(testKeySet);
123 CPPUNIT_TEST(testKeyReset);
124 CPPUNIT_TEST(testSetSetMemberName);
125 CPPUNIT_TEST(testReadCommands);
126 CPPUNIT_TEST(testThreads);
127 CPPUNIT_TEST(testRecursive);
128 CPPUNIT_TEST(testCrossThreads);
129 CPPUNIT_TEST_SUITE_END();
130
131private:
132 css::uno::Reference< css::uno::XComponentContext > context_;
133 css::uno::Reference< css::lang::XMultiServiceFactory > provider_;
134};
135
136class TestThread: public osl::Thread {
137public:
138 TestThread(osl::Condition & stop);

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

270 rtl::OUString(
271 RTL_CONSTASCII_USTRINGPARAM(
272 "/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
273 "dotuno:WebHtml"))),
274 css::uno::UNO_QUERY_THROW);
275 properties_->addPropertyChangeListener(
276 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")), this);
277 step();
106private:
107 css::uno::Reference< css::uno::XComponentContext > context_;
108 css::uno::Reference< css::lang::XMultiServiceFactory > provider_;
109};
110
111class TestThread: public osl::Thread {
112public:
113 TestThread(osl::Condition & stop);

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

245 rtl::OUString(
246 RTL_CONSTASCII_USTRINGPARAM(
247 "/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
248 "dotuno:WebHtml"))),
249 css::uno::UNO_QUERY_THROW);
250 properties_->addPropertyChangeListener(
251 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")), this);
252 step();
278 CPPUNIT_ASSERT(count_ == 0);
253 ASSERT_TRUE(count_ == 0);
279 css::uno::Reference< css::lang::XComponent >(
280 properties_, css::uno::UNO_QUERY_THROW)->dispose();
281}
282
283RecursiveTest::~RecursiveTest() {
284 *destroyed_ = true;
285}
286
287void RecursiveTest::disposing(css::lang::EventObject const & Source)
288 throw (css::uno::RuntimeException)
289{
254 css::uno::Reference< css::lang::XComponent >(
255 properties_, css::uno::UNO_QUERY_THROW)->dispose();
256}
257
258RecursiveTest::~RecursiveTest() {
259 *destroyed_ = true;
260}
261
262void RecursiveTest::disposing(css::lang::EventObject const & Source)
263 throw (css::uno::RuntimeException)
264{
290 CPPUNIT_ASSERT(properties_.is() && Source.Source == properties_);
265 ASSERT_TRUE(properties_.is() && Source.Source == properties_);
291 properties_.clear();
292}
293
294void RecursiveTest::propertyChange(css::beans::PropertyChangeEvent const & evt)
295 throw (css::uno::RuntimeException)
296{
266 properties_.clear();
267}
268
269void RecursiveTest::propertyChange(css::beans::PropertyChangeEvent const & evt)
270 throw (css::uno::RuntimeException)
271{
297 CPPUNIT_ASSERT(
272 ASSERT_TRUE(
298 evt.Source == properties_ &&
299 evt.PropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Label")));
300 if (count_ > 0) {
301 --count_;
302 step();
303 }
304}
305

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

352 test_.resetKey(
353 rtl::OUString(
354 RTL_CONSTASCII_USTRINGPARAM(
355 "/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
356 "dotuno:WebHtml")),
357 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")));
358}
359
273 evt.Source == properties_ &&
274 evt.PropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Label")));
275 if (count_ > 0) {
276 --count_;
277 step();
278 }
279}
280

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

327 test_.resetKey(
328 rtl::OUString(
329 RTL_CONSTASCII_USTRINGPARAM(
330 "/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
331 "dotuno:WebHtml")),
332 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")));
333}
334
360void Test::setUp() {
361 char const * forward = getForwardString();
335void Test::SetUp() {
336 char const * forward = getenv("CONFIGMGR_UNIT_FORWARD_STRING");
362 rtl_uString * registry = 0;
337 rtl_uString * registry = 0;
363 CPPUNIT_ASSERT(
338 ASSERT_TRUE(
364 rtl_convertStringToUString(
365 &registry, forward, rtl_str_getLength(forward),
366 osl_getThreadTextEncoding(),
367 (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
368 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
369 RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)));
370 context_ = css::uno::Reference< css::uno::XComponentContext >(
371 css::uno::Reference< css::beans::XPropertySet >(
372 cppu::createRegistryServiceFactory(
373 rtl::OUString(registry, SAL_NO_ACQUIRE)),
374 css::uno::UNO_QUERY_THROW)->getPropertyValue(
375 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))),
376 css::uno::UNO_QUERY_THROW);
339 rtl_convertStringToUString(
340 &registry, forward, rtl_str_getLength(forward),
341 osl_getThreadTextEncoding(),
342 (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
343 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
344 RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)));
345 context_ = css::uno::Reference< css::uno::XComponentContext >(
346 css::uno::Reference< css::beans::XPropertySet >(
347 cppu::createRegistryServiceFactory(
348 rtl::OUString(registry, SAL_NO_ACQUIRE)),
349 css::uno::UNO_QUERY_THROW)->getPropertyValue(
350 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))),
351 css::uno::UNO_QUERY_THROW);
377 CPPUNIT_ASSERT(
352 ASSERT_TRUE(
378 context_->getValueByName(
379 rtl::OUString(
380 RTL_CONSTASCII_USTRINGPARAM(
381 "/singletons/"
382 "com.sun.star.configuration.theDefaultProvider"))) >>=
383 provider_);
384}
385
353 context_->getValueByName(
354 rtl::OUString(
355 RTL_CONSTASCII_USTRINGPARAM(
356 "/singletons/"
357 "com.sun.star.configuration.theDefaultProvider"))) >>=
358 provider_);
359}
360
386void Test::tearDown() {
361void Test::TearDown() {
387 css::uno::Reference< css::lang::XComponent >(
388 context_, css::uno::UNO_QUERY_THROW)->dispose();
389}
390
362 css::uno::Reference< css::lang::XComponent >(
363 context_, css::uno::UNO_QUERY_THROW)->dispose();
364}
365
391void Test::testKeyFetch() {
366TEST_F(Test, testKeyFetch) {
392 rtl::OUString s;
367 rtl::OUString s;
393 CPPUNIT_ASSERT(
368 ASSERT_TRUE(
394 getKey(
395 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
396 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("L10N/ooLocale"))) >>=
397 s);
369 getKey(
370 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
371 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("L10N/ooLocale"))) >>=
372 s);
398 CPPUNIT_ASSERT(
373 ASSERT_TRUE(
399 getKey(
400 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
401 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/AString"))) >>=
402 s);
403}
404
374 getKey(
375 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
376 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/AString"))) >>=
377 s);
378}
379
405void Test::testKeySet() {
380TEST_F(Test, testKeySet) {
406 setKey(
407 rtl::OUString(
408 RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
409 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString")),
410 css::uno::makeAny(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("baa"))));
411 rtl::OUString s;
381 setKey(
382 rtl::OUString(
383 RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
384 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString")),
385 css::uno::makeAny(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("baa"))));
386 rtl::OUString s;
412 CPPUNIT_ASSERT(
387 ASSERT_TRUE(
413 getKey(
414 rtl::OUString(
415 RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
416 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString"))) >>=
417 s);
388 getKey(
389 rtl::OUString(
390 RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
391 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString"))) >>=
392 s);
418 CPPUNIT_ASSERT(s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("baa")));
393 ASSERT_TRUE(s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("baa")));
419}
420
394}
395
421void Test::testKeyReset() {
396TEST_F(Test, testKeyReset) {
422 if (resetKey(
423 rtl::OUString(
424 RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
425 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString"))))
426 {
427 rtl::OUString s;
397 if (resetKey(
398 rtl::OUString(
399 RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
400 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString"))))
401 {
402 rtl::OUString s;
428 CPPUNIT_ASSERT(
403 ASSERT_TRUE(
429 getKey(
430 rtl::OUString(
431 RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
432 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString"))) >>=
433 s);
404 getKey(
405 rtl::OUString(
406 RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
407 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString"))) >>=
408 s);
434 CPPUNIT_ASSERT(s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Foo")));
409 ASSERT_TRUE(s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Foo")));
435 }
436}
437
410 }
411}
412
438void Test::testSetSetMemberName() {
413TEST_F(Test, testSetSetMemberName) {
439 rtl::OUString s;
414 rtl::OUString s;
440 CPPUNIT_ASSERT(
415 ASSERT_TRUE(
441 getKey(
442 rtl::OUString(
443 RTL_CONSTASCII_USTRINGPARAM(
444 "/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
445 ".uno:FontworkShapeType")),
446 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label"))) >>=
447 s);
416 getKey(
417 rtl::OUString(
418 RTL_CONSTASCII_USTRINGPARAM(
419 "/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
420 ".uno:FontworkShapeType")),
421 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label"))) >>=
422 s);
448 CPPUNIT_ASSERT(
423 ASSERT_TRUE(
449 s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Fontwork Shape")));
450
451 css::uno::Reference< css::container::XNameAccess > access(
452 createUpdateAccess(
453 rtl::OUString(
454 RTL_CONSTASCII_USTRINGPARAM(
455 "/org.openoffice.UI.GenericCommands/UserInterface/"
456 "Commands"))),
457 css::uno::UNO_QUERY_THROW);
458 css::uno::Reference< css::container::XNamed > member;
459 access->getByName(
460 rtl::OUString(
461 RTL_CONSTASCII_USTRINGPARAM(".uno:FontworkGalleryFloater"))) >>=
462 member;
424 s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Fontwork Shape")));
425
426 css::uno::Reference< css::container::XNameAccess > access(
427 createUpdateAccess(
428 rtl::OUString(
429 RTL_CONSTASCII_USTRINGPARAM(
430 "/org.openoffice.UI.GenericCommands/UserInterface/"
431 "Commands"))),
432 css::uno::UNO_QUERY_THROW);
433 css::uno::Reference< css::container::XNamed > member;
434 access->getByName(
435 rtl::OUString(
436 RTL_CONSTASCII_USTRINGPARAM(".uno:FontworkGalleryFloater"))) >>=
437 member;
463 CPPUNIT_ASSERT(member.is());
438 ASSERT_TRUE(member.is());
464 member->setName(
465 rtl::OUString(
466 RTL_CONSTASCII_USTRINGPARAM(".uno:FontworkShapeType")));
467 css::uno::Reference< css::util::XChangesBatch >(
468 access, css::uno::UNO_QUERY_THROW)->commitChanges();
469 css::uno::Reference< css::lang::XComponent >(
470 access, css::uno::UNO_QUERY_THROW)->dispose();
471
439 member->setName(
440 rtl::OUString(
441 RTL_CONSTASCII_USTRINGPARAM(".uno:FontworkShapeType")));
442 css::uno::Reference< css::util::XChangesBatch >(
443 access, css::uno::UNO_QUERY_THROW)->commitChanges();
444 css::uno::Reference< css::lang::XComponent >(
445 access, css::uno::UNO_QUERY_THROW)->dispose();
446
472 CPPUNIT_ASSERT(
447 ASSERT_TRUE(
473 getKey(
474 rtl::OUString(
475 RTL_CONSTASCII_USTRINGPARAM(
476 "/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
477 ".uno:FontworkShapeType")),
478 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label"))) >>=
479 s);
448 getKey(
449 rtl::OUString(
450 RTL_CONSTASCII_USTRINGPARAM(
451 "/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
452 ".uno:FontworkShapeType")),
453 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label"))) >>=
454 s);
480 CPPUNIT_ASSERT(
455 ASSERT_TRUE(
481 s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Fontwork Gallery")));
482}
483
456 s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Fontwork Gallery")));
457}
458
484void Test::testReadCommands() {
459TEST_F(Test, testReadCommands) {
485 css::uno::Reference< css::container::XNameAccess > access(
486 createViewAccess(
487 rtl::OUString(
488 RTL_CONSTASCII_USTRINGPARAM(
489 "/org.openoffice.UI.GenericCommands/UserInterface/"
490 "Commands"))),
491 css::uno::UNO_QUERY_THROW);
492 css::uno::Sequence< rtl::OUString > names(access->getElementNames());
460 css::uno::Reference< css::container::XNameAccess > access(
461 createViewAccess(
462 rtl::OUString(
463 RTL_CONSTASCII_USTRINGPARAM(
464 "/org.openoffice.UI.GenericCommands/UserInterface/"
465 "Commands"))),
466 css::uno::UNO_QUERY_THROW);
467 css::uno::Sequence< rtl::OUString > names(access->getElementNames());
493 CPPUNIT_ASSERT(names.getLength() == 695);
468 ASSERT_TRUE(names.getLength() == 695);
494 // testSetSetMemberName() already removed ".uno:FontworkGalleryFloater"
495 sal_uInt32 n = osl_getGlobalTimer();
496 for (int i = 0; i < 8; ++i) {
497 for (sal_Int32 j = 0; j < names.getLength(); ++j) {
498 css::uno::Reference< css::container::XNameAccess > child;
499 if (access->getByName(names[j]) >>= child) {
469 // testSetSetMemberName() already removed ".uno:FontworkGalleryFloater"
470 sal_uInt32 n = osl_getGlobalTimer();
471 for (int i = 0; i < 8; ++i) {
472 for (sal_Int32 j = 0; j < names.getLength(); ++j) {
473 css::uno::Reference< css::container::XNameAccess > child;
474 if (access->getByName(names[j]) >>= child) {
500 CPPUNIT_ASSERT(child.is());
475 ASSERT_TRUE(child.is());
501 child->getByName(
502 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")));
503 child->getByName(
504 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ContextLabel")));
505 child->getByName(
506 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Properties")));
507 }
508 }
509 }
510 n = osl_getGlobalTimer() - n;
476 child->getByName(
477 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")));
478 child->getByName(
479 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ContextLabel")));
480 child->getByName(
481 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Properties")));
482 }
483 }
484 }
485 n = osl_getGlobalTimer() - n;
511 t_print("Reading elements took %" SAL_PRIuUINT32 " ms\n", n);
486 printf("Reading elements took %" SAL_PRIuUINT32 " ms\n", n);
512 css::uno::Reference< css::lang::XComponent >(
513 access, css::uno::UNO_QUERY_THROW)->dispose();
514}
515
487 css::uno::Reference< css::lang::XComponent >(
488 access, css::uno::UNO_QUERY_THROW)->dispose();
489}
490
516void Test::testThreads() {
491TEST_F(Test, testThreads) {
517 struct Entry { rtl::OUString path; rtl::OUString relative; };
518 Entry list[] = {
519 { rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
520 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/AString")) },
521 { rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
522 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/AString")) },
523 { rtl::OUString(
524 RTL_CONSTASCII_USTRINGPARAM(

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

544 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/ABoolean")) }
545 };
546 std::size_t const numReaders = sizeof list / sizeof (Entry);
547 std::size_t const numWriters = numReaders - 2;
548 ReaderThread * readers[numReaders];
549 WriterThread * writers[numWriters];
550 osl::Condition stop;
551 for (std::size_t i = 0; i < numReaders; ++i) {
492 struct Entry { rtl::OUString path; rtl::OUString relative; };
493 Entry list[] = {
494 { rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
495 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/AString")) },
496 { rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
497 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/AString")) },
498 { rtl::OUString(
499 RTL_CONSTASCII_USTRINGPARAM(

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

519 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/ABoolean")) }
520 };
521 std::size_t const numReaders = sizeof list / sizeof (Entry);
522 std::size_t const numWriters = numReaders - 2;
523 ReaderThread * readers[numReaders];
524 WriterThread * writers[numWriters];
525 osl::Condition stop;
526 for (std::size_t i = 0; i < numReaders; ++i) {
552 CPPUNIT_ASSERT(getKey(list[i].path, list[i].relative).hasValue());
527 ASSERT_TRUE(getKey(list[i].path, list[i].relative).hasValue());
553 readers[i] = new ReaderThread(
554 stop, *this, list[i].path, list[i].relative);
555 }
556 for (std::size_t i = 0; i < numWriters; ++i) {
557 writers[i] = new WriterThread(
558 stop, *this, list[i].path, list[i].relative);
559 }
560 for (int i = 0; i < 5; ++i) {

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

573 success = success && readers[i]->getSuccess();
574 delete readers[i];
575 }
576 for (std::size_t i = 0; i < numWriters; ++i) {
577 writers[i]->join();
578 success = success && writers[i]->getSuccess();
579 delete writers[i];
580 }
528 readers[i] = new ReaderThread(
529 stop, *this, list[i].path, list[i].relative);
530 }
531 for (std::size_t i = 0; i < numWriters; ++i) {
532 writers[i] = new WriterThread(
533 stop, *this, list[i].path, list[i].relative);
534 }
535 for (int i = 0; i < 5; ++i) {

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

548 success = success && readers[i]->getSuccess();
549 delete readers[i];
550 }
551 for (std::size_t i = 0; i < numWriters; ++i) {
552 writers[i]->join();
553 success = success && writers[i]->getSuccess();
554 delete writers[i];
555 }
581 CPPUNIT_ASSERT(success);
556 ASSERT_TRUE(success);
582}
583
557}
558
584void Test::testRecursive() {
559TEST_F(Test, testRecursive) {
585 bool destroyed = false;
586 rtl::Reference< RecursiveTest >(
587 new SimpleRecursiveTest(*this, 100, &destroyed))->test();
560 bool destroyed = false;
561 rtl::Reference< RecursiveTest >(
562 new SimpleRecursiveTest(*this, 100, &destroyed))->test();
588 CPPUNIT_ASSERT(destroyed);
563 ASSERT_TRUE(destroyed);
589}
590
564}
565
591void Test::testCrossThreads() {
566TEST_F(Test, testCrossThreads) {
592 bool destroyed = false;
593 rtl::Reference< RecursiveTest >(
594 new SimpleRecursiveTest(*this, 10, &destroyed))->test();
567 bool destroyed = false;
568 rtl::Reference< RecursiveTest >(
569 new SimpleRecursiveTest(*this, 10, &destroyed))->test();
595 CPPUNIT_ASSERT(destroyed);
570 ASSERT_TRUE(destroyed);
596}
597
598css::uno::Any Test::getKey(
599 rtl::OUString const & path, rtl::OUString const & relative) const
600{
601 css::uno::Reference< css::container::XHierarchicalNameAccess > access(
602 createViewAccess(path), css::uno::UNO_QUERY_THROW);
603 css::uno::Any value(access->getByHierarchicalName(relative));

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

662 css::uno::makeAny(path))));
663 return provider_->createInstanceWithArguments(
664 rtl::OUString(
665 RTL_CONSTASCII_USTRINGPARAM(
666 "com.sun.star.configuration.ConfigurationUpdateAccess")),
667 css::uno::Sequence< css::uno::Any >(&arg, 1));
668}
669
571}
572
573css::uno::Any Test::getKey(
574 rtl::OUString const & path, rtl::OUString const & relative) const
575{
576 css::uno::Reference< css::container::XHierarchicalNameAccess > access(
577 createViewAccess(path), css::uno::UNO_QUERY_THROW);
578 css::uno::Any value(access->getByHierarchicalName(relative));

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

637 css::uno::makeAny(path))));
638 return provider_->createInstanceWithArguments(
639 rtl::OUString(
640 RTL_CONSTASCII_USTRINGPARAM(
641 "com.sun.star.configuration.ConfigurationUpdateAccess")),
642 css::uno::Sequence< css::uno::Any >(&arg, 1));
643}
644
670CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltest");
671
672}
673
645
646}
647
674NOADDITIONAL;
648int main(int argc, char **argv)
649{
650 osl_setCommandArgs(argc, argv);
651 ::testing::InitGoogleTest(&argc, argv);
652 return RUN_ALL_TESTS();
653}