summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-02-11 09:33:47 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-02-11 10:00:32 +0100
commitdab503c530c00bf80df590234534082dcaa61043 (patch)
tree5ec284cc43430a3e70a7772f605a9f9ce117895f /configmgr
parentd49bc78f22d7f7403f1f885f15b1d3dd2840cf0d (diff)
loplugin:unreffun
Change-Id: I6cfa63043460a5776873087c62cfbb2753c88f83
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/qa/unit/test.cxx362
1 files changed, 184 insertions, 178 deletions
diff --git a/configmgr/qa/unit/test.cxx b/configmgr/qa/unit/test.cxx
index 184e5cbbbc42..5caefb07f9b8 100644
--- a/configmgr/qa/unit/test.cxx
+++ b/configmgr/qa/unit/test.cxx
@@ -57,23 +57,6 @@
namespace {
-void normalize(
- OUString const & path, OUString const & relative,
- OUString * normalizedPath, OUString * name)
-{
- sal_Int32 i = relative.lastIndexOf('/');
- if (i == -1) {
- *normalizedPath = path;
- *name = relative;
- } else {
- OUStringBuffer buf(path);
- buf.append('/');
- buf.append(relative.copy(0, i));
- *normalizedPath = buf.makeStringAndClear();
- *name = relative.copy(i + 1);
- }
-}
-
class Test: public CppUnit::TestFixture {
public:
virtual void setUp() SAL_OVERRIDE;
@@ -84,7 +67,9 @@ public:
void testKeyReset();
void testSetSetMemberName();
void testReadCommands();
+#if 0
void testThreads();
+#endif
void testRecursive();
void testCrossThreads();
@@ -109,7 +94,9 @@ public:
CPPUNIT_TEST(testKeyReset);
CPPUNIT_TEST(testSetSetMemberName);
CPPUNIT_TEST(testReadCommands);
- /* CPPUNIT_TEST(testThreads);*/
+#if 0
+ CPPUNIT_TEST(testThreads);
+#endif
CPPUNIT_TEST(testRecursive);
CPPUNIT_TEST(testCrossThreads);
CPPUNIT_TEST_SUITE_END();
@@ -119,108 +106,6 @@ private:
css::uno::Reference< css::lang::XMultiServiceFactory > provider_;
};
-class TestThread: public osl::Thread {
-public:
- TestThread(osl::Condition & stop);
-
- bool getSuccess() const;
-
-protected:
- virtual bool iteration() = 0;
-
-private:
- virtual void SAL_CALL run() SAL_OVERRIDE;
-
- osl::Condition & stop_;
- bool success_;
-};
-
-TestThread::TestThread(
- osl::Condition & stop):
- stop_(stop), success_(true)
-{}
-
-bool TestThread::getSuccess() const
-{
- return success_;
-}
-
-void TestThread::run()
-{
- try {
- while (!stop_.check()) {
- if (!iteration()) {
- success_ = false;
- }
- }
- } catch (...) {
- success_ = false;
- }
-}
-
-class ReaderThread: public TestThread {
-public:
- ReaderThread(
- osl::Condition & stop, Test const & test, OUString const & path,
- OUString const & relative);
-
-private:
- virtual bool iteration() SAL_OVERRIDE;
-
- Test const & test_;
- OUString path_;
- OUString relative_;
-};
-
-ReaderThread::ReaderThread(
- osl::Condition & stop, Test const & test, OUString const & path,
- OUString const & relative):
- TestThread(stop), test_(test), path_(path), relative_(relative)
-{
- create();
-}
-
-bool ReaderThread::iteration()
-{
- return test_.getKey(path_, relative_).hasValue();
-}
-
-class WriterThread: public TestThread {
-public:
- WriterThread(
- osl::Condition & stop, Test const & test, OUString const & path,
- OUString const & relative);
-
-private:
- virtual bool iteration() SAL_OVERRIDE;
-
- Test const & test_;
- OUString path_;
- OUString name_;
- std::size_t index_;
-};
-
-WriterThread::WriterThread(
- osl::Condition & stop, Test const & test, OUString const & path,
- OUString const & relative):
- TestThread(stop), test_(test), index_(0)
-{
- normalize(path, relative, &path_, &name_);
- create();
-}
-
-bool WriterThread::iteration() {
- OUString options[] = {
- OUString("fish"),
- OUString("chips"),
- OUString("kippers"),
- OUString("bloaters") };
-
- test_.setKey(path_, name_, css::uno::makeAny(options[index_]));
- index_ = (index_ + 1) % (sizeof options / sizeof (OUString));
- return true;
-}
-
class RecursiveTest:
public cppu::WeakImplHelper1< css::beans::XPropertyChangeListener >
{
@@ -433,64 +318,6 @@ void Test::testReadCommands()
access, css::uno::UNO_QUERY_THROW)->dispose();
}
-void Test::testThreads()
-{
- struct Entry { OUString path; OUString relative; };
- Entry list[] = {
- { OUString(
- "/org.openoffice.Office.UI.GenericCommands"),
- OUString(
- "UserInterface/Commands/.uno:WebHtml") },
- { OUString(
- "/org.openoffice.Office.UI.GenericCommands"),
- OUString(
- "UserInterface/Commands/.uno:NewPresentation") },
- { OUString(
- "/org.openoffice.Office.UI.GenericCommands"),
- OUString(
- "UserInterface/Commands/.uno:RecentFileList") },
- { OUString("/org.openoffice.System"),
- OUString("L10N/Locale") }
- };
- std::size_t const numReaders = sizeof list / sizeof (Entry);
- std::size_t const numWriters = numReaders - 2;
- ReaderThread * readers[numReaders];
- WriterThread * writers[numWriters];
- osl::Condition stop;
- for (std::size_t i = 0; i < numReaders; ++i) {
- CPPUNIT_ASSERT(getKey(list[i].path, list[i].relative).hasValue());
- readers[i] = new ReaderThread(
- stop, *this, list[i].path, list[i].relative);
- }
- for (std::size_t i = 0; i < numWriters; ++i) {
- writers[i] = new WriterThread(
- stop, *this, list[i].path, list[i].relative);
- }
- for (int i = 0; i < 5; ++i) {
- for (std::size_t j = 0; j < numReaders; ++j) {
- OUString path;
- OUString name;
- normalize(list[j].path, list[j].relative, &path, &name);
- resetKey(path, name);
- osl::Thread::yield();
- }
- }
- stop.set();
- bool success = true;
- for (std::size_t i = 0; i < numReaders; ++i) {
- readers[i]->join();
- CPPUNIT_ASSERT(readers[i]->getSuccess());
- delete readers[i];
- }
- for (std::size_t i = 0; i < numWriters; ++i) {
- writers[i]->join();
- CPPUNIT_ASSERT(writers[i]->getSuccess());
- delete writers[i];
- }
-
- CPPUNIT_ASSERT(success);
-}
-
void Test::testRecursive()
{
bool destroyed = false;
@@ -577,6 +404,185 @@ css::uno::Reference< css::uno::XInterface > Test::createUpdateAccess(
css::uno::Sequence< css::uno::Any >(&arg, 1));
}
+#if 0
+class TestThread: public osl::Thread {
+public:
+ TestThread(osl::Condition & stop);
+
+ bool getSuccess() const;
+
+protected:
+ virtual bool iteration() = 0;
+
+private:
+ virtual void SAL_CALL run() SAL_OVERRIDE;
+
+ osl::Condition & stop_;
+ bool success_;
+};
+
+TestThread::TestThread(
+ osl::Condition & stop):
+ stop_(stop), success_(true)
+{}
+
+bool TestThread::getSuccess() const
+{
+ return success_;
+}
+
+void TestThread::run()
+{
+ try {
+ while (!stop_.check()) {
+ if (!iteration()) {
+ success_ = false;
+ }
+ }
+ } catch (...) {
+ success_ = false;
+ }
+}
+
+class ReaderThread: public TestThread {
+public:
+ ReaderThread(
+ osl::Condition & stop, Test const & test, OUString const & path,
+ OUString const & relative);
+
+private:
+ virtual bool iteration() SAL_OVERRIDE;
+
+ Test const & test_;
+ OUString path_;
+ OUString relative_;
+};
+
+ReaderThread::ReaderThread(
+ osl::Condition & stop, Test const & test, OUString const & path,
+ OUString const & relative):
+ TestThread(stop), test_(test), path_(path), relative_(relative)
+{
+ create();
+}
+
+bool ReaderThread::iteration()
+{
+ return test_.getKey(path_, relative_).hasValue();
+}
+
+void normalize(
+ OUString const & path, OUString const & relative,
+ OUString * normalizedPath, OUString * name)
+{
+ sal_Int32 i = relative.lastIndexOf('/');
+ if (i == -1) {
+ *normalizedPath = path;
+ *name = relative;
+ } else {
+ OUStringBuffer buf(path);
+ buf.append('/');
+ buf.append(relative.copy(0, i));
+ *normalizedPath = buf.makeStringAndClear();
+ *name = relative.copy(i + 1);
+ }
+}
+
+class WriterThread: public TestThread {
+public:
+ WriterThread(
+ osl::Condition & stop, Test const & test, OUString const & path,
+ OUString const & relative);
+
+private:
+ virtual bool iteration() SAL_OVERRIDE;
+
+ Test const & test_;
+ OUString path_;
+ OUString name_;
+ std::size_t index_;
+};
+
+WriterThread::WriterThread(
+ osl::Condition & stop, Test const & test, OUString const & path,
+ OUString const & relative):
+ TestThread(stop), test_(test), index_(0)
+{
+ normalize(path, relative, &path_, &name_);
+ create();
+}
+
+bool WriterThread::iteration() {
+ OUString options[] = {
+ OUString("fish"),
+ OUString("chips"),
+ OUString("kippers"),
+ OUString("bloaters") };
+
+ test_.setKey(path_, name_, css::uno::makeAny(options[index_]));
+ index_ = (index_ + 1) % (sizeof options / sizeof (OUString));
+ return true;
+}
+
+void Test::testThreads()
+{
+ struct Entry { OUString path; OUString relative; };
+ Entry list[] = {
+ { OUString(
+ "/org.openoffice.Office.UI.GenericCommands"),
+ OUString(
+ "UserInterface/Commands/.uno:WebHtml") },
+ { OUString(
+ "/org.openoffice.Office.UI.GenericCommands"),
+ OUString(
+ "UserInterface/Commands/.uno:NewPresentation") },
+ { OUString(
+ "/org.openoffice.Office.UI.GenericCommands"),
+ OUString(
+ "UserInterface/Commands/.uno:RecentFileList") },
+ { OUString("/org.openoffice.System"),
+ OUString("L10N/Locale") }
+ };
+ std::size_t const numReaders = sizeof list / sizeof (Entry);
+ std::size_t const numWriters = numReaders - 2;
+ ReaderThread * readers[numReaders];
+ WriterThread * writers[numWriters];
+ osl::Condition stop;
+ for (std::size_t i = 0; i < numReaders; ++i) {
+ CPPUNIT_ASSERT(getKey(list[i].path, list[i].relative).hasValue());
+ readers[i] = new ReaderThread(
+ stop, *this, list[i].path, list[i].relative);
+ }
+ for (std::size_t i = 0; i < numWriters; ++i) {
+ writers[i] = new WriterThread(
+ stop, *this, list[i].path, list[i].relative);
+ }
+ for (int i = 0; i < 5; ++i) {
+ for (std::size_t j = 0; j < numReaders; ++j) {
+ OUString path;
+ OUString name;
+ normalize(list[j].path, list[j].relative, &path, &name);
+ resetKey(path, name);
+ osl::Thread::yield();
+ }
+ }
+ stop.set();
+ bool success = true;
+ for (std::size_t i = 0; i < numReaders; ++i) {
+ readers[i]->join();
+ CPPUNIT_ASSERT(readers[i]->getSuccess());
+ delete readers[i];
+ }
+ for (std::size_t i = 0; i < numWriters; ++i) {
+ writers[i]->join();
+ CPPUNIT_ASSERT(writers[i]->getSuccess());
+ delete writers[i];
+ }
+
+ CPPUNIT_ASSERT(success);
+}
+#endif
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}