summaryrefslogtreecommitdiffstats
path: root/lib/store/tests
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-25 05:28:35 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-25 05:28:35 +0000
commitf008adb5a77e094eaf6abf3fc0f36958e66896a5 (patch)
tree8e9244c4d4957c36be81e15b566b4aa5ea26c982 /lib/store/tests
parent1210f27b660efb7b37ff43ec68763e85a403471f (diff)
downloadkoffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.tar.gz
koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.zip
TQt4 port koffice
This should enable compilation under both Qt3 and Qt4; fixes for any missed components will be forthcoming git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238284 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lib/store/tests')
-rw-r--r--lib/store/tests/storage_test.cpp38
-rw-r--r--lib/store/tests/storedroptest.cpp72
-rw-r--r--lib/store/tests/xmlwritertest.cpp40
-rw-r--r--lib/store/tests/xmlwritertest.h20
4 files changed, 85 insertions, 85 deletions
diff --git a/lib/store/tests/storage_test.cpp b/lib/store/tests/storage_test.cpp
index 6fd03bf3..1c7269ad 100644
--- a/lib/store/tests/storage_test.cpp
+++ b/lib/store/tests/storage_test.cpp
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#include <qfile.h>
-#include <qdir.h>
+#include <tqfile.h>
+#include <tqdir.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
@@ -44,21 +44,21 @@ namespace {
const char* const unableToRead = "Couldn't read stream back!";
}
-int cleanUp( KoStore* store, const QString& testFile, const char* error )
+int cleanUp( KoStore* store, const TQString& testFile, const char* error )
{
- QFile::remove( testFile );
+ TQFile::remove( testFile );
delete store;
kdDebug() << error << endl;
return 1;
}
-int test( const char* testName, KoStore::Backend backend, const QString& testFile )
+int test( const char* testName, KoStore::Backend backend, const TQString& testFile )
{
- if ( QFile::exists( testFile ) )
- QFile::remove( testFile );
- QDir dirTest( testFile );
+ if ( TQFile::exists( testFile ) )
+ TQFile::remove( testFile );
+ TQDir dirTest( testFile );
if ( dirTest.exists() ) {
- system( QCString( "rm -rf " ) + QFile::encodeName( testFile ) ); // QDir::rmdir isn't recursive!
+ system( TQCString( "rm -rf " ) + TQFile::encodeName( testFile ) ); // TQDir::rmdir isn't recursive!
}
kdDebug() << "======================="<<testName<<"====================================" << endl;
@@ -75,7 +75,7 @@ int test( const char* testName, KoStore::Backend backend, const QString& testFil
return cleanUp( store, testFile, unableToOpen );
store->enterDirectory( testDir );
- if ( store->currentPath() != QString( testDirResult ) )
+ if ( store->currentPath() != TQString( testDirResult ) )
return cleanUp( store, testFile, brokenPath );
if ( store->open( "test2/with/a/relative/dir.txt" ) ) {
@@ -94,7 +94,7 @@ int test( const char* testName, KoStore::Backend backend, const QString& testFil
return cleanUp( store, testFile, unableToOpen );
store->enterDirectory( testDir2 );
- if ( store->currentPath() != QString( testDir2Result ) )
+ if ( store->currentPath() != TQString( testDir2Result ) )
return cleanUp( store, testFile, brokenPath );
if ( store->open( "root" ) ) {
@@ -115,7 +115,7 @@ int test( const char* testName, KoStore::Backend backend, const QString& testFil
return cleanUp( store, testFile, badStorage );
if ( store->open( "test1/with/a/relative/dir.txt" ) ) {
- QIODevice* dev = store->device();
+ TQIODevice* dev = store->device();
int i = 0, lim = strlen( test1 ), count = 0;
while ( static_cast<char>( dev->getch() ) == test1[i++] ) {
if ( i == lim ) {
@@ -131,11 +131,11 @@ int test( const char* testName, KoStore::Backend backend, const QString& testFil
return cleanUp( store, testFile, unableToOpen );
store->enterDirectory( testDir );
- if ( store->currentPath() != QString( testDirResult ) )
+ if ( store->currentPath() != TQString( testDirResult ) )
return cleanUp( store, testFile, brokenPath );
if ( store->open( "test2/with/a/relative/dir.txt" ) ) {
- QIODevice* dev = store->device();
+ TQIODevice* dev = store->device();
int i = 0, lim = strlen( test2 ), count = 0;
while ( static_cast<char>( dev->getch() ) == test2[i++] ) {
if ( i == lim ) {
@@ -155,12 +155,12 @@ int test( const char* testName, KoStore::Backend backend, const QString& testFil
while ( store->leaveDirectory() );
store->enterDirectory( testDir );
- if ( store->currentPath() != QString( testDirResult ) )
+ if ( store->currentPath() != TQString( testDirResult ) )
return cleanUp( store, testFile, brokenPath );
if ( store->open( "root" ) ) {
if ( store->size() == 22 ) {
- QIODevice* dev = store->device();
+ TQIODevice* dev = store->device();
unsigned int i = 0;
while ( static_cast<char>( dev->getch() ) == test3[i++] );
store->close();
@@ -180,7 +180,7 @@ int test( const char* testName, KoStore::Backend backend, const QString& testFil
}
store->popDirectory();
- if ( store->currentPath() != QString( testDir2Result ) )
+ if ( store->currentPath() != TQString( testDir2Result ) )
return cleanUp( store, testFile, brokenPath );
if ( store->open( "root" ) ) {
@@ -197,7 +197,7 @@ int test( const char* testName, KoStore::Backend backend, const QString& testFil
if ( store->isOpen() )
store->close();
delete store;
- QFile::remove( testFile );
+ TQFile::remove( testFile );
kdDebug() << "===========================================================" << endl;
return 0;
@@ -210,7 +210,7 @@ int main( int argc, char **argv )
// KZip (due to KSaveFile) doesn't support relative filenames
// So use $PWD as base for the paths explicitely.
- const QString testDir = QDir::currentDirPath();
+ const TQString testDir = TQDir::currentDirPath();
if ( test( "Tar", KoStore::Tar, testDir+"test.tgz" ) != 0 )
return 1;
if ( test( "Directory", KoStore::Directory, testDir+"testdir/maindoc.xml" ) != 0 )
diff --git a/lib/store/tests/storedroptest.cpp b/lib/store/tests/storedroptest.cpp
index 0510ea62..344cab54 100644
--- a/lib/store/tests/storedroptest.cpp
+++ b/lib/store/tests/storedroptest.cpp
@@ -1,25 +1,25 @@
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <KoStore.h>
-#include <qtextbrowser.h>
-#include <qstringlist.h>
-#include <qbuffer.h>
-#include <qclipboard.h>
+#include <tqtextbrowser.h>
+#include <tqstringlist.h>
+#include <tqbuffer.h>
+#include <tqclipboard.h>
-class StoreDropTest : public QTextBrowser
+class StoreDropTest : public TQTextBrowser
{
public:
- StoreDropTest( QWidget* parent );
+ StoreDropTest( TQWidget* tqparent );
protected:
- virtual void contentsDragEnterEvent( QDragEnterEvent * e );
- virtual void contentsDragMoveEvent( QDragMoveEvent * e );
- virtual void contentsDropEvent( QDropEvent * e );
- virtual void keyPressEvent( QKeyEvent * e );
+ virtual void contentsDragEnterEvent( TQDragEnterEvent * e );
+ virtual void contentsDragMoveEvent( TQDragMoveEvent * e );
+ virtual void contentsDropEvent( TQDropEvent * e );
+ virtual void keyPressEvent( TQKeyEvent * e );
virtual void paste();
private:
- bool processMimeSource( QMimeSource* ev );
- void showZipContents( QByteArray data, const char* mimeType, bool oasis );
- QString loadTextFile( KoStore* store, const QString& fileName );
+ bool processMimeSource( TQMimeSource* ev );
+ void showZipContents( TQByteArray data, const char* mimeType, bool oasis );
+ TQString loadTextFile( KoStore* store, const TQString& fileName );
};
int main( int argc, char** argv )
@@ -32,46 +32,46 @@ int main( int argc, char** argv )
window->resize( 500, 500 );
window->show();
- QObject::connect( qApp, SIGNAL( lastWindowClosed() ), qApp, SLOT( quit() ) );
+ TQObject::connect( tqApp, TQT_SIGNAL( lastWindowClosed() ), tqApp, TQT_SLOT( quit() ) );
return app.exec();
}
-StoreDropTest::StoreDropTest( QWidget* parent )
- : QTextBrowser( parent )
+StoreDropTest::StoreDropTest( TQWidget* tqparent )
+ : TQTextBrowser( tqparent )
{
setText( "KoStore drop/paste test\nDrop or paste a selection from a KOffice application into this widget to see the ZIP contents" );
setAcceptDrops( true );
}
-void StoreDropTest::contentsDragEnterEvent( QDragEnterEvent * ev )
+void StoreDropTest::contentsDragEnterEvent( TQDragEnterEvent * ev )
{
ev->acceptAction();
}
-void StoreDropTest::contentsDragMoveEvent( QDragMoveEvent * ev )
+void StoreDropTest::contentsDragMoveEvent( TQDragMoveEvent * ev )
{
ev->acceptAction();
}
-void StoreDropTest::keyPressEvent( QKeyEvent * e )
+void StoreDropTest::keyPressEvent( TQKeyEvent * e )
{
if ( ( ( e->state() & ShiftButton ) && e->key() == Key_Insert ) ||
( ( e->state() & ControlButton ) && e->key() == Key_V ) )
paste();
//else
- // QTextBrowser::keyPressEvent( e );
+ // TQTextBrowser::keyPressEvent( e );
}
void StoreDropTest::paste()
{
qDebug( "paste" );
- QMimeSource* m = QApplication::clipboard()->data();
+ TQMimeSource* m = TQApplication::tqclipboard()->data();
if ( !m )
return;
processMimeSource( m );
}
-void StoreDropTest::contentsDropEvent( QDropEvent *ev )
+void StoreDropTest::contentsDropEvent( TQDropEvent *ev )
{
if ( processMimeSource( ev ) )
ev->acceptAction();
@@ -79,16 +79,16 @@ void StoreDropTest::contentsDropEvent( QDropEvent *ev )
ev->ignore();
}
-bool StoreDropTest::processMimeSource( QMimeSource* ev )
+bool StoreDropTest::processMimeSource( TQMimeSource* ev )
{
- const QCString acceptMimeType = "application/vnd.oasis.opendocument.";
+ const TQCString acceptMimeType = "application/vnd.oasis.opendocument.";
const char* fmt;
- QStringList formats;
+ TQStringList formats;
for (int i=0; (fmt = ev->format(i)); i++) {
formats += fmt;
- bool oasis = QString( fmt ).startsWith( acceptMimeType );
- if ( oasis || QString( fmt ) == "application/x-kpresenter" ) {
- QByteArray data = ev->encodedData( fmt );
+ bool oasis = TQString( fmt ).startsWith( acceptMimeType );
+ if ( oasis || TQString( fmt ) == "application/x-kpresenter" ) {
+ TQByteArray data = ev->tqencodedData( fmt );
showZipContents( data, fmt, oasis );
return true;
}
@@ -97,13 +97,13 @@ bool StoreDropTest::processMimeSource( QMimeSource* ev )
return false;
}
-void StoreDropTest::showZipContents( QByteArray data, const char* mimeType, bool oasis )
+void StoreDropTest::showZipContents( TQByteArray data, const char* mimeType, bool oasis )
{
if ( data.isEmpty() ) {
setText( "No data!" );
return;
}
- QBuffer buffer( data );
+ TQBuffer buffer( data );
KoStore * store = KoStore::createStore( &buffer, KoStore::Read );
if ( store->bad() ) {
setText( "Invalid ZIP!" );
@@ -111,7 +111,7 @@ void StoreDropTest::showZipContents( QByteArray data, const char* mimeType, bool
}
store->disallowNameExpansion();
- QString txt = QString( "Valid ZIP file found for format " ) + mimeType + "\n";
+ TQString txt = TQString( "Valid ZIP file found for format " ) + mimeType + "\n";
if ( oasis ) {
txt += loadTextFile( store, "content.xml" );
@@ -124,15 +124,15 @@ void StoreDropTest::showZipContents( QByteArray data, const char* mimeType, bool
setText( txt );
}
-QString StoreDropTest::loadTextFile( KoStore* store, const QString& fileName )
+TQString StoreDropTest::loadTextFile( KoStore* store, const TQString& fileName )
{
if ( !store->open( fileName ) )
- return QString( "%1 not found\n" ).arg( fileName );
+ return TQString( "%1 not found\n" ).tqarg( fileName );
- QByteArray data = store->device()->readAll();
+ TQByteArray data = store->device()->readAll();
store->close();
- QString txt = QString( "Found %1: \n" ).arg( fileName );
- txt += QString::fromUtf8( data.data(), data.size() );
+ TQString txt = TQString( "Found %1: \n" ).tqarg( fileName );
+ txt += TQString::fromUtf8( data.data(), data.size() );
txt += "\n";
return txt;
}
diff --git a/lib/store/tests/xmlwritertest.cpp b/lib/store/tests/xmlwritertest.cpp
index dad86f8f..28bd3b08 100644
--- a/lib/store/tests/xmlwritertest.cpp
+++ b/lib/store/tests/xmlwritertest.cpp
@@ -2,19 +2,19 @@
#include "KoXmlWriter.h"
-#include <qapplication.h>
-#include <qfile.h>
-#include <qdatetime.h>
+#include <tqapplication.h>
+#include <tqfile.h>
+#include <tqdatetime.h>
static const int numParagraphs = 30000;
void speedTest()
{
- QTime time;
+ TQTime time;
time.start();
- QString paragText = QString::fromUtf8( "This is the text of the paragraph. I'm including a euro sign to test encoding issues: €" );
- QCString styleName = "Heading 1";
+ TQString paragText = TQString::fromUtf8( "This is the text of the paragraph. I'm including a euro sign to test encoding issues: €" );
+ TQCString styleName = "Heading 1";
- QFile out( QString::fromLatin1( "out5.xml" ) );
+ TQFile out( TQString::tqfromLatin1( "out5.xml" ) );
if ( out.open(IO_WriteOnly) )
{
KoXmlWriter writer( &out );
@@ -35,7 +35,7 @@ void speedTest()
}
int main( int argc, char** argv ) {
- QApplication app( argc, argv, QApplication::Tty );
+ TQApplication app( argc, argv, TQApplication::Tty );
TEST_BEGIN( 0, 0 );
TEST_END( "framework test", "<r/>\n" );
@@ -78,7 +78,7 @@ int main( int argc, char** argv ) {
TEST_BEGIN( 0, 0 );
writer.startElement( "p", false /*no indent*/ );
- writer.addTextSpan( QString::fromLatin1( " \t\n foo " ) );
+ writer.addTextSpan( TQString::tqfromLatin1( " \t\n foo " ) );
writer.endElement();
TEST_END( "textspan test", "<r>\n"
" <p><text:s text:c=\"3\"/><text:tab/><text:line-break/> foo<text:s text:c=\"2\"/></p>\n"
@@ -86,9 +86,9 @@ int main( int argc, char** argv ) {
TEST_BEGIN( 0, 0 );
writer.startElement( "p", false /*no indent*/ );
- QMap<int, int> tabCache;
+ TQMap<int, int> tabCache;
tabCache.insert( 3, 0 );
- writer.addTextSpan( QString::fromUtf8( " \t\n foö " ), tabCache );
+ writer.addTextSpan( TQString::fromUtf8( " \t\n foö " ), tabCache );
writer.endElement();
TEST_END( "textspan with tabcache", "<r>\n"
" <p><text:s text:c=\"3\"/><text:tab text:tab-ref=\"1\"/><text:line-break/> foö<text:s text:c=\"2\"/></p>\n"
@@ -97,29 +97,29 @@ int main( int argc, char** argv ) {
TEST_BEGIN( 0, 0 );
writer.startElement( "p", false /*no indent*/ );
writer.addProcessingInstruction( "opendocument foobar" );
- writer.addTextSpan( QString::fromLatin1( "foo" ) );
+ writer.addTextSpan( TQString::tqfromLatin1( "foo" ) );
writer.endElement();
TEST_END( "processinginstruction test", "<r>\n"
" <p><?opendocument foobar?>foo</p>\n"
"</r>\n" );
TEST_BEGIN( 0, 0 );
- writer.addManifestEntry( QString::fromLatin1( "foo/bar/blah" ), QString::fromLatin1( "mime/type" ) );
+ writer.addManifestEntry( TQString::tqfromLatin1( "foo/bar/blah" ), TQString::tqfromLatin1( "mime/type" ) );
TEST_END( "addManifestEntry", "<r>\n <manifest:file-entry manifest:media-type=\"mime/type\" manifest:full-path=\"foo/bar/blah\"/>\n</r>\n" );
int sz = 15000; // must be more than KoXmlWriter::s_escapeBufferLen
- QCString x( sz );
+ TQCString x( sz );
x.fill( 'x', sz );
x += '&';
- QCString expected = "<r a=\"";
+ TQCString expected = "<r a=\"";
expected += x + "amp;\"/>\n";
TEST_BEGIN( 0, 0 );
writer.addAttribute( "a", x );
TEST_END( "escaping long cstring", expected.data() );
- QString longPath;
+ TQString longPath;
for ( uint i = 0 ; i < 1000 ; ++i )
- longPath += QString::fromLatin1( "M10 10L20 20 " );
+ longPath += TQString::tqfromLatin1( "M10 10L20 20 " );
expected = "<r a=\"";
expected += longPath.utf8() + "\"/>\n";
TEST_BEGIN( 0, 0 );
@@ -131,9 +131,9 @@ int main( int argc, char** argv ) {
bool val = true;
int num = 1;
double numdouble = 5.0;
- writer.addConfigItem( QString::fromLatin1( "TestConfigBool" ), val );
- writer.addConfigItem( QString::fromLatin1( "TestConfigInt" ), num );
- writer.addConfigItem( QString::fromLatin1( "TestConfigDouble" ), numdouble );
+ writer.addConfigItem( TQString::tqfromLatin1( "TestConfigBool" ), val );
+ writer.addConfigItem( TQString::tqfromLatin1( "TestConfigInt" ), num );
+ writer.addConfigItem( TQString::tqfromLatin1( "TestConfigDouble" ), numdouble );
TEST_END( "test config", "<r>\n"
" <config:config-item config:name=\"TestConfigBool\" config:type=\"boolean\">true</config:config-item>\n"
" <config:config-item config:name=\"TestConfigInt\" config:type=\"int\">1</config:config-item>\n"
diff --git a/lib/store/tests/xmlwritertest.h b/lib/store/tests/xmlwritertest.h
index c5dc76e7..b3d305ea 100644
--- a/lib/store/tests/xmlwritertest.h
+++ b/lib/store/tests/xmlwritertest.h
@@ -1,18 +1,18 @@
#ifndef XMLWRITERTEST_H
#define XMLWRITERTEST_H
-#define QT_NO_CAST_ASCII
+#define TQT_NO_CAST_ASCII
// Those macros are in a separate header file in order to share them
// with kofficecore/tests/kogenstylestest.cpp
-#include <qbuffer.h>
-#include <qregexp.h>
+#include <tqbuffer.h>
+#include <tqregexp.h>
#define TEST_BEGIN(publicId,systemId) \
{ \
- QCString cstr; \
- QBuffer buffer( cstr ); \
+ TQCString cstr; \
+ TQBuffer buffer( cstr ); \
buffer.open( IO_WriteOnly ); \
{ \
KoXmlWriter writer( &buffer ); \
@@ -24,18 +24,18 @@
writer.endDocument(); \
} \
buffer.putch( '\0' ); /*null-terminate*/ \
- QCString expectedFull( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ); \
+ TQCString expectedFull( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ); \
expectedFull += expected; \
if ( cstr == expectedFull ) \
qDebug( "%s OK", testname ); \
else { \
qDebug( "%s FAILED!", testname ); \
- QCString s1 = cstr; \
- QCString s2 = expectedFull; \
+ TQCString s1 = cstr; \
+ TQCString s2 = expectedFull; \
if ( s1.length() != s2.length() ) \
qDebug( "got length %d, expected %d", s1.length(), s2.length() ); \
- s1.replace( QRegExp( QString::fromLatin1( "[x]{1000}" ) ), "[x]*1000" ); \
- s2.replace( QRegExp( QString::fromLatin1( "[x]{1000}" ) ), "[x]*1000" ); \
+ s1.tqreplace( TQRegExp( TQString::tqfromLatin1( "[x]{1000}" ) ), "[x]*1000" ); \
+ s2.tqreplace( TQRegExp( TQString::tqfromLatin1( "[x]{1000}" ) ), "[x]*1000" ); \
qDebug( "%s", s1.data() ); \
qDebug( "Expected:\n%s", s2.data() ); \
return 1; /*exit*/ \