[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 10 commits - configmgr/qa cppuhelper/qa sal/qa sfx2/CppunitTest_sfx2_metadatable.mk sfx2/GoogleTest_sfx2_metadatable.mk sfx2/Module_sfx2.mk sfx2/qa slideshow/test stoc/test sw/GoogleTest_sw_bigpointerarray.mk sw/Module_sw.mk sw/qa sw/source tools/GoogleTest_tools_fractiontest.mk tools/Module_tools.mk tools/test
Damjan Jovanovic
damjan at apache.org
Sun Sep 20 13:42:36 PDT 2015
Rebased ref, commits from common ancestor:
commit 06de7664d7c85390f3780f5025f69f08d4116867
Author: Damjan Jovanovic <damjan at apache.org>
Date: Sun Sep 20 18:29:11 2015 +0000
#i126529# Bullet should be apart of AccessibleText
Patch by: Niklas Johansson <sleeping dot pillow at gmail dot com>
diff --git a/sw/source/core/access/accportions.cxx b/sw/source/core/access/accportions.cxx
index 6d438c4..237ef17 100644
--- a/sw/source/core/access/accportions.cxx
+++ b/sw/source/core/access/accportions.cxx
@@ -170,7 +170,6 @@ void SwAccessiblePortionData::Special(
sDisplay = String(sal_Unicode(0xfffc));
break;
case POR_GRFNUM:
- case POR_BULLET:
break;
case POR_FLD:
//Added by yanjun for 6854
@@ -202,6 +201,7 @@ void SwAccessiblePortionData::Special(
}
break;
case POR_NUMBER:
+ case POR_BULLET:
{
OUStringBuffer aTmpBuffer( rText.Len() + 1 );
aTmpBuffer.append( rText );
commit 93dbde5274464c89de5cd55bea70491e043bc9b4
Author: Damjan Jovanovic <damjan at apache.org>
Date: Sun Sep 20 16:02:17 2015 +0000
#i125003# migrate main/stoc/test/uriproc from cppunit to Google Test
diff --git a/stoc/test/uriproc/makefile.mk b/stoc/test/uriproc/makefile.mk
index a7fed75..030f24e 100644
--- a/stoc/test/uriproc/makefile.mk
+++ b/stoc/test/uriproc/makefile.mk
@@ -35,18 +35,22 @@ my_components = stocservices
.INCLUDE: settings.mk
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+ @echo unit tests are disabled. Nothing to do.
+
+.ELSE
+
DLLPRE = # no leading "lib" on .so files
-SHL1TARGET = $(TARGET)
-SHL1OBJS = $(SLO)/test_uriproc.obj
-SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(SALLIB)
-SHL1VERSIONMAP = version.map
-SHL1RPATH = NONE
-SHL1IMPLIB = i$(SHL1TARGET)
-DEF1NAME = $(SHL1TARGET)
+APP1TARGET = $(TARGET)
+APP1OBJS = $(SLO)/test_uriproc.obj
+APP1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(GTESTLIB) $(SALLIB)
+APP1RPATH = NONE
+# this is a custom test, can't use APP1TARGET_run so disable it here:
+APP1TEST = disabled
-SLOFILES = $(SHL1OBJS)
+SLOFILES = $(APP1OBJS)
.INCLUDE: target.mk
@@ -59,10 +63,11 @@ my_file = file://
ALLTAR: test
test .PHONY: $(SHL1TARGETN) $(MISC)/$(TARGET)/services.rdb
- $(CPPUNITTESTER) $(SHL1TARGETN) \
- -env:UNO_TYPES=$(my_file)$(SOLARBINDIR)/udkapi.rdb \
- -env:UNO_SERVICES=$(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb \
- -env:URE_INTERNAL_LIB_DIR=$(my_file)$(PWD)/$(DLLDEST)
+ $(COMMAND_ECHO) $(AUGMENT_LIBRARY_PATH_LOCAL) \
+ UNO_TYPES=$(my_file)$(SOLARBINDIR)/udkapi.rdb \
+ UNO_SERVICES=$(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb \
+ URE_INTERNAL_LIB_DIR=$(my_file)$(PWD)/$(DLLDEST) \
+ $(APP1TARGETN) --gtest_output="xml:$(BIN)/$(APP1TARGET)_result.xml"
$(MISC)/$(TARGET)/services.rdb .ERRREMOVE: $(SOLARENV)/bin/packcomponents.xslt \
$(MISC)/$(TARGET)/services.input \
@@ -76,4 +81,6 @@ $(MISC)/$(TARGET)/services.input:
'<list>$(my_components:^"<filename>":+".component</filename>")</list>' \
> $@
-.END
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"
+
+.ENDIF # "$(OOO_SUBSEQUENT_TESTS)" == ""
diff --git a/stoc/test/uriproc/test_uriproc.cxx b/stoc/test/uriproc/test_uriproc.cxx
index c97dbe9..637afb7 100644
--- a/stoc/test/uriproc/test_uriproc.cxx
+++ b/stoc/test/uriproc/test_uriproc.cxx
@@ -39,11 +39,9 @@
#include "com/sun/star/uri/XVndSunStarScriptUrlReference.hpp"
#include "com/sun/star/util/XMacroExpander.hpp"
#include "cppuhelper/bootstrap.hxx"
-#include "cppunit/TestAssert.h"
-#include "cppunit/TestFixture.h"
-#include "cppunit/extensions/HelperMacros.h"
-#include "cppunit/plugin/TestPlugIn.h"
+#include "gtest/gtest.h"
#include "osl/diagnose.h"
+#include "osl/process.h"
#include "rtl/string.h"
#include "rtl/string.hxx"
#include "rtl/textenc.h"
@@ -58,11 +56,11 @@ namespace css = com::sun::star;
namespace {
#define TEST_ASSERT_EQUAL(token1, token2, token3, expected, actual) \
- CPPUNIT_ASSERT_MESSAGE( \
+ ASSERT_TRUE( \
+ (actual) == (expected)) << \
createTestAssertEqualMessage( \
token1, token2, token3, #expected, #actual, expected, actual). \
- getStr(), \
- (actual) == (expected))
+ getStr()
template< typename T > void append(
rtl::OUStringBuffer & buffer, T const & value)
@@ -109,53 +107,29 @@ rtl::OString createTestAssertEqualMessage(
buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US);
}
-class Test: public CppUnit::TestFixture {
+class Test: public ::testing::Test {
public:
- virtual void setUp();
+ virtual void SetUp();
- virtual void tearDown();
+ virtual void TearDown();
- void testParse();
-
- void testMakeAbsolute();
-
- void testMakeRelative();
-
- void testVndSunStarExpand();
-
- void testVndSunStarScript();
-
- void testTranslator();
-
- void testPkgUrlFactory();
-
- CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testMakeAbsolute);
- CPPUNIT_TEST(testMakeRelative);
- CPPUNIT_TEST(testVndSunStarExpand);
- CPPUNIT_TEST(testVndSunStarScript);
- CPPUNIT_TEST(testTranslator);
- CPPUNIT_TEST(testPkgUrlFactory);
- CPPUNIT_TEST_SUITE_END();
-
-private:
+protected:
css::uno::Reference< css::uno::XComponentContext > m_context;
css::uno::Reference< css::uri::XUriReferenceFactory > m_uriFactory;
};
-void Test::setUp() {
+void Test::SetUp() {
m_context = cppu::defaultBootstrap_InitialComponentContext();
m_uriFactory = css::uri::UriReferenceFactory::create(m_context);
}
-void Test::tearDown() {
+void Test::TearDown() {
m_uriFactory.clear();
css::uno::Reference< css::lang::XComponent >(
m_context, css::uno::UNO_QUERY_THROW)->dispose();
}
-void Test::testParse() {
+TEST_F(Test, testParse) {
struct Data {
char const * uriReference;
char const * scheme;
@@ -204,7 +178,7 @@ void Test::testParse() {
css::uno::Reference< css::uri::XUriReference > uriRef(
m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].uriReference)));
- CPPUNIT_ASSERT(uriRef.is() == (data[i].schemeSpecificPart != 0));
+ ASSERT_TRUE(uriRef.is() == (data[i].schemeSpecificPart != 0));
if (uriRef.is()) {
TEST_ASSERT_EQUAL(
"testParse", i, data[i].uriReference,
@@ -291,7 +265,7 @@ void Test::testParse() {
}
}
-void Test::testMakeAbsolute() {
+TEST_F(Test, testMakeAbsolute) {
struct Data {
char const * baseUriReference;
char const * uriReference;
@@ -594,11 +568,11 @@ void Test::testMakeAbsolute() {
css::uno::Reference< css::uri::XUriReference > baseUriRef(
m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].baseUriReference)));
- CPPUNIT_ASSERT(baseUriRef.is());
+ ASSERT_TRUE(baseUriRef.is());
css::uno::Reference< css::uri::XUriReference > uriRef(
m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].uriReference)));
- CPPUNIT_ASSERT(uriRef.is());
+ ASSERT_TRUE(uriRef.is());
css::uno::Reference< css::uri::XUriReference > absolute(
m_uriFactory->makeAbsolute(
baseUriRef, uriRef, data[i].processSpecialBaseSegments,
@@ -615,7 +589,7 @@ void Test::testMakeAbsolute() {
}
}
-void Test::testMakeRelative() {
+TEST_F(Test, testMakeRelative) {
struct Data {
char const * baseUriReference;
char const * uriReference;
@@ -699,11 +673,11 @@ void Test::testMakeRelative() {
css::uno::Reference< css::uri::XUriReference > baseUriRef(
m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].baseUriReference)));
- CPPUNIT_ASSERT(baseUriRef.is());
+ ASSERT_TRUE(baseUriRef.is());
css::uno::Reference< css::uri::XUriReference > uriRef(
m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].uriReference)));
- CPPUNIT_ASSERT(uriRef.is());
+ ASSERT_TRUE(uriRef.is());
css::uno::Reference< css::uri::XUriReference > relative(
m_uriFactory->makeRelative(
baseUriRef, uriRef, data[i].preferAuthorityOverRelativePath,
@@ -721,7 +695,7 @@ void Test::testMakeRelative() {
m_uriFactory->makeAbsolute(
baseUriRef, relative, true,
css::uri::RelativeUriExcessParentSegments_ERROR));
- CPPUNIT_ASSERT(absolute.is());
+ ASSERT_TRUE(absolute.is());
TEST_ASSERT_EQUAL(
"testMakeRelative", i, data[i].uriReference,
rtl::OUString::createFromAscii(
@@ -732,7 +706,7 @@ void Test::testMakeRelative() {
}
}
-void Test::testVndSunStarExpand() {
+TEST_F(Test, testVndSunStarExpand) {
struct Data {
char const * uriReference;
char const * expanded;
@@ -766,7 +740,7 @@ void Test::testVndSunStarExpand() {
}
}
-void Test::testVndSunStarScript() {
+TEST_F(Test, testVndSunStarScript) {
struct Parameter {
char const * key;
char const * value;
@@ -920,7 +894,7 @@ void Test::testVndSunStarScript() {
true);
}
-void Test::testTranslator() {
+TEST_F(Test, testTranslator) {
struct Data {
char const * externalUriReference;
char const * internalUriReference;
@@ -964,7 +938,7 @@ void Test::testTranslator() {
}
}
-void Test::testPkgUrlFactory() {
+TEST_F(Test, testPkgUrlFactory) {
struct Data {
char const * authority;
char const * result;
@@ -993,8 +967,12 @@ void Test::testPkgUrlFactory() {
}
}
-CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}
-CPPUNIT_PLUGIN_IMPLEMENT();
+int main(int argc, char **argv)
+{
+ osl_setCommandArgs(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
commit d7b7943aa73e3d39f3e6c7b594ec16145aa96494
Author: Damjan Jovanovic <damjan at apache.org>
Date: Sun Sep 20 15:35:09 2015 +0000
#i125003# migrate main/configmgr/qa/unit from cppunit to Google Test. All tests fail
and on Windows it doesn't start running, but these look like problems from before
and at least it doesn't run during the build.
diff --git a/configmgr/qa/unit/makefile.mk b/configmgr/qa/unit/makefile.mk
index ea24171..3b2c786 100644
--- a/configmgr/qa/unit/makefile.mk
+++ b/configmgr/qa/unit/makefile.mk
@@ -29,20 +29,25 @@ ENABLE_EXCEPTIONS = TRUE
.INCLUDE: settings.mk
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+ @echo unit tests are disabled. Nothing to do.
+
+.ELSE
SLOFILES = $(SLO)/test.obj
-SHL1OBJS = $(SLOFILES)
-SHL1STDLIBS = \
+APP1OBJS = $(SLOFILES)
+APP1STDLIBS = \
$(CPPUHELPERLIB) \
$(CPPULIB) \
- $(CPPUNITLIB) \
+ $(GTESTLIB) \
$(SALLIB) \
$(TESTSHL2LIB)
-SHL1TARGET = unit
-SHL1VERSIONMAP = version.map
-DEF1NAME = $(SHL1TARGET)
+APP1TARGET = unit
+APP1RPATH = NONE
+# this is a custom test, can't use APP1TARGET_run so disable it here:
+APP1TEST = disabled
.INCLUDE: target.mk
@@ -54,11 +59,13 @@ MY_INI = .ini
MY_INI = rc
.ENDIF
+DLLPRE = # no leading "lib" on .so files
+
$(MISC)/unit.rdb .ERRREMOVE:
cp $(SOLARBINDIR)/types.rdb $@
- $(REGCOMP) -register -r $@ -c $(DLLDEST)/$(DLLPRE)configmgr$(DLLPOST)
+ $(REGCOMP) -register -r $@ -c $(DLLDEST)/$(DLLPRE)configmgr.uno$(DLLPOST)
-TEST .PHONY: $(SHL1TARGETN) $(MISC)/unit.rdb
+TEST .PHONY: $(APP1TARGETN) $(MISC)/unit.rdb
rm -rf $(MISC)/unitdata
mkdir $(MISC)/unitdata
cp urebootstrap.ini $(MISC)/unitdata
@@ -78,12 +85,9 @@ TEST .PHONY: $(SHL1TARGETN) $(MISC)/unit.rdb
echo '[Bootstrap]' > $(MISC)/unitdata/brand/program/bootstrap$(MY_INI)
echo 'UserInstallation = $$ORIGIN/../../user' \
>> $(MISC)/unitdata/brand/program/bootstrap$(MY_INI)
-.IF "$(USE_SHELL)" == "bash"
- export \
- URE_BOOTSTRAP=vnd.sun.star.pathname:$(MISC)/unitdata/urebootstrap.ini \
- && $(TESTSHL2) $(SHL1TARGETN) -forward $(MISC)/unit.rdb
-.ELSE
- setenv \
- URE_BOOTSTRAP vnd.sun.star.pathname:$(MISC)/unitdata/urebootstrap.ini \
- && $(TESTSHL2) $(SHL1TARGETN) -forward $(MISC)/unit.rdb
-.ENDIF
+ $(COMMAND_ECHO) $(AUGMENT_LIBRARY_PATH_LOCAL) \
+ URE_BOOTSTRAP=vnd.sun.star.pathname:$(MISC)/unitdata/urebootstrap.ini \
+ CONFIGMGR_UNIT_FORWARD_STRING=$(MISC)/unit.rdb \
+ $(APP1TARGETN) --gtest_output="xml:$(BIN)/$(APP1TARGET)_result.xml"
+
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"
diff --git a/configmgr/qa/unit/test.cxx b/configmgr/qa/unit/test.cxx
index 0d53cdf..292d9e0 100644
--- a/configmgr/qa/unit/test.cxx
+++ b/configmgr/qa/unit/test.cxx
@@ -25,6 +25,7 @@
#include "sal/config.h"
#include <cstddef>
+#include <cstdlib>
#include "com/sun/star/beans/NamedValue.hpp"
#include "com/sun/star/beans/PropertyChangeEvent.hpp"
@@ -47,6 +48,7 @@
#include "cppuhelper/implbase1.hxx"
#include "cppuhelper/servicefactory.hxx"
#include "osl/conditn.hxx"
+#include "osl/process.h"
#include "osl/thread.h"
#include "osl/thread.hxx"
#include "osl/time.h"
@@ -57,7 +59,7 @@
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
-#include "testshl/simpleheader.hxx"
+#include "gtest/gtest.h"
namespace {
@@ -80,27 +82,11 @@ void normalize(
}
}
-class Test: public CppUnit::TestFixture {
+class Test: public ::testing::Test {
public:
- virtual void setUp();
+ virtual void SetUp();
- virtual void tearDown();
-
- void testKeyFetch();
-
- void testKeySet();
-
- void testKeyReset();
-
- void testSetSetMemberName();
-
- void testReadCommands();
-
- void testThreads();
-
- void testRecursive();
-
- void testCrossThreads();
+ virtual void TearDown();
css::uno::Any getKey(
rtl::OUString const & path, rtl::OUString const & relative) const;
@@ -117,17 +103,6 @@ public:
css::uno::Reference< css::uno::XInterface > createUpdateAccess(
rtl::OUString const & path) const;
- CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(testKeyFetch);
- CPPUNIT_TEST(testKeySet);
- CPPUNIT_TEST(testKeyReset);
- CPPUNIT_TEST(testSetSetMemberName);
- CPPUNIT_TEST(testReadCommands);
- CPPUNIT_TEST(testThreads);
- CPPUNIT_TEST(testRecursive);
- CPPUNIT_TEST(testCrossThreads);
- CPPUNIT_TEST_SUITE_END();
-
private:
css::uno::Reference< css::uno::XComponentContext > context_;
css::uno::Reference< css::lang::XMultiServiceFactory > provider_;
@@ -275,7 +250,7 @@ void RecursiveTest::test() {
properties_->addPropertyChangeListener(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")), this);
step();
- CPPUNIT_ASSERT(count_ == 0);
+ ASSERT_TRUE(count_ == 0);
css::uno::Reference< css::lang::XComponent >(
properties_, css::uno::UNO_QUERY_THROW)->dispose();
}
@@ -287,14 +262,14 @@ RecursiveTest::~RecursiveTest() {
void RecursiveTest::disposing(css::lang::EventObject const & Source)
throw (css::uno::RuntimeException)
{
- CPPUNIT_ASSERT(properties_.is() && Source.Source == properties_);
+ ASSERT_TRUE(properties_.is() && Source.Source == properties_);
properties_.clear();
}
void RecursiveTest::propertyChange(css::beans::PropertyChangeEvent const & evt)
throw (css::uno::RuntimeException)
{
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
evt.Source == properties_ &&
evt.PropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Label")));
if (count_ > 0) {
@@ -357,10 +332,10 @@ void CrossThreadTest::step() const {
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")));
}
-void Test::setUp() {
- char const * forward = getForwardString();
+void Test::SetUp() {
+ char const * forward = getenv("CONFIGMGR_UNIT_FORWARD_STRING");
rtl_uString * registry = 0;
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
rtl_convertStringToUString(
®istry, forward, rtl_str_getLength(forward),
osl_getThreadTextEncoding(),
@@ -374,7 +349,7 @@ void Test::setUp() {
css::uno::UNO_QUERY_THROW)->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))),
css::uno::UNO_QUERY_THROW);
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
context_->getValueByName(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
@@ -383,61 +358,61 @@ void Test::setUp() {
provider_);
}
-void Test::tearDown() {
+void Test::TearDown() {
css::uno::Reference< css::lang::XComponent >(
context_, css::uno::UNO_QUERY_THROW)->dispose();
}
-void Test::testKeyFetch() {
+TEST_F(Test, testKeyFetch) {
rtl::OUString s;
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
getKey(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("L10N/ooLocale"))) >>=
s);
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
getKey(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/AString"))) >>=
s);
}
-void Test::testKeySet() {
+TEST_F(Test, testKeySet) {
setKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString")),
css::uno::makeAny(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("baa"))));
rtl::OUString s;
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
getKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString"))) >>=
s);
- CPPUNIT_ASSERT(s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("baa")));
+ ASSERT_TRUE(s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("baa")));
}
-void Test::testKeyReset() {
+TEST_F(Test, testKeyReset) {
if (resetKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString"))))
{
rtl::OUString s;
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
getKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString"))) >>=
s);
- CPPUNIT_ASSERT(s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Foo")));
+ ASSERT_TRUE(s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Foo")));
}
}
-void Test::testSetSetMemberName() {
+TEST_F(Test, testSetSetMemberName) {
rtl::OUString s;
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
getKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
@@ -445,7 +420,7 @@ void Test::testSetSetMemberName() {
".uno:FontworkShapeType")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label"))) >>=
s);
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Fontwork Shape")));
css::uno::Reference< css::container::XNameAccess > access(
@@ -460,7 +435,7 @@ void Test::testSetSetMemberName() {
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(".uno:FontworkGalleryFloater"))) >>=
member;
- CPPUNIT_ASSERT(member.is());
+ ASSERT_TRUE(member.is());
member->setName(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(".uno:FontworkShapeType")));
@@ -469,7 +444,7 @@ void Test::testSetSetMemberName() {
css::uno::Reference< css::lang::XComponent >(
access, css::uno::UNO_QUERY_THROW)->dispose();
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
getKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
@@ -477,11 +452,11 @@ void Test::testSetSetMemberName() {
".uno:FontworkShapeType")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label"))) >>=
s);
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Fontwork Gallery")));
}
-void Test::testReadCommands() {
+TEST_F(Test, testReadCommands) {
css::uno::Reference< css::container::XNameAccess > access(
createViewAccess(
rtl::OUString(
@@ -490,14 +465,14 @@ void Test::testReadCommands() {
"Commands"))),
css::uno::UNO_QUERY_THROW);
css::uno::Sequence< rtl::OUString > names(access->getElementNames());
- CPPUNIT_ASSERT(names.getLength() == 695);
+ ASSERT_TRUE(names.getLength() == 695);
// testSetSetMemberName() already removed ".uno:FontworkGalleryFloater"
sal_uInt32 n = osl_getGlobalTimer();
for (int i = 0; i < 8; ++i) {
for (sal_Int32 j = 0; j < names.getLength(); ++j) {
css::uno::Reference< css::container::XNameAccess > child;
if (access->getByName(names[j]) >>= child) {
- CPPUNIT_ASSERT(child.is());
+ ASSERT_TRUE(child.is());
child->getByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")));
child->getByName(
@@ -508,12 +483,12 @@ void Test::testReadCommands() {
}
}
n = osl_getGlobalTimer() - n;
- t_print("Reading elements took %" SAL_PRIuUINT32 " ms\n", n);
+ printf("Reading elements took %" SAL_PRIuUINT32 " ms\n", n);
css::uno::Reference< css::lang::XComponent >(
access, css::uno::UNO_QUERY_THROW)->dispose();
}
-void Test::testThreads() {
+TEST_F(Test, testThreads) {
struct Entry { rtl::OUString path; rtl::OUString relative; };
Entry list[] = {
{ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
@@ -549,7 +524,7 @@ void Test::testThreads() {
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());
+ ASSERT_TRUE(getKey(list[i].path, list[i].relative).hasValue());
readers[i] = new ReaderThread(
stop, *this, list[i].path, list[i].relative);
}
@@ -578,21 +553,21 @@ void Test::testThreads() {
success = success && writers[i]->getSuccess();
delete writers[i];
}
- CPPUNIT_ASSERT(success);
+ ASSERT_TRUE(success);
}
-void Test::testRecursive() {
+TEST_F(Test, testRecursive) {
bool destroyed = false;
rtl::Reference< RecursiveTest >(
new SimpleRecursiveTest(*this, 100, &destroyed))->test();
- CPPUNIT_ASSERT(destroyed);
+ ASSERT_TRUE(destroyed);
}
-void Test::testCrossThreads() {
+TEST_F(Test, testCrossThreads) {
bool destroyed = false;
rtl::Reference< RecursiveTest >(
new SimpleRecursiveTest(*this, 10, &destroyed))->test();
- CPPUNIT_ASSERT(destroyed);
+ ASSERT_TRUE(destroyed);
}
css::uno::Any Test::getKey(
@@ -667,8 +642,12 @@ css::uno::Reference< css::uno::XInterface > Test::createUpdateAccess(
css::uno::Sequence< css::uno::Any >(&arg, 1));
}
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltest");
}
-NOADDITIONAL;
+int main(int argc, char **argv)
+{
+ osl_setCommandArgs(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
commit faff774b727508f7eb088a18a8d3b46f4a51a6af
Author: Damjan Jovanovic <damjan at apache.org>
Date: Sun Sep 20 13:43:27 2015 +0000
#i125003# migrate main/cppuhelper/qa/propertysetmixin from cppunit to Google Test
diff --git a/cppuhelper/qa/propertysetmixin/makefile.mk b/cppuhelper/qa/propertysetmixin/makefile.mk
index f653a76..19699f2 100644
--- a/cppuhelper/qa/propertysetmixin/makefile.mk
+++ b/cppuhelper/qa/propertysetmixin/makefile.mk
@@ -25,6 +25,12 @@
nothing .PHONY:
.ELSE
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+ @echo unit tests are disabled. Nothing to do.
+
+.ELSE
+
PRJ := ../..
PRJNAME := cppuhelper
@@ -45,15 +51,13 @@ my_file = file://
DLLPRE = # no leading "lib" on .so files
INCPRE += -I$(MISC)/$(TARGET)/inc
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
-SHL1TARGET = $(TARGET)
-SHL1OBJS = $(SLO)/test_propertysetmixin.obj
-SHL1VERSIONMAP = test.map
-SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(SALLIB)
-SHL1IMPLIB = i$(SHL1TARGET)
-SHL1RPATH = NONE
-DEF1NAME = $(SHL1TARGET)
+APP1TARGET = $(TARGET)
+APP1OBJS = $(SLO)/test_propertysetmixin.obj
+APP1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(GTESTLIB) $(SALLIB)
+APP1RPATH = NONE
+# this is a custom test, can't use APP1TARGET_run so disable it here:
+APP1TEST = disabled
SHL2TARGET = $(TARGET).uno
SHL2OBJS = $(SLO)/comp_propertysetmixin.obj
@@ -63,15 +67,16 @@ SHL2IMPLIB = i$(SHL2TARGET)
SH21RPATH = NONE
DEF2NAME = $(SHL2TARGET)
-SLOFILES = $(SHL1OBJS) $(SHL2OBJS)
+SLOFILES = $(APP1OBJS) $(SHL2OBJS)
JAVAFILES = JavaSupplier.java
JARFILES = java_uno.jar juh.jar jurt.jar ridl.jar
-.INCLUDE: target.mk
ALLTAR: test
+.INCLUDE: target.mk
+
$(MISC)/$(TARGET)/types.urd: types.idl
$(MKDIRHIER) $(@:d)
$(IDLC) -O$(@:d) -I$(SOLARIDLDIR) -cid -we $<
@@ -121,14 +126,19 @@ $(MISC)/$(TARGET)/$(TARGET).uno.jar: $(JAVATARGET) \
$(MISC)/$(TARGET)/javamaker.flag manifest
jar cfm $@ manifest -C $(CLASSDIR) test/cppuhelper/propertysetmixin
-test .PHONY: $(SHL1TARGETN) $(SHL2TARGETN) $(MISC)/$(TARGET)/$(TARGET).uno.jar \
+
+test .PHONY: $(APP1TARGETN) $(SHL2TARGETN) $(MISC)/$(TARGET)/$(TARGET).uno.jar \
$(MISC)/$(TARGET)/types.rdb $(MISC)/$(TARGET)/services.rdb
- $(CPPUNITTESTER) $(SHL1TARGETN) \
- '-env:UNO_TYPES=$(my_file)$(SOLARBINDIR)/udkapi.rdb $(my_file)$(PWD)/$(MISC)/$(TARGET)/types.rdb' \
- '-env:UNO_SERVICES=$(my_file)$(SOLARXMLDIR)/ure/services.rdb $(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb'\
- -env:URE_INTERNAL_LIB_DIR=$(my_file)$(SOLARSHAREDBIN) \
- -env:URE_INTERNAL_JAVA_DIR=$(my_file)$(SOLARBINDIR) \
- -env:OOO_INBUILD_SHAREDLIB_DIR=$(my_file)$(PWD)/$(DLLDEST) \
- -env:OOO_INBUILD_JAR_DIR=$(my_file)$(PWD)/$(MISC)/$(TARGET)
+ $(COMMAND_ECHO) $(AUGMENT_LIBRARY_PATH_LOCAL) \
+ UNO_TYPES='$(my_file)$(SOLARBINDIR)/udkapi.rdb $(my_file)$(PWD)/$(MISC)/$(TARGET)/types.rdb' \
+ UNO_SERVICES='$(my_file)$(SOLARXMLDIR)/ure/services.rdb $(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb'\
+ URE_INTERNAL_LIB_DIR=$(my_file)$(SOLARSHAREDBIN) \
+ URE_INTERNAL_JAVA_DIR=$(my_file)$(SOLARBINDIR) \
+ OOO_INBUILD_SHAREDLIB_DIR=$(my_file)$(PWD)/$(DLLDEST) \
+ OOO_INBUILD_JAR_DIR=$(my_file)$(PWD)/$(MISC)/$(TARGET) \
+ $(APP1TARGETN) --gtest_output="xml:$(BIN)/$(APP1TARGET)_result.xml"
-.END
+
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"
+
+.ENDIF # "$(OOO_SUBSEQUENT_TESTS)" == ""
diff --git a/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx b/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx
index 4caa4d9..bed1f93 100644
--- a/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx
+++ b/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx
@@ -56,10 +56,7 @@
#include "com/sun/star/uno/XComponentContext.hpp"
#include "cppuhelper/bootstrap.hxx"
#include "cppuhelper/implbase1.hxx"
-#include "cppunit/TestAssert.h"
-#include "cppunit/TestFixture.h"
-#include "cppunit/extensions/HelperMacros.h"
-#include "cppunit/plugin/TestPlugIn.h"
+#include "gtest/gtest.h"
#include "osl/mutex.hxx"
#include "rtl/ref.hxx"
#include "rtl/string.h"
@@ -67,6 +64,7 @@
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
+#include "osl/process.h"
#include <limits>
#include <ostream>
@@ -107,14 +105,14 @@ public:
throw (css::uno::RuntimeException)
{
osl::MutexGuard g(m_mutex);
- CPPUNIT_ASSERT(m_count < std::numeric_limits< int >::max());
+ ASSERT_TRUE(m_count < std::numeric_limits< int >::max());
++m_count;
}
virtual void SAL_CALL propertyChange(
css::beans::PropertyChangeEvent const &)
throw (css::uno::RuntimeException)
- { CPPUNIT_FAIL("BoundListener::propertyChange called"); }
+ { FAIL() << "BoundListener::propertyChange called"; }
private:
BoundListener(BoundListener &); // not defined
@@ -141,14 +139,14 @@ public:
throw (css::uno::RuntimeException)
{
osl::MutexGuard g(m_mutex);
- CPPUNIT_ASSERT(m_count < std::numeric_limits< int >::max());
+ ASSERT_TRUE(m_count < std::numeric_limits< int >::max());
++m_count;
}
virtual void SAL_CALL vetoableChange(
css::beans::PropertyChangeEvent const &)
throw (css::beans::PropertyVetoException, css::uno::RuntimeException)
- { CPPUNIT_FAIL("VetoListener::vetoableChange called"); }
+ { FAIL() << "VetoListener::vetoableChange called"; }
private:
VetoListener(VetoListener &); // not defined
@@ -160,34 +158,13 @@ private:
int m_count;
};
-class Test: public CppUnit::TestFixture {
+class Test: public ::testing::Test {
public:
- virtual void setUp();
+ virtual void SetUp();
- virtual void tearDown();
+ virtual void TearDown();
- void testCppEmpty1() { testEmpty1(getCppSupplier()); }
-
- void testCppEmpty2() { testEmpty2(getCppSupplier()); }
-
- void testCppFull() { testFull(getCppSupplier()); }
-
- void testJavaEmpty1() { testEmpty1(getJavaSupplier()); }
-
- void testJavaEmpty2() { testEmpty2(getJavaSupplier()); }
-
- void testJavaFull() { testFull(getJavaSupplier()); }
-
- CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(testCppEmpty1);
- CPPUNIT_TEST(testCppEmpty2);
- CPPUNIT_TEST(testCppFull);
- CPPUNIT_TEST(testJavaEmpty1);
- CPPUNIT_TEST(testJavaEmpty2);
- CPPUNIT_TEST(testJavaFull);
- CPPUNIT_TEST_SUITE_END();
-
-private:
+protected:
css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
getCppSupplier() const;
@@ -209,12 +186,12 @@ private:
css::uno::Reference< css::uno::XComponentContext > m_context;
};
-void Test::setUp() {
+void Test::SetUp() {
m_context = cppu::defaultBootstrap_InitialComponentContext();
- CPPUNIT_ASSERT(m_context.is());
+ ASSERT_TRUE(m_context.is());
}
-void Test::tearDown() {
+void Test::TearDown() {
css::uno::Reference< css::lang::XComponent >(
m_context, css::uno::UNO_QUERY_THROW)->dispose();
}
@@ -237,13 +214,13 @@ void Test::testEmpty1(
{
css::uno::Reference< css::lang::XComponent > empty1(
supplier->getEmpty1(), css::uno::UNO_QUERY_THROW);
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
!css::uno::Reference< css::beans::XPropertySet >(
empty1, css::uno::UNO_QUERY).is());
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
!css::uno::Reference< css::beans::XFastPropertySet >(
empty1, css::uno::UNO_QUERY).is());
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
!css::uno::Reference< css::beans::XPropertyAccess >(
empty1, css::uno::UNO_QUERY).is());
empty1->dispose();
@@ -257,29 +234,29 @@ void Test::testEmpty2(
supplier->getEmpty2(), css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::beans::XPropertySet > empty2p(
empty2, css::uno::UNO_QUERY);
- CPPUNIT_ASSERT(empty2p.is());
+ ASSERT_TRUE(empty2p.is());
css::uno::Reference< css::beans::XPropertySetInfo > info(
empty2p->getPropertySetInfo());
- CPPUNIT_ASSERT(info.is());
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_TRUE(info.is());
+ ASSERT_EQ(
static_cast< sal_Int32 >(0), info->getProperties().getLength());
try {
info->getPropertyByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")));
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
!info->hasPropertyByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any"))));
try {
empty2p->setPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")), css::uno::Any());
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
empty2p->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")));
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
rtl::Reference< BoundListener > boundListener1(new BoundListener);
empty2p->addPropertyChangeListener(rtl::OUString(), boundListener1.get());
@@ -295,27 +272,27 @@ void Test::testEmpty2(
empty2p->removeVetoableChangeListener(rtl::OUString(), vetoListener2.get());
css::uno::Reference< css::beans::XFastPropertySet > empty2f(
empty2, css::uno::UNO_QUERY);
- CPPUNIT_ASSERT(empty2f.is());
+ ASSERT_TRUE(empty2f.is());
try {
empty2f->setFastPropertyValue(-1, css::uno::Any());
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
empty2f->setFastPropertyValue(0, css::uno::Any());
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
empty2f->getFastPropertyValue(-1);
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
empty2f->getFastPropertyValue(0);
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
css::uno::Reference< css::beans::XPropertyAccess > empty2a(
empty2, css::uno::UNO_QUERY);
- CPPUNIT_ASSERT(empty2a.is());
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_TRUE(empty2a.is());
+ ASSERT_EQ(
static_cast< sal_Int32 >(0), empty2a->getPropertyValues().getLength());
empty2a->setPropertyValues(
css::uno::Sequence< css::beans::PropertyValue >());
@@ -328,17 +305,17 @@ void Test::testEmpty2(
vs[0].State = css::beans::PropertyState_DIRECT_VALUE;
try {
empty2a->setPropertyValues(vs);
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
- CPPUNIT_ASSERT_EQUAL(0, boundListener1->count());
- CPPUNIT_ASSERT_EQUAL(0, boundListener2->count());
- CPPUNIT_ASSERT_EQUAL(0, vetoListener1->count());
- CPPUNIT_ASSERT_EQUAL(0, vetoListener2->count());
+ ASSERT_EQ(0, boundListener1->count());
+ ASSERT_EQ(0, boundListener2->count());
+ ASSERT_EQ(0, vetoListener1->count());
+ ASSERT_EQ(0, vetoListener2->count());
empty2->dispose();
- CPPUNIT_ASSERT_EQUAL(2, boundListener1->count());
- CPPUNIT_ASSERT_EQUAL(0, boundListener2->count());
- CPPUNIT_ASSERT_EQUAL(2, vetoListener1->count());
- CPPUNIT_ASSERT_EQUAL(0, vetoListener2->count());
+ ASSERT_EQ(2, boundListener1->count());
+ ASSERT_EQ(0, boundListener2->count());
+ ASSERT_EQ(2, vetoListener1->count());
+ ASSERT_EQ(0, vetoListener2->count());
empty2p->removePropertyChangeListener(
rtl::OUString(), boundListener1.get());
empty2p->removePropertyChangeListener(
@@ -359,10 +336,10 @@ void Test::testEmpty2(
rtl::OUString(),
css::uno::Reference< css::beans::XVetoableChangeListener >());
} catch (css::uno::RuntimeException &) {}
- CPPUNIT_ASSERT_EQUAL(3, boundListener1->count());
- CPPUNIT_ASSERT_EQUAL(1, boundListener2->count());
- CPPUNIT_ASSERT_EQUAL(3, vetoListener1->count());
- CPPUNIT_ASSERT_EQUAL(1, vetoListener2->count());
+ ASSERT_EQ(3, boundListener1->count());
+ ASSERT_EQ(1, boundListener2->count());
+ ASSERT_EQ(3, vetoListener1->count());
+ ASSERT_EQ(1, vetoListener2->count());
}
void Test::testFull(
@@ -373,27 +350,27 @@ void Test::testFull(
supplier->getFull(), css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::beans::XPropertySet > fullp(
full, css::uno::UNO_QUERY);
- CPPUNIT_ASSERT(fullp.is());
+ ASSERT_TRUE(fullp.is());
css::uno::Reference< css::beans::XPropertySetInfo > info(
fullp->getPropertySetInfo());
- CPPUNIT_ASSERT(info.is());
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_TRUE(info.is());
+ ASSERT_EQ(
static_cast< sal_Int32 >(3), info->getProperties().getLength());
css::beans::Property prop(
info->getPropertyByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First"))));
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), prop.Name);
- CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(0), prop.Handle);
- CPPUNIT_ASSERT_EQUAL(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type);
- CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int16 >(0), prop.Attributes);
+ ASSERT_EQ(static_cast< sal_Int32 >(0), prop.Handle);
+ ASSERT_EQ(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type);
+ ASSERT_EQ(static_cast< sal_Int16 >(0), prop.Attributes);
prop = info->getPropertyByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")));
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), prop.Name);
- CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(1), prop.Handle);
- CPPUNIT_ASSERT_EQUAL(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type);
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(static_cast< sal_Int32 >(1), prop.Handle);
+ ASSERT_EQ(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type);
+ ASSERT_EQ(
static_cast< sal_Int16 >(
css::beans::PropertyAttribute::MAYBEVOID
| css::beans::PropertyAttribute::BOUND
@@ -405,117 +382,117 @@ void Test::testFull(
try {
info->getPropertyByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")));
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
prop = info->getPropertyByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")));
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), prop.Name);
- CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(3), prop.Handle);
- CPPUNIT_ASSERT_EQUAL(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type);
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(static_cast< sal_Int32 >(3), prop.Handle);
+ ASSERT_EQ(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type);
+ ASSERT_EQ(
static_cast< sal_Int16 >(css::beans::PropertyAttribute::OPTIONAL),
prop.Attributes);
try {
info->getPropertyByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first")));
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
info->hasPropertyByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First"))));
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
info->hasPropertyByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))));
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
!info->hasPropertyByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third"))));
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
info->hasPropertyByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth"))));
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
!info->hasPropertyByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first"))));
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(
css::uno::makeAny(static_cast< sal_Int32 >(0)),
fullp->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First"))));
fullp->setPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")),
css::uno::makeAny(static_cast< sal_Int32 >(-100)));
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(
css::uno::makeAny(static_cast< sal_Int32 >(-100)),
fullp->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First"))));
css::uno::Any voidAny;
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(
voidAny,
fullp->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))));
fullp->setPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")),
css::uno::makeAny(static_cast< sal_Int32 >(100)));
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(
css::uno::makeAny(static_cast< sal_Int32 >(100)),
fullp->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))));
- CPPUNIT_ASSERT(full->getSecond().Value.Value.IsPresent);
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_TRUE(full->getSecond().Value.Value.IsPresent);
+ ASSERT_EQ(
static_cast< sal_Int32 >(100), full->getSecond().Value.Value.Value);
- CPPUNIT_ASSERT(!full->getSecond().Value.IsDefaulted);
- CPPUNIT_ASSERT(!full->getSecond().IsAmbiguous);
+ ASSERT_TRUE(!full->getSecond().Value.IsDefaulted);
+ ASSERT_TRUE(!full->getSecond().IsAmbiguous);
fullp->setPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")),
css::uno::Any());
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(
voidAny,
fullp->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))));
- CPPUNIT_ASSERT(!full->getSecond().Value.Value.IsPresent);
- CPPUNIT_ASSERT(!full->getSecond().Value.IsDefaulted);
- CPPUNIT_ASSERT(!full->getSecond().IsAmbiguous);
+ ASSERT_TRUE(!full->getSecond().Value.Value.IsPresent);
+ ASSERT_TRUE(!full->getSecond().Value.IsDefaulted);
+ ASSERT_TRUE(!full->getSecond().IsAmbiguous);
try {
fullp->setPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
css::uno::makeAny(static_cast< sal_Int32 >(100)));
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
fullp->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")));
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
fullp->setPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")),
css::uno::makeAny(static_cast< sal_Int32 >(100)));
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
fullp->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")));
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
fullp->setPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first")),
css::uno::Any());
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
fullp->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first")));
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
css::uno::Reference< css::beans::XFastPropertySet > fullf(
full, css::uno::UNO_QUERY);
- CPPUNIT_ASSERT(fullf.is());
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_TRUE(fullf.is());
+ ASSERT_EQ(
css::uno::makeAny(static_cast< sal_Int32 >(-100)),
fullf->getFastPropertyValue(0));
fullf->setFastPropertyValue(
0, css::uno::makeAny(static_cast< sal_Int32 >(0)));
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(
css::uno::makeAny(static_cast< sal_Int32 >(0)),
fullf->getFastPropertyValue(0));
try {
@@ -526,43 +503,43 @@ void Test::testFull(
} catch (css::beans::UnknownPropertyException &) {}
css::uno::Reference< css::beans::XPropertyAccess > fulla(
full, css::uno::UNO_QUERY);
- CPPUNIT_ASSERT(fulla.is());
+ ASSERT_TRUE(fulla.is());
css::uno::Sequence< css::beans::PropertyValue > vs(
fulla->getPropertyValues());
- CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(2), vs.getLength());
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(static_cast< sal_Int32 >(2), vs.getLength());
+ ASSERT_EQ(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vs[0].Name);
- CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(0), vs[0].Handle);
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(static_cast< sal_Int32 >(0), vs[0].Handle);
+ ASSERT_EQ(
css::uno::makeAny(static_cast< sal_Int32 >(0)), vs[0].Value);
- CPPUNIT_ASSERT_EQUAL(css::beans::PropertyState_DIRECT_VALUE, vs[0].State);
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(css::beans::PropertyState_DIRECT_VALUE, vs[0].State);
+ ASSERT_EQ(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vs[1].Name);
- CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(1), vs[1].Handle);
- CPPUNIT_ASSERT_EQUAL(voidAny, vs[1].Value);
- CPPUNIT_ASSERT_EQUAL(css::beans::PropertyState_DIRECT_VALUE, vs[1].State);
+ ASSERT_EQ(static_cast< sal_Int32 >(1), vs[1].Handle);
+ ASSERT_EQ(voidAny, vs[1].Value);
+ ASSERT_EQ(css::beans::PropertyState_DIRECT_VALUE, vs[1].State);
vs[0].Value <<= static_cast< sal_Int32 >(-100);
vs[1].Value <<= static_cast< sal_Int32 >(100);
vs[1].State = css::beans::PropertyState_AMBIGUOUS_VALUE;
fulla->setPropertyValues(vs);
vs = fulla->getPropertyValues();
- CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(2), vs.getLength());
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(static_cast< sal_Int32 >(2), vs.getLength());
+ ASSERT_EQ(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vs[0].Name);
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(
css::uno::makeAny(static_cast< sal_Int32 >(-100)), vs[0].Value);
- CPPUNIT_ASSERT_EQUAL(css::beans::PropertyState_DIRECT_VALUE, vs[0].State);
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(css::beans::PropertyState_DIRECT_VALUE, vs[0].State);
+ ASSERT_EQ(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vs[1].Name);
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(
css::uno::makeAny(static_cast< sal_Int32 >(100)), vs[1].Value);
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_EQ(
css::beans::PropertyState_AMBIGUOUS_VALUE, vs[1].State);
- CPPUNIT_ASSERT(full->getSecond().Value.Value.IsPresent);
- CPPUNIT_ASSERT_EQUAL(
+ ASSERT_TRUE(full->getSecond().Value.Value.IsPresent);
+ ASSERT_EQ(
static_cast< sal_Int32 >(100), full->getSecond().Value.Value.Value);
- CPPUNIT_ASSERT(!full->getSecond().Value.IsDefaulted);
- CPPUNIT_ASSERT(full->getSecond().IsAmbiguous);
+ ASSERT_TRUE(!full->getSecond().Value.IsDefaulted);
+ ASSERT_TRUE(full->getSecond().IsAmbiguous);
css::uno::Reference< css::beans::XPropertyChangeListener > boundListener(
new BoundListener);
fullp->addPropertyChangeListener(
@@ -577,13 +554,13 @@ void Test::testFull(
fullp->addPropertyChangeListener(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
boundListener);
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
fullp->removePropertyChangeListener(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
boundListener);
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
fullp->addPropertyChangeListener(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), boundListener);
@@ -593,13 +570,13 @@ void Test::testFull(
fullp->addPropertyChangeListener(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")),
boundListener);
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
fullp->removePropertyChangeListener(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")),
boundListener);
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
css::uno::Reference< css::beans::XVetoableChangeListener > vetoListener(
new VetoListener);
@@ -615,13 +592,13 @@ void Test::testFull(
fullp->addVetoableChangeListener(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
vetoListener);
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
fullp->removeVetoableChangeListener(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
vetoListener);
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
fullp->addVetoableChangeListener(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), vetoListener);
@@ -631,18 +608,36 @@ void Test::testFull(
fullp->addVetoableChangeListener(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")),
vetoListener);
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
try {
fullp->removeVetoableChangeListener(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")),
vetoListener);
- CPPUNIT_FAIL("exception expected");
+ FAIL() << "exception expected";
} catch (css::beans::UnknownPropertyException &) {}
}
-CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+TEST_F(Test, testCppEmpty1) { testEmpty1(getCppSupplier()); }
+
+TEST_F(Test, testCppEmpty2) { testEmpty2(getCppSupplier()); }
+TEST_F(Test, testCppFull) { testFull(getCppSupplier()); }
+
+TEST_F(Test, testJavaEmpty1) { testEmpty1(getJavaSupplier()); }
+
+TEST_F(Test, testJavaEmpty2) { testEmpty2(getJavaSupplier()); }
+
+TEST_F(Test, testJavaFull) { testFull(getJavaSupplier()); }
+
+
+
+}
+
+int main(int argc, char **argv)
+{
+ osl_setCommandArgs(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
-CPPUNIT_PLUGIN_IMPLEMENT();
commit 201e6e9f5459adf7acac04f64a8b5de3944e1943
Author: Damjan Jovanovic <damjan at apache.org>
Date: Sun Sep 20 10:33:32 2015 +0000
#i125003# migrate main/sal/qa/osl/security from cppunit to Google Test.
diff --git a/sal/qa/osl/security/makefile.mk b/sal/qa/osl/security/makefile.mk
index 08ebad5..1b668aa 100644
--- a/sal/qa/osl/security/makefile.mk
+++ b/sal/qa/osl/security/makefile.mk
@@ -32,29 +32,33 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+ @echo unit tests are disabled. Nothing to do.
+
+.ELSE
+
CFLAGS+= $(LFS_CFLAGS)
CXXFLAGS+= $(LFS_CFLAGS)
# BEGIN ----------------------------------------------------------------
# auto generated Target:Security by codegen.pl
-SHL1OBJS= \
+APP1OBJS= \
$(SLO)$/osl_Security.obj
-SHL1TARGET= osl_Security
-SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
+APP1TARGET= osl_Security
+APP1STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB)
.IF "$(GUI)" == "WNT"
-SHL1STDLIBS+= $(ADVAPI32LIB)
+APP1STDLIBS+= $(ADVAPI32LIB)
.ENDIF
-SHL1IMPLIB= i$(SHL1TARGET)
-SHL1DEF= $(MISC)$/$(SHL1TARGET).def
-
-DEF1NAME =$(SHL1TARGET)
-SHL1VERSIONMAP= $(PRJ)$/qa$/export.map
+APP1RPATH = NONE
+APP1TEST = enabled
# auto generated Target:Security
# END ------------------------------------------------------------------
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
-.INCLUDE : _cppunit.mk
+
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"
\ No newline at end of file
diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index 7c8db13..415c9bc 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -41,8 +41,8 @@ using namespace rtl;
*/
inline void printBool( sal_Bool bOk )
{
- //t_print("#printBool# " );
- ( sal_True == bOk ) ? t_print("TRUE!\n" ): t_print("FALSE!\n" );
+ //printf("#printBool# " );
+ ( sal_True == bOk ) ? printf("TRUE!\n" ): printf("FALSE!\n" );
}
/** print a UNI_CODE String.
@@ -51,9 +51,9 @@ inline void printUString( const ::rtl::OUString & str )
{
rtl::OString aString;
- //t_print("#printUString_u# " );
+ //printf("#printUString_u# " );
aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
- t_print("%s\n", aString.getStr( ) );
+ printf("%s\n", aString.getStr( ) );
}
@@ -67,24 +67,19 @@ namespace osl_Security
/** testing the method:
Security()
*/
- class ctors : public CppUnit::TestFixture
+ class ctors : public ::testing::Test
{
public:
sal_Bool bRes, bRes1;
- void ctors_001( )
- {
- ::osl::Security aSec;
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: create a security its handle should not be NULL.",
- aSec.getHandle( ) != NULL );
- }
-
- CPPUNIT_TEST_SUITE( ctors );
- CPPUNIT_TEST( ctors_001 );
- CPPUNIT_TEST_SUITE_END( );
}; // class ctors
+ TEST_F(ctors, ctors_001)
+ {
+ ::osl::Security aSec;
+
+ ASSERT_TRUE(aSec.getHandle( ) != NULL) << "#test comment#: create a security its handle should not be NULL.";
+ }
/** testing the methods:
inline sal_Bool SAL_CALL logonUser(const ::rtl::OUString& strName,
@@ -93,7 +88,7 @@ namespace osl_Security
const ::rtl::OUString & strPasswd,
const ::rtl::OUString & strFileServer);
*/
- class logonUser : public CppUnit::TestFixture
+ class logonUser : public ::testing::Test
{
public:
sal_Bool bRes;
@@ -103,8 +98,7 @@ namespace osl_Security
::osl::Security aSec;
bRes = aSec.logonUser( aLogonUser, aLogonPasswd );
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: check logon user through forwarded user name, pwd, passed in (UNX), failed in (W32).",
- ( sal_True == bRes ) );
+ ASSERT_TRUE(( sal_True == bRes )) << "#test comment#: check logon user through forwarded user name, pwd, passed in (UNX), failed in (W32).";
}
void logonUser_user_pwd_server( )
@@ -112,258 +106,200 @@ namespace osl_Security
::osl::Security aSec;
bRes = aSec.logonUser( aLogonUser, aLogonPasswd, aFileServer );
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: check logon user through forwarded user name, pwd and server name, failed in (UNX)(W32).",
- ( sal_True == bRes ) );
+ ASSERT_TRUE(( sal_True == bRes )) << "#test comment#: check logon user through forwarded user name, pwd and server name, failed in (UNX)(W32).";
}
+ }; // class logonUser
-
- CPPUNIT_TEST_SUITE( logonUser );
+ TEST_F(logonUser, logonUser_001)
+ {
if ( !aStringForward.equals( aNullURL ) && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 && ( aStringForward.indexOf( ( sal_Unicode ) ' ' ) == aStringForward.lastIndexOf( ( sal_Unicode ) ' ' ) ) )
/// if user name and passwd are forwarded
{
- CPPUNIT_TEST( logonUser_user_pwd );
+ logonUser_user_pwd();
}
+ }
+
+ TEST_F(logonUser, logonUser_002)
+ {
if ( !aStringForward.equals( aNullURL ) && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 && ( aStringForward.indexOf( ( sal_Unicode ) ' ' ) != aStringForward.lastIndexOf( ( sal_Unicode ) ' ' ) ) )
/// if user name and passwd and file server are forwarded
{
- CPPUNIT_TEST( logonUser_user_pwd_server );
+ logonUser_user_pwd_server();
}
- CPPUNIT_TEST_SUITE_END( );
- }; // class logonUser
-
+ }
/** testing the method:
inline sal_Bool Security::getUserIdent( rtl::OUString& strIdent) const
*/
- class getUserIdent : public CppUnit::TestFixture
+ class getUserIdent : public ::testing::Test
{
public:
sal_Bool bRes, bRes1;
+ }; // class getUserIdent
- void getUserIdent_001( )
- {
- ::osl::Security aSec;
- ::rtl::OUString strID;
- bRes = aSec.getUserIdent( strID );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: get UserID and compare it with names got at the beginning of the test.",
- ( sal_True == strUserID.equals( strID ) ) && ( sal_True == bRes ));
- }
+ TEST_F(getUserIdent, getUserIdent_001)
+ {
+ ::osl::Security aSec;
+ ::rtl::OUString strID;
+ bRes = aSec.getUserIdent( strID );
- CPPUNIT_TEST_SUITE( getUserIdent );
- CPPUNIT_TEST( getUserIdent_001 );
- CPPUNIT_TEST_SUITE_END( );
- }; // class getUserIdent
+ ASSERT_TRUE(( sal_True == strUserID.equals( strID ) ) && ( sal_True == bRes )) << "#test comment#: get UserID and compare it with names got at the beginning of the test.";
+ }
/** testing the method:
inline sal_Bool SAL_CALL getUserName( ::rtl::OUString& strName) const;
*/
- class getUserName : public CppUnit::TestFixture
+ class getUserName : public ::testing::Test
{
public:
sal_Bool bRes, bRes1;
+ }; // class getUserName
- void getUserName_001( )
- {
- ::osl::Security aSec;
+ TEST_F(getUserName, getUserName_001)
+ {
+ ::osl::Security aSec;
#ifdef WNT
- ::rtl::OUString strName( strUserName ), strGetName;
+ ::rtl::OUString strName( strUserName ), strGetName;
#else
- ::rtl::OUString strName( strUserName ), strGetName;
+ ::rtl::OUString strName( strUserName ), strGetName;
#endif
- bRes = aSec.getUserName( strGetName );
+ bRes = aSec.getUserName( strGetName );
- sal_Int32 nPos = -1;
- if (strName.getLength() > 0)
- {
- nPos = strGetName.indexOf(strName);
- }
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: get UserName and compare it with names got at the beginning of the test.",
- ( nPos >= 0 ) && ( sal_True == bRes ) );
+ sal_Int32 nPos = -1;
+ if (strName.getLength() > 0)
+ {
+ nPos = strGetName.indexOf(strName);
}
-
- CPPUNIT_TEST_SUITE( getUserName );
- CPPUNIT_TEST( getUserName_001 );
- CPPUNIT_TEST_SUITE_END( );
- }; // class getUserName
-
-
+ ASSERT_TRUE(( nPos >= 0 ) && ( sal_True == bRes )) << "#test comment#: get UserName and compare it with names got at the beginning of the test.";
+ }
/** testing the method:
inline sal_Bool SAL_CALL getHomeDir( ::rtl::OUString& strDirectory) const;
*/
- class getHomeDir : public CppUnit::TestFixture
+ class getHomeDir : public ::testing::Test
{
public:
sal_Bool bRes, bRes1;
+ }; // class getHomeDir
- void getHomeDir_001( )
- {
- ::osl::Security aSec;
- ::rtl::OUString strHome;
- bRes = aSec.getHomeDir( strHome );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: getHomeDir and compare it with the info we get at the beginning.",
- ( sal_True == strHomeDirectory.equals( strHome ) ) && ( sal_True == bRes ) );
- }
+ TEST_F(getHomeDir, getHomeDir_001)
+ {
+ ::osl::Security aSec;
+ ::rtl::OUString strHome;
+ bRes = aSec.getHomeDir( strHome );
- CPPUNIT_TEST_SUITE( getHomeDir );
- CPPUNIT_TEST( getHomeDir_001 );
- CPPUNIT_TEST_SUITE_END( );
- }; // class getHomeDir
+ ASSERT_TRUE(( sal_True == strHomeDirectory.equals( strHome ) ) && ( sal_True == bRes )) << "#test comment#: getHomeDir and compare it with the info we get at the beginning.";
+ }
/** testing the method:
inline sal_Bool Security::getConfigDir( rtl::OUString& strDirectory ) const
*/
- class getConfigDir : public CppUnit::TestFixture
+ class getConfigDir : public ::testing::Test
{
public:
sal_Bool bRes, bRes1;
+ }; // class getConfigDir
- void getConfigDir_001( )
- {
- ::osl::Security aSec;
- ::rtl::OUString strConfig;
- bRes = aSec.getConfigDir( strConfig );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: getHomeDir and compare it with the info we get at the beginning.",
- ( sal_True == strConfigDirectory.equals( strConfig ) ) && ( sal_True == bRes ) );
- }
+ TEST_F(getConfigDir, getConfigDir_001)
+ {
+ ::osl::Security aSec;
+ ::rtl::OUString strConfig;
+ bRes = aSec.getConfigDir( strConfig );
- CPPUNIT_TEST_SUITE( getConfigDir );
- CPPUNIT_TEST( getConfigDir_001 );
- CPPUNIT_TEST_SUITE_END( );
- }; // class getConfigDir
+ ASSERT_TRUE(( sal_True == strConfigDirectory.equals( strConfig ) ) && ( sal_True == bRes )) << "#test comment#: getHomeDir and compare it with the info we get at the beginning.";
+ }
/** testing the method:
inline sal_Bool SAL_CALL isAdministrator() const;
*/
- class isAdministrator : public CppUnit::TestFixture
+ class isAdministrator : public ::testing::Test
{
public:
sal_Bool bRes;
+ }; // class isAdministrator
- void isAdministrator_001( )
- {
- ::osl::Security aSec;
- bRes = aSec.isAdministrator( );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: check if the user is administrator at beginning, compare here.",
- bRes == isAdmin );
- }
+ TEST_F(isAdministrator, isAdministrator_001)
+ {
+ ::osl::Security aSec;
+ bRes = aSec.isAdministrator( );
- CPPUNIT_TEST_SUITE( isAdministrator );
- CPPUNIT_TEST( isAdministrator_001 );
- CPPUNIT_TEST_SUITE_END( );
- }; // class isAdministrator
+ ASSERT_TRUE(bRes == isAdmin) << "#test comment#: check if the user is administrator at beginning, compare here.";
+ }
/** testing the method:
inline oslSecurity getHandle() const;
*/
- class getHandle : public CppUnit::TestFixture
+ class getHandle : public ::testing::Test
{
public:
sal_Bool bRes;
-
- void getHandle_001( )
- {
- ::osl::Security aSec;
- bRes = aSec.isAdministrator( ) == osl_isAdministrator( aSec.getHandle( ) );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: use getHandle function to call C API.",
- bRes == sal_True );
- }
-
- CPPUNIT_TEST_SUITE( getHandle );
- CPPUNIT_TEST( getHandle_001 );
- CPPUNIT_TEST_SUITE_END( );
}; // class getHandle
-
- class UserProfile : public CppUnit::TestFixture
+ TEST_F(getHandle, getHandle_001)
{
- public:
-
- void loadUserProfile( )
- {
- ::osl::Security aSec;
- sal_Bool bValue = osl_loadUserProfile(aSec.getHandle());
-
- CPPUNIT_ASSERT_MESSAGE( "empty function.", bValue == sal_False );
- }
-
- void unloadUserProfile( )
- {
- ::osl::Security aSec;
- osl_unloadUserProfile(aSec.getHandle());
- CPPUNIT_ASSERT_MESSAGE( "empty function.", sal_True );
- }
+ ::osl::Security aSec;
+ bRes = aSec.isAdministrator( ) == osl_isAdministrator( aSec.getHandle( ) );
- CPPUNIT_TEST_SUITE( UserProfile );
- CPPUNIT_TEST( loadUserProfile );
- CPPUNIT_TEST( unloadUserProfile );
- CPPUNIT_TEST_SUITE_END( );
- }; // class UserProfile
+ ASSERT_TRUE(bRes == sal_True) << "#test comment#: use getHandle function to call C API.";
+ }
- class loginUserOnFileServer : public CppUnit::TestFixture
+ class UserProfile : public ::testing::Test
{
public:
+ }; // class UserProfile
- void loginUserOnFileServer_001( )
- {
- rtl::OUString suUserName;
- rtl::OUString suPassword;
- rtl::OUString suFileServer;
- ::osl::Security aSec;
- oslSecurity pSec = aSec.getHandle();
+ TEST_F(UserProfile, loadUserProfile)
+ {
+ ::osl::Security aSec;
+ sal_Bool bValue = osl_loadUserProfile(aSec.getHandle());
- oslSecurityError erg = osl_loginUserOnFileServer(suUserName.pData, suPassword.pData, suFileServer.pData, &pSec);
+ ASSERT_TRUE(bValue == sal_False) << "empty function.";
+ }
- CPPUNIT_ASSERT_MESSAGE( "empty function.", erg == osl_Security_E_UserUnknown );
- }
+ TEST_F(UserProfile, unloadUserProfile)
+ {
+ ::osl::Security aSec;
+ osl_unloadUserProfile(aSec.getHandle());
+ ASSERT_TRUE(sal_True) << "empty function.";
+ }
- CPPUNIT_TEST_SUITE( loginUserOnFileServer );
- CPPUNIT_TEST( loginUserOnFileServer_001 );
- CPPUNIT_TEST_SUITE_END( );
+ class loginUserOnFileServer : public ::testing::Test
+ {
+ public:
}; // class loginUserOnFileServer
-// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Security::ctors, "osl_Security");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Security::logonUser, "osl_Security");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Security::getUserIdent, "osl_Security");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Security::getUserName, "osl_Security");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Security::getHomeDir, "osl_Security");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Security::getConfigDir, "osl_Security");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Security::isAdministrator, "osl_Security");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Security::getHandle, "osl_Security");
-
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Security::UserProfile, "osl_Security");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Security::loginUserOnFileServer, "osl_Security");
+ TEST_F(loginUserOnFileServer, loginUserOnFileServer_001)
+ {
+ rtl::OUString suUserName;
+ rtl::OUString suPassword;
+ rtl::OUString suFileServer;
+ ::osl::Security aSec;
+ oslSecurity pSec = aSec.getHandle();
-// -----------------------------------------------------------------------------
+ oslSecurityError erg = osl_loginUserOnFileServer(suUserName.pData, suPassword.pData, suFileServer.pData, &pSec);
+
+ ASSERT_TRUE(erg == osl_Security_E_UserUnknown) << "empty function.";
+ }
} // namespace osl_Security
// -----------------------------------------------------------------------------
-// this macro creates an empty function, which will called by the RegisterAllFunctions()
-// to let the user the possibility to also register some functions by hand.
-
/** to do some initialized work, we replace the NOADDITIONAL macro with the initialize work which
get current user name, .
*/
-void RegisterAdditionalFunctions(FktRegFuncPtr)
+int main(int argc, char **argv)
{
/// start message
- t_print("#Initializing ...\n" );
- t_print("#\n#logonUser function need root/Administrator account to test.\n" );
- t_print("#You can test by login with root/Administrator, and excute:\n" );
- t_print("#testshl2 -forward \"username password\" ../../../wntmsci9/bin/Security.dll\n" );
- t_print("# where username and password are forwarded account info.\n" );
- t_print("#if no text forwarded, this function will be skipped.\n" );
+ printf("#Initializing ...\n" );
+ printf("#\n#logonUser function need root/Administrator account to test.\n" );
+ printf("#You can test by login with root/Administrator, and excute:\n" );
+ printf("#testshl2 -forward \"username password\" ../../../wntmsci9/bin/Security.dll\n" );
+ printf("# where username and password are forwarded account info.\n" );
+ printf("#if no text forwarded, this function will be skipped.\n" );
/// get system information
#if ( defined UNX ) || ( defined OS2 )
@@ -371,7 +307,7 @@ void RegisterAdditionalFunctions(FktRegFuncPtr)
struct passwd* pw;
- CPPUNIT_ASSERT_MESSAGE( "getpwuid: no password entry\n",( pw = getpwuid( getuid() ) ) != NULL );
+ EXPECT_TRUE(( pw = getpwuid( getuid() ) ) != NULL) << "getpwuid: no password entry\n";
/// get user ID;
strUserID = ::rtl::OUString::valueOf( ( sal_Int32 )getuid( ) );
@@ -380,8 +316,7 @@ void RegisterAdditionalFunctions(FktRegFuncPtr)
strUserName = ::rtl::OUString::createFromAscii( pw->pw_name );
/// get home directory;
- CPPUNIT_ASSERT_MESSAGE( "#Convert from system path to URL failed.",
- ::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( pw->pw_dir ), strHomeDirectory ) );
+ EXPECT_TRUE(::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( pw->pw_dir ), strHomeDirectory )) << "#Convert from system path to URL failed.";
/// get config directory;
strConfigDirectory = strHomeDirectory.copy(0);
@@ -420,15 +355,13 @@ void RegisterAdditionalFunctions(FktRegFuncPtr)
lRet = RegQueryValueEx(hRegKey, "AppData", NULL, &Type, ( unsigned char * )PathA, ( unsigned long * )&lSize);
if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _access( PathA, 0 ) == 0 ) )
{
- CPPUNIT_ASSERT_MESSAGE( "#Convert from system path to URL failed.",
- ::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( PathA ), strConfigDirectory ) );
+ EXPECT_TRUE(::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( PathA ), strConfigDirectory )) << "#Convert from system path to URL failed.";
}
lRet = RegQueryValueEx(hRegKey, "Personal", NULL, &Type, ( unsigned char * )PathA, ( unsigned long * )&lSize);
if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _access( PathA, 0 ) == 0 ) )
{
- CPPUNIT_ASSERT_MESSAGE( "#Convert from system path to URL failed.",
- ::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( PathA ), strHomeDirectory ) );
+ EXPECT_TRUE(::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( PathA ), strHomeDirectory )) << "#Convert from system path to URL failed.";
}
RegCloseKey(hRegKey);
@@ -451,11 +384,11 @@ void RegisterAdditionalFunctions(FktRegFuncPtr)
// Create buffers for the SID and the domain name.
PSID pSid = (PSID) new WIN_BYTE[dwSidBufferSize];
- CPPUNIT_ASSERT_MESSAGE("# creating SID buffer failed.\n", pSid!= NULL );
+ EXPECT_TRUE(pSid!= NULL) << "# creating SID buffer failed.\n";
memset( pSid, 0, dwSidBufferSize);
wszDomainName = new WCHAR[dwDomainBufferSize];
- CPPUNIT_ASSERT_MESSAGE("# creating Domain name buffer failed.\n", wszDomainName != NULL );
+ EXPECT_TRUE(wszDomainName != NULL) << "# creating Domain name buffer failed.\n";
memset(wszDomainName, 0, dwDomainBufferSize*sizeof(WCHAR));
// Obtain the SID for the account name passed.
@@ -489,7 +422,7 @@ void RegisterAdditionalFunctions(FktRegFuncPtr)
wprintf(L"# The SID buffer was too small. It will be reallocated.\n");
FreeSid( pSid);
pSid = (PSID) new WIN_BYTE[cbSid];
- CPPUNIT_ASSERT_MESSAGE("# re-creating SID buffer failed.\n", pSid!= NULL );
+ EXPECT_TRUE(pSid!= NULL) << "# re-creating SID buffer failed.\n";
memset( pSid, 0, cbSid);
dwSidBufferSize = cbSid;
}
@@ -499,7 +432,7 @@ void RegisterAdditionalFunctions(FktRegFuncPtr)
wprintf(L"# The domain name buffer was too small. It will be reallocated.\n");
delete [] wszDomainName;
wszDomainName = new WCHAR[cchDomainName];
- CPPUNIT_ASSERT_MESSAGE("# re-creating domain name buffer failed.\n", wszDomainName!= NULL );
+ EXPECT_TRUE(wszDomainName!= NULL) << "# re-creating domain name buffer failed.\n";
memset(wszDomainName, 0, cchDomainName*sizeof(WCHAR));
dwDomainBufferSize = cchDomainName;
}
@@ -593,43 +526,43 @@ void RegisterAdditionalFunctions(FktRegFuncPtr)
#endif
/// print the information.
- t_print("#\n#Retrived system information is below:\n");
+ printf("#\n#Retrived system information is below:\n");
- t_print("Computer Name: ");
+ printf("Computer Name: ");
if ( strComputerName == aNullURL )
- t_print(" Not retrived\n" );
+ printf(" Not retrived\n" );
else
printUString( strComputerName );
- t_print("Current User Name: ");
+ printf("Current User Name: ");
if ( strUserName == aNullURL )
- t_print(" Not retrived\n" );
+ printf(" Not retrived\n" );
else
printUString( strUserName );
- t_print("Current User Home Directory:");
+ printf("Current User Home Directory:");
if ( strHomeDirectory == aNullURL )
- t_print(" Not retrived\n" );
+ printf(" Not retrived\n" );
else
printUString( strHomeDirectory );
- t_print("Current Config Directory: ");
+ printf("Current Config Directory: ");
if ( strConfigDirectory == aNullURL )
- t_print(" Not retrived\n" );
+ printf(" Not retrived\n" );
else
printUString( strConfigDirectory );
- t_print("Current UserID: ");
+ printf("Current UserID: ");
if ( strUserID == aNullURL )
- t_print(" Not retrived\n" );
+ printf(" Not retrived\n" );
else
printUString( strUserID );
- t_print("Current User is");
+ printf("Current User is");
if ( isAdmin == sal_False )
- t_print(" NOT Administrator.\n" );
+ printf(" NOT Administrator.\n" );
else
- t_print(" Administrator.\n" );
+ printf(" Administrator.\n" );
/// get and display forwarded text if available.
@@ -642,33 +575,35 @@ void RegisterAdditionalFunctions(FktRegFuncPtr)
/// only forwarded two parameters, username and password.
{
aLogonUser = aStringForward.copy( 0, nFirstSpacePoint );
- t_print("\n#Forwarded username: ");
+ printf("\n#Forwarded username: ");
printUString( aLogonUser);
aLogonPasswd = aStringForward.copy( nFirstSpacePoint +1, aStringForward.getLength( ) - 1 );
- t_print("#Forwarded password: ");
- for ( int i = nFirstSpacePoint +1; i <= aStringForward.getLength( ) - 1; i++, t_print("*") );
- t_print("\n" );
+ printf("#Forwarded password: ");
+ for ( int i = nFirstSpacePoint +1; i <= aStringForward.getLength( ) - 1; i++, printf("*") );
+ printf("\n" );
}
else
/// forwarded three parameters, username, password and fileserver.
{
aLogonUser = aStringForward.copy( 0, nFirstSpacePoint );
- t_print("#Forwarded username: ");
+ printf("#Forwarded username: ");
printUString( aLogonUser);
aLogonPasswd = aStringForward.copy( nFirstSpacePoint +1, nLastSpacePoint );
- t_print("#Forwarded password: ");
- for ( int i = nFirstSpacePoint +1; i <= nLastSpacePoint; i++, t_print("*") );
- t_print("\n" );
+ printf("#Forwarded password: ");
+ for ( int i = nFirstSpacePoint +1; i <= nLastSpacePoint; i++, printf("*") );
+ printf("\n" );
aFileServer = aStringForward.copy( nLastSpacePoint +1, aStringForward.getLength( ) - 1 );
- t_print("#Forwarded FileServer: ");
+ printf("#Forwarded FileServer: ");
printUString( aFileServer );
}
}
- t_print("#\n#Initialization Done.\n" );
+ printf("#\n#Initialization Done.\n" );
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
diff --git a/sal/qa/osl/security/osl_Security_Const.h b/sal/qa/osl/security/osl_Security_Const.h
index f4ff7e2..f68839d 100644
--- a/sal/qa/osl/security/osl_Security_Const.h
+++ b/sal/qa/osl/security/osl_Security_Const.h
@@ -50,7 +50,7 @@
#include <pwd.h>
#endif
-#include <testshl/simpleheader.hxx>
+#include "gtest/gtest.h"
// LLA: #include <testshl2/cmdlinebits.hxx>
commit f2e9a481c2c5ec461434e93b1d41937dca30ce03
Author: Damjan Jovanovic <damjan at apache.org>
Date: Sun Sep 20 09:07:54 2015 +0000
#i125003# migrate main/sal/qa/systools from cppunit to Google Test.
diff --git a/sal/qa/systools/makefile.mk b/sal/qa/systools/makefile.mk
index 1ea5229..481a7b4 100644
--- a/sal/qa/systools/makefile.mk
+++ b/sal/qa/systools/makefile.mk
@@ -33,6 +33,12 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+ @echo unit tests are disabled. Nothing to do.
+
+.ELSE
+
CFLAGS+= $(LFS_CFLAGS)
CXXFLAGS+= $(LFS_CFLAGS)
@@ -40,27 +46,19 @@ CFLAGS+=/Ob0
# BEGIN ----------------------------------------------------------------
# auto generated Target:joblist by codegen.pl
-SHL1OBJS= \
+APP1OBJS= \
$(SLO)$/test_comtools.obj
-SHL1TARGET= test_comtools
-SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) uuid.lib
-
-SHL1IMPLIB= i$(SHL1TARGET)
-# SHL1DEF= $(MISC)$/$(SHL1TARGET).def
-
-DEF1NAME =$(SHL1TARGET)
-# DEF1EXPORTFILE= export.exp
-SHL1VERSIONMAP= $(PRJ)$/qa$/export.map
+APP1TARGET= test_comtools
+APP1STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB) uuid.lib
+APP1RPATH = NONE
+APP1TEST = enabled
# auto generated Target:joblist
# END ------------------------------------------------------------------
-#------------------------------- All object files -------------------------------
-# do this here, so we get right dependencies
-# SLOFILES=$(SHL1OBJS)
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
-.INCLUDE : _cppunit.mk
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"
diff --git a/sal/qa/systools/test_comtools.cxx b/sal/qa/systools/test_comtools.cxx
index 1a5de4a..cb5493f 100644
--- a/sal/qa/systools/test_comtools.cxx
+++ b/sal/qa/systools/test_comtools.cxx
@@ -26,7 +26,7 @@
#include "precompiled_sal.hxx"
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "gtest/gtest.h"
#include <systools/win32/comtools.hxx>
class COMObject : public IUnknown
@@ -99,148 +99,124 @@ void comObjectSource2(LPVOID* ppv)
namespace test_comtools
{
- class test_COMReference : public CppUnit::TestFixture
+ class test_COMReference : public ::testing::Test
{
+ };
- public:
- /// test of COMReference<IUnknown> r;
- void default_ctor()
- {
- sal::systools::COMReference<IUnknown> r;
- CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() == NULL);
- }
+ /// test of COMReference<IUnknown> r;
+ TEST_F(test_COMReference, default_ctor)
+ {
+ sal::systools::COMReference<IUnknown> r;
+ ASSERT_TRUE(r.get() == NULL) << "COMReference should be empty";
+ }
- void test_ctor_manual_AddRef()
- {
- COMObject* p = new COMObject;
- p->AddRef();
- sal::systools::COMReference<IUnknown> r(p, false);
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
- }
+ TEST_F(test_COMReference, test_ctor_manual_AddRef)
+ {
+ COMObject* p = new COMObject;
+ p->AddRef();
+ sal::systools::COMReference<IUnknown> r(p, false);
+ ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+ }
- void test_copy_ctor()
- {
- sal::systools::COMReference<IUnknown> r(comObjectSource());
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
- }
+ TEST_F(test_COMReference, test_copy_ctor)
+ {
+ sal::systools::COMReference<IUnknown> r(comObjectSource());
+ ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+ }
- void test_copy_assignment()
- {
- sal::systools::COMReference<IUnknown> r;
- CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() == NULL);
+ TEST_F(test_COMReference, test_copy_assignment)
+ {
+ sal::systools::COMReference<IUnknown> r;
+ ASSERT_TRUE(r.get() == NULL) << "COMReference should be empty";
- r = comObjectSource();
- CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() != NULL);
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
- }
+ r = comObjectSource();
+ ASSERT_TRUE(r.get() != NULL) << "COMReference should be empty";
+ ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+ }
- void test_ref_to_ref_assignment()
- {
- sal::systools::COMReference<IUnknown> r1 = comObjectSource();
- sal::systools::COMReference<IUnknown> r2 = r1;
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count 2 is expected", reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2);
- }
+ TEST_F(test_COMReference, test_ref_to_ref_assignment)
+ {
+ sal::systools::COMReference<IUnknown> r1 = comObjectSource();
+ sal::systools::COMReference<IUnknown> r2 = r1;
+ ASSERT_TRUE(reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2) << "Wrong reference count 2 is expected";
+ }
- void test_pointer_to_ref_assignment()
- {
- sal::systools::COMReference<IUnknown> r;
- r = new COMObject;
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
- }
+ TEST_F(test_COMReference, test_pointer_to_ref_assignment)
+ {
+ sal::systools::COMReference<IUnknown> r;
+ r = new COMObject;
+ ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+ }
- void test_pointer_to_ref_assignment2()
- {
- sal::systools::COMReference<IUnknown> r = comObjectSource();
- r = new COMObject;
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
- }
+ TEST_F(test_COMReference, test_pointer_to_ref_assignment2)
+ {
+ sal::systools::COMReference<IUnknown> r = comObjectSource();
+ r = new COMObject;
+ ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+ }
- void test_source_sink()
- {
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count, 0 is expected", comObjectSink(comObjectSource(), 0));
- }
+ TEST_F(test_COMReference, test_source_sink)
+ {
+ ASSERT_TRUE(comObjectSink(comObjectSource(), 0)) << "Wrong reference count, 0 is expected";
+ }
- void test_address_operator()
- {
- sal::systools::COMReference<IUnknown> r;
- comObjectSource2(reinterpret_cast<LPVOID*>(&r));
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count, 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
- }
+ TEST_F(test_COMReference, test_address_operator)
+ {
+ sal::systools::COMReference<IUnknown> r;
+ comObjectSource2(reinterpret_cast<LPVOID*>(&r));
+ ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count, 1 is expected";
+ }
+
+ TEST_F(test_COMReference, test_address_operator2)
+ {
+ sal::systools::COMReference<IUnknown> r1 = comObjectSource();
+ sal::systools::COMReference<IUnknown> r2 = r1;
+ ASSERT_TRUE(reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2) << "Wrong reference count 2 is expected";
+ comObjectSource2(reinterpret_cast<LPVOID*>(&r1));
+ ASSERT_TRUE(reinterpret_cast<COMObject*>(r1.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+ ASSERT_TRUE(reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+ }
+
+ TEST_F(test_COMReference, test_clear)
+ {
+ sal::systools::COMReference<IUnknown> r = comObjectSource();
+ ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+ r.clear();
+ ASSERT_TRUE(!r.is()) << "Expect reference to be empty";
+ }
- void test_address_operator2()
+ TEST_F(test_COMReference, test_query_interface)
+ {
+ try
{
sal::systools::COMReference<IUnknown> r1 = comObjectSource();
- sal::systools::COMReference<IUnknown> r2 = r1;
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count 2 is expected", reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2);
- comObjectSource2(reinterpret_cast<LPVOID*>(&r1));
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r1.get())->GetRefCount() == 1);
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 1);
+ sal::systools::COMReference<IUnknown> r2 = r1.QueryInterface<IUnknown>(IID_IUnknown);
+ ASSERT_TRUE(reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2) << "Wrong reference count, 2 is expected";
}
-
- void test_clear()
+ catch(sal::systools::ComError& ex)
{
- sal::systools::COMReference<IUnknown> r = comObjectSource();
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
- r.clear();
- CPPUNIT_ASSERT_MESSAGE("Expect reference to be empty", !r.is());
+ ASSERT_TRUE(false) << "Exception should not have been thrown";
}
+ }
- void test_query_interface()
+ TEST_F(test_COMReference, test_query_interface_throw)
+ {
+ try
{
- try
- {
- sal::systools::COMReference<IUnknown> r1 = comObjectSource();
- sal::systools::COMReference<IUnknown> r2 = r1.QueryInterface<IUnknown>(IID_IUnknown);
- CPPUNIT_ASSERT_MESSAGE("Wrong reference count, 2 is expected", reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2);
- }
- catch(sal::systools::ComError& ex)
- {
- CPPUNIT_ASSERT_MESSAGE("Exception should not have been thrown", false);
- }
+ sal::systools::COMReference<IUnknown> r1 = comObjectSource();
+ sal::systools::COMReference<IPersistFile> r2 = r1.QueryInterface<IPersistFile>(IID_IPersistFile);
}
-
- void test_query_interface_throw()
+ catch(sal::systools::ComError& ex)
{
- try
- {
- sal::systools::COMReference<IUnknown> r1 = comObjectSource();
- sal::systools::COMReference<IPersistFile> r2 = r1.QueryInterface<IPersistFile>(IID_IPersistFile);
- }
- catch(sal::systools::ComError& ex)
- {
- return;
- }
- CPPUNIT_ASSERT_MESSAGE("Exception should have been thrown", false);
+ return;
}
-
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(test_COMReference);
- CPPUNIT_TEST(default_ctor);
- CPPUNIT_TEST(test_ctor_manual_AddRef);
- CPPUNIT_TEST(test_copy_ctor);
- CPPUNIT_TEST(test_copy_assignment);
- CPPUNIT_TEST(test_ref_to_ref_assignment);
- CPPUNIT_TEST(test_pointer_to_ref_assignment);
- CPPUNIT_TEST(test_pointer_to_ref_assignment2);
- CPPUNIT_TEST(test_source_sink);
- CPPUNIT_TEST(test_address_operator);
- CPPUNIT_TEST(test_address_operator2);
- CPPUNIT_TEST(test_clear);
- CPPUNIT_TEST(test_query_interface);
- CPPUNIT_TEST(test_query_interface_throw);
- CPPUNIT_TEST_SUITE_END();
- };
-
-// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_comtools::test_COMReference, "test_comtools");
+ ASSERT_TRUE(false) << "Exception should have been thrown";
+ }
} // namespace rtl_OUString
-
-// this macro creates an empty function, which will called by the RegisterAllFunctions()
-// to let the user the possibility to also register some functions by hand.
-NOADDITIONAL;
-
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
commit eb80254927fe946fce3461da934bc321ae2f14f7
Author: Damjan Jovanovic <damjan at apache.org>
Date: Sun Sep 20 07:37:03 2015 +0000
#i125003# migrate main/sw from cppunit to Google Test.
diff --git a/sw/GoogleTest_sw_bigpointerarray.mk b/sw/GoogleTest_sw_bigpointerarray.mk
new file mode 100644
index 0000000..fbff0ee
--- /dev/null
+++ b/sw/GoogleTest_sw_bigpointerarray.mk
@@ -0,0 +1,51 @@
+#**************************************************************
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#**************************************************************
+
+
+$(eval $(call gb_GoogleTest_GoogleTest,sw_bigpointerarray))
+
+$(eval $(call gb_GoogleTest_add_exception_objects,sw_bigpointerarray, \
+ sw/qa/core/Test-BigPtrArray \
+))
+
+$(eval $(call gb_GoogleTest_add_linked_libs,sw_bigpointerarray, \
+ sal \
+ sfx \
+ stl \
+ sw \
+ tl \
+ $(gb_STDLIBS) \
+))
+
+$(eval $(call gb_GoogleTest_set_include,sw_bigpointerarray,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/sw/inc \
+ -I$(SRCDIR)/sw/inc/pch \
+ -I$(SRCDIR)/sw/qa/core \
+ -I$(OUTDIR)/inc/offuh \
+ -I$(OUTDIR)/inc \
+))
+
+$(eval $(call gb_GoogleTest_set_ldflags,sw_bigpointerarray,\
+ $$(LDFLAGS) \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index d286994..a149c2c 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -36,6 +36,13 @@ $(eval $(call gb_Module_add_targets,sw,\
))
+ifeq ($(ENABLE_UNIT_TESTS),YES)
+$(eval $(call gb_Module_add_check_targets,sw,\
+ GoogleTest_sw_bigpointerarray \
+))
+endif
+
+
ifneq ($(OOO_JUNIT_JAR),)
$(eval $(call gb_Module_add_subsequentcheck_targets,sw,\
JunitTest_sw_complex \
diff --git a/sw/qa/core/Test-BigPtrArray.cxx b/sw/qa/core/Test-BigPtrArray.cxx
index 4bf2bc8..bfe9e28 100644
--- a/sw/qa/core/Test-BigPtrArray.cxx
+++ b/sw/qa/core/Test-BigPtrArray.cxx
@@ -25,7 +25,7 @@
#include "precompiled_sw.hxx"
#define TIMELOG
-#include <testshl/simpleheader.hxx>
+#include "gtest/gtest.h"
#include <bparr.hxx>
#include <string>
#include <stdlib.h>
@@ -33,12 +33,15 @@
#undef ENABLE_DEBUG_OUTPUT
+// FIXME:
+#define RUN_OLD_FAILING_TESTS 0
+
using namespace std;
namespace /* private */
{
- const int NUM_ENTRIES = 100000;
+ const int NUM_ENTRIES = 1000;
class BigPtrEntryMock : public BigPtrEntry
{
@@ -122,647 +125,478 @@ namespace /* private */
RTL_LOGFILE_CONTEXT(logFile, "BigPtrArray performance measures" );
}
-class BigPtrArrayUnittest : public CppUnit::TestFixture
+class BigPtrArrayUnittest : public ::testing::Test
{
public:
BigPtrArrayUnittest()
{
}
+};
- /** Test constructor/destructor
- The size of the BigPtrArray
- aka the 'Count' should be 0
- initially.
- */
- void test_ctor()
- {
- printMethodName("test_ctor\n");
-
- BigPtrArray bparr;
+/** Test constructor/destructor
+ The size of the BigPtrArray
+ aka the 'Count' should be 0
+ initially.
+*/
+TEST_F(BigPtrArrayUnittest, test_ctor)
+{
+ printMethodName("test_ctor\n");
- CPPUNIT_ASSERT_MESSAGE
- (
- "BigPtrArray ctor failed",
- bparr.Count() == 0
- );
- }
+ BigPtrArray bparr;
- void test_insert_entries_at_front()
- {
- printMethodName("test_insert_entries_at_front\n");
-
- RTL_LOGFILE_CONTEXT_TRACE(logFile, "START: test_insert_entries_at_front");
+ ASSERT_TRUE(bparr.Count() == 0) << "BigPtrArray ctor failed";;
+}
- BigPtrArray bparr;
+TEST_F(BigPtrArrayUnittest, test_insert_entries_at_front)
+{
+ printMethodName("test_insert_entries_at_front\n");
- for (int i = 0; i < NUM_ENTRIES; i++)
- {
- sal_uLong oldCount = bparr.Count();
- bparr.Insert(new BigPtrEntryMock(i), 0);
- CPPUNIT_ASSERT_MESSAGE
- (
- "test_insert_entries_at_front failed",
- (bparr.Count() == oldCount + 1)
- )
- }
+ RTL_LOGFILE_CONTEXT_TRACE(logFile, "START: test_insert_entries_at_front");
- RTL_LOGFILE_CONTEXT_TRACE(logFile, "END: test_insert_entries_at_front");
+ BigPtrArray bparr;
- for (int i = 0, j = NUM_ENTRIES - 1; i < NUM_ENTRIES; i++, j--)
- {
- CPPUNIT_ASSERT_MESSAGE
- (
- "test_insert_entries_at_front failed",
- static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == j
- )
- }
+ for (int i = 0; i < NUM_ENTRIES; i++)
+ {
+ sal_uLong oldCount = bparr.Count();
+ bparr.Insert(new BigPtrEntryMock(i), 0);
+ ASSERT_TRUE((bparr.Count() == oldCount + 1)) << "test_insert_entries_at_front failed";
+ }
- CPPUNIT_ASSERT_MESSAGE
- (
- "test_insert_entries_at_front failed",
- checkElementPositions(bparr)
- )
+ RTL_LOGFILE_CONTEXT_TRACE(logFile, "END: test_insert_entries_at_front");
- releaseBigPtrArrayContent(bparr);
- dumpBigPtrArray(bparr);
+ for (int i = 0, j = NUM_ENTRIES - 1; i < NUM_ENTRIES; i++, j--)
+ {
+ ASSERT_TRUE(static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == j) << "test_insert_entries_at_front failed";
}
- void test_insert_entries_in_the_middle()
- {
- printMethodName("test_insert_entries_in_the_middle\n");
+ ASSERT_TRUE(checkElementPositions(bparr)) << "test_insert_entries_at_front failed";
- RTL_LOGFILE_CONTEXT_TRACE(logFile, "START: test_insert_entries_in_the_middle");
+ releaseBigPtrArrayContent(bparr);
+ dumpBigPtrArray(bparr);
+}
- BigPtrArray bparr;
+TEST_F(BigPtrArrayUnittest, test_insert_entries_in_the_middle)
+{
+ printMethodName("test_insert_entries_in_the_middle\n");
- fillBigPtrArray(bparr, NUM_ENTRIES);
- dumpBigPtrArray(bparr);
+ RTL_LOGFILE_CONTEXT_TRACE(logFile, "START: test_insert_entries_in_the_middle");
- sal_uLong oldCount = bparr.Count();
+ BigPtrArray bparr;
- bparr.Insert(new BigPtrEntryMock(NUM_ENTRIES), bparr.Count() / 2);
+ fillBigPtrArray(bparr, NUM_ENTRIES);
+ dumpBigPtrArray(bparr);
- RTL_LOGFILE_CONTEXT_TRACE(logFile, "END: test_insert_entries_in_the_middle");
+ sal_uLong oldCount = bparr.Count();
- CPPUNIT_ASSERT_MESSAGE
- (
- "test_insert_entries_in_the_middle failed",
- (oldCount + 1 == bparr.Count() && static_cast<BigPtrEntryMock*>(bparr[bparr.Count() / 2])->getCount() == NUM_ENTRIES)
- )
+ bparr.Insert(new BigPtrEntryMock(NUM_ENTRIES), bparr.Count() / 2);
- CPPUNIT_ASSERT_MESSAGE
- (
- "test_insert_entries_in_the_middle failed",
- checkElementPositions(bparr)
- )
+ RTL_LOGFILE_CONTEXT_TRACE(logFile, "END: test_insert_entries_in_the_middle");
- releaseBigPtrArrayContent(bparr);
- dumpBigPtrArray(bparr);
- }
+ ASSERT_TRUE((oldCount + 1 == bparr.Count() && static_cast<BigPtrEntryMock*>(bparr[bparr.Count() / 2])->getCount() == NUM_ENTRIES)) << "test_insert_entries_in_the_middle failed";
- void test_insert_at_already_used_index()
- {
- printMethodName("test_insert_at_already_used_index\n");
+ ASSERT_TRUE(checkElementPositions(bparr)) << "test_insert_entries_in_the_middle failed";
- RTL_LOGFILE_CONTEXT_TRACE(logFile, "START: test_insert_at_already_used_index");
+ releaseBigPtrArrayContent(bparr);
+ dumpBigPtrArray(bparr);
+}
- BigPtrArray bparr;
+TEST_F(BigPtrArrayUnittest, test_insert_at_already_used_index)
+{
+ printMethodName("test_insert_at_already_used_index\n");
- fillBigPtrArray(bparr, NUM_ENTRIES);
- dumpBigPtrArray(bparr);
+ RTL_LOGFILE_CONTEXT_TRACE(logFile, "START: test_insert_at_already_used_index");
- int oldCount = bparr.Count();
+ BigPtrArray bparr;
- for (int i = 0, j = -5; i < 5; i++, j++)
- bparr.Insert(new BigPtrEntryMock(j), i);
+ fillBigPtrArray(bparr, NUM_ENTRIES);
+ dumpBigPtrArray(bparr);
- RTL_LOGFILE_CONTEXT_TRACE(logFile, "END: test_insert_at_already_used_index");
+ int oldCount = bparr.Count();
- CPPUNIT_ASSERT_MESSAGE
- (
- "test_insert_at_already_used_index failed",
- (oldCount + 5 == bparr.Count())
- )
+ for (int i = 0, j = -5; i < 5; i++, j++)
+ bparr.Insert(new BigPtrEntryMock(j), i);
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list