summaryrefslogtreecommitdiffstats
path: root/kexi/tests
diff options
context:
space:
mode:
Diffstat (limited to 'kexi/tests')
-rw-r--r--kexi/tests/Makefile.am6
-rw-r--r--kexi/tests/README14
-rw-r--r--kexi/tests/altertable/1.kexibin0 -> 49150 bytes
-rw-r--r--kexi/tests/altertable/Makefile.am22
-rw-r--r--kexi/tests/altertable/README200
-rw-r--r--kexi/tests/altertable/TODO3
-rw-r--r--kexi/tests/altertable/alltypes.altertable109
-rw-r--r--kexi/tests/altertable/altertable.cpp716
-rw-r--r--kexi/tests/altertable/altertable.h63
-rw-r--r--kexi/tests/altertable/defaultvalues.altertable129
-rw-r--r--kexi/tests/gui/finddialog/finddialog.pro18
-rw-r--r--kexi/tests/gui/finddialog/kexifinddialog.cpp67
-rw-r--r--kexi/tests/gui/finddialog/kexifinddialog.h66
-rw-r--r--kexi/tests/gui/finddialog/kexifinddialogbase.ui326
-rw-r--r--kexi/tests/gui/finddialog/main.cpp36
-rw-r--r--kexi/tests/newapi/Makefile.am32
-rw-r--r--kexi/tests/newapi/README59
-rw-r--r--kexi/tests/newapi/cursors_test.h60
-rw-r--r--kexi/tests/newapi/dbcreation_test.h61
-rw-r--r--kexi/tests/newapi/dr_prop_test.h41
-rw-r--r--kexi/tests/newapi/main.cpp254
-rw-r--r--kexi/tests/newapi/mysqlcursor.cpp121
-rw-r--r--kexi/tests/newapi/mysqlcursortest_create.sql41
-rw-r--r--kexi/tests/newapi/mysqlcursortest_expectedoutput128
-rw-r--r--kexi/tests/newapi/newapi.pro33
-rw-r--r--kexi/tests/newapi/parser_test.h62
-rw-r--r--kexi/tests/newapi/schema.sql38
-rw-r--r--kexi/tests/newapi/schema_test.h55
-rwxr-xr-xkexi/tests/newapi/sqltest27
-rwxr-xr-xkexi/tests/newapi/sqltest_int15
-rw-r--r--kexi/tests/newapi/statements.txt89
-rw-r--r--kexi/tests/newapi/tables_test.h117
-rw-r--r--kexi/tests/newapi/tableview_test.h60
-rw-r--r--kexi/tests/parser/Makefile.am13
-rw-r--r--kexi/tests/parser/README9
-rw-r--r--kexi/tests/parser/dbbin0 -> 17408 bytes
-rw-r--r--kexi/tests/parser/main.cpp103
-rw-r--r--kexi/tests/parser/parser.pro24
-rw-r--r--kexi/tests/startup/Makefile.am19
-rw-r--r--kexi/tests/startup/main.cpp119
-rw-r--r--kexi/tests/startup/testdb.kexis63
-rw-r--r--kexi/tests/tableview/Makefile.am16
-rw-r--r--kexi/tests/tableview/README3
-rw-r--r--kexi/tests/tableview/main.cpp53
-rw-r--r--kexi/tests/tableview/tableview.pro32
-rw-r--r--kexi/tests/tests.pro6
-rw-r--r--kexi/tests/widgets/Makefile.am14
-rw-r--r--kexi/tests/widgets/kexidbdrivercombotest.cpp76
48 files changed, 3618 insertions, 0 deletions
diff --git a/kexi/tests/Makefile.am b/kexi/tests/Makefile.am
new file mode 100644
index 00000000..5eefec2a
--- /dev/null
+++ b/kexi/tests/Makefile.am
@@ -0,0 +1,6 @@
+
+SUBDIRS = newapi widgets
+
+# unused: parser tableview
+# startup
+
diff --git a/kexi/tests/README b/kexi/tests/README
new file mode 100644
index 00000000..e5c61abf
--- /dev/null
+++ b/kexi/tests/README
@@ -0,0 +1,14 @@
+Kexi tests
+----------
+
+newapi/ New KexiDB API test in few aspects
+parser/ Interactive test of KEXISQL parser
+tableview/ Test for not-data-aware KexiTableView widget
+
+See README file in selected directory for details.
+
+In these files:
+- <driver_name> means selected name of a driver from kexidb/drivers,
+ eg. sqlite, mysql (case insensitive)
+- <new_db_name> mean any valid database name
+- <db_name> means any existing database name
diff --git a/kexi/tests/altertable/1.kexi b/kexi/tests/altertable/1.kexi
new file mode 100644
index 00000000..1165d90e
--- /dev/null
+++ b/kexi/tests/altertable/1.kexi
Binary files differ
diff --git a/kexi/tests/altertable/Makefile.am b/kexi/tests/altertable/Makefile.am
new file mode 100644
index 00000000..a2389007
--- /dev/null
+++ b/kexi/tests/altertable/Makefile.am
@@ -0,0 +1,22 @@
+include $(top_srcdir)/kexi/Makefile.global
+
+noinst_PROGRAMS = kexialtertabletest
+
+INCLUDES = -I$(top_srcdir)/kexi \
+ -I$(top_srcdir)/kexi/widget \
+ -I$(top_srcdir)/kexi/core \
+ -I$(top_srcdir)/lib \
+ $(all_includes)
+
+SUBDIRS = .
+
+METASOURCES = AUTO
+
+kexialtertabletest_SOURCES = altertable.cpp
+kexialtertabletest_LDADD = $(LIB_QT) $(LIB_KDECORE) $(top_builddir)/kexi/kexidb/libkexidb.la \
+ $(top_builddir)/kexi/kexiutils/libkexiutils.la \
+ $(top_builddir)/kexi/main/libkeximain.la \
+ $(top_builddir)/kexi/kexidb/parser/libkexidbparser.la \
+ $(top_builddir)/kexi/widget/libkexiextendedwidgets.la
+kexialtertabletest_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
diff --git a/kexi/tests/altertable/README b/kexi/tests/altertable/README
new file mode 100644
index 00000000..1278a54d
--- /dev/null
+++ b/kexi/tests/altertable/README
@@ -0,0 +1,200 @@
+===================================================
+ README for the "altertable" test
+ Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
+===================================================
+
+
+Invoking
+--------
+"altertable" test requires <db_name>, <driver_name> and <alterscript> arguments
+
+The purpose of .altertable files
+--------------------------------
+.altertable files are provoded to test a given use case of table altering.
+It contains a set of commands mapped to a sequence of ALTER TABLE and other
+SQL statements. The commands are mapped to AlterTableHandler::***Action objects,
+what is equat to actions performed by the user during the table designing.
+
+Second purpose of the test is testing the Table Designer's GUI itself.
+Whenever there is a bug in a the GUI, e.g. in the property editor,
+the resulting schema can differ from expected, or there can be even a crash.
+The suite already helped to find a few bugs in the GUI code.
+
+
+How the test is performed, .alterscript file contents
+-----------------------------------------------------
+
+The file can be consisted of many sections described below. The test can be built by:
+a. requesting a table design to be opened in the Table designer,
+b. specifying commands affecting the design,
+c. then checking the actions sequence genrated by the "alter table machinery"
+ (it's a method that allocates AlterTableHandler::***Action objects and add them
+ using AlterTableHandler::addAction() to the alte table machinery.
+ The result is the same as user's actions);
+d. then saving the design,
+e. and finally checking the table data with the expected table contents.
+Every comparison is performed line by line: obtained result is compared with expected one.
+
+2. Expected result of altering the table.
+ It's a full human-redable dump of table schema and its contents.
+
+Each section has a strictly defined format, so the test suite can combine commands into more complex sets.
+
+
+Available commands of the test suite
+------------------------------------
+
+1. Top-level commands
+
+* openDatabase <filename>
+ Opens kexi database for tests. In fact the file is copied to a temporary file (with .tmp suffix)
+ and we're dealing with the copy, so the original could not be broken. Thus, tests can be reproduced.
+#TODO: support server databases
+ Example use: openDatabase 1.kexi
+
+* designTable <tablename> \n <block> \n endDesign
+ Opens table in design mode. <block> contains one or more schema altering
+ commands described in 2.
+
+2. Commands for altering table fields (during the design mode, within "designTable" command):
+
+* insertField <rownumber(int)> <fieldname(string)>
+ Inserts a new table field with default properties (text type) and 'fieldname' name.
+ Note that the inserted field can *replace* an existing field. To avoid this, use
+ insertEmptyRow command before insertField to add an empty row.
+ Example use: insertField 2 abc
+
+* insertEmptyRow <rownumber(int)>
+ Inserts empty row before 'rownumber'. Rows below are moved down.
+ Example use: insertEmptyRow 2
+
+* removeField <rownumber(int)>
+ Removes a table field at a specified row.
+ Example use: removeField 1
+
+* changeFieldProperty <rownumber(int)> <propertyname(string)> <valuetype(string)> <value(string)>
+ Changes property of table field at a specified row.
+ 'valuetype' can be int, string, bool, double/float, bool/boolean, data, dateTime, time,
+ bytearray, longlong.
+ <value(string)> should be a string representation of the value. Special cases are:
+ byteArray: hexadecimal string like 'fd1a5c', dateTime: yyyy-mm-ddThh:mm:ss string
+ like '2005-11-05T12:34:56'.
+ Null values should be specified as <null> string. Empty string values should be specified as "".
+ 'type' property means a field datatype, where value can be any of the names
+ in KexiDB::Field::Type enum, written as string, e.g. "integer","text", "date", etc.
+ Example use: changeFieldProperty 1 type string date
+
+* i++
+ Increases "i" variable by 1. This integer variable is initialized to 1 before test is executed.
+ Can be used as an argument for <rownumber(int)> for above field-related commands.
+
+* i=<number(int)>
+ Sets "i" variable to <number(int)>.
+ Example use: shows that using the variable instead of constants allows to insert
+ a command without a need for managing subsequent arguments.
+ i=3
+ removeField i
+ insertField i textField
+ changeFieldProperty i type string text
+ i++ #i is now 4
+ insertField i longTextField
+ changeFieldProperty i type string longText
+
+3. Commands related to altered (not saved) table schema:
+
+* showSchema [clipboard]
+ Shows schema dump as returned by KexiTableDesignerInterface::debugStringForCurrentTableSchema().
+ Useful for creating "checkSchema" checks: Just paste the output to the test file.
+ You can use "clipboard" word to copy prepare the schema dump to clipboard.
+
+* checkSchema \n <block> \n endSchema
+ Checks validity of the not yet saved schema altered in the Table Designer using the
+ actions listed in p. 1. The <block> should end with "endSchema" line.
+ Between these lines there should be pasted a <block> - exact textual schema dump as returned
+ by KexiTableDesignerInterface::debugStringForCurrentTableSchema().
+ The check compares lines returned from the Designer with the lines you provided, line by line.
+ You can use "showSchema" command to display the expected schema to the stderr and copy the text.
+ Every line contains up to three main sections <fieldname> <type> [<constraints>].
+ The lines can be indented - trailing and leading whitespaces are ignored in comparison.
+ Example use:
+ checkSchema
+ textfield Text(200)
+ owner UNSIGNED Integer
+ booleanfield Boolean NOTNULL
+ endSchema
+
+4. Commands related to simplified list of Alter Table actions (simulated, before real saving):
+
+* showActions [clipboard]
+ Shows the list of simplified Alter Table actions that are result of commands related to table fields,
+ mentioned in 1.
+ You can use "clipboard" word to copy prepare the expected actions dump to clipboard.
+
+* checkActions \n <block> \n endActions
+ Checks validity of the list of simplified Alter Table actions.
+ The <block> should end with "endActions" line.
+ The check compares lines returned from the Designer with the lines you provided as <block>, line by line.
+ Textual dump of actions is obtained from KexiTableDesignerInterface::simulateAlterTableExecution().
+ Every line contains section(s): <actionname> [(<fielddebugstring>)].
+ Example use:
+ checkActions
+ Insert table field "textfield" at position 1 (textfield Text(200))
+ Remove table field "model"
+ Insert table field "longtextfield" at position 3 (longtextfield Text(200))
+ endActions
+
+5. Commands related to physical schema saving (altering) and checking its result
+
+* saveTableDesign
+ Executes the final Alter Table function. Table design will be altered and data should
+ be preserved. After this command it is usable to run "checkTableData" test to see
+ whether the data looks as expected.
+
+* showTableData [clipboard]
+ Shows current table contents in tab-separated CSV format (one row per record)
+ on the stderr; text is encoded in utf-8. The data is printed to the stderr.
+ If optional "clipboard" word is present, the data is copied to clipboard instead.
+ Table dumps can be sometimes large and hard to prepare by hand, so you can use
+ "clipboard" word to prepare the expected table dump by pasting the text to
+ a .altertable file.
+ For details about the output format in the description "checkTableData".
+
+* checkTableData \n <block> \n endTableData
+ Compares the current contents of table with expected contents, line by line.
+ The data has to be in tab-separated CSV format (one row per record);
+ text has to be encoded in utf-8 and enclosed in " quotes.
+ Column names should be included as a first row.
+ You can use showTableData command first and then copy the results to your test file for later.
+ Example use:
+ checkTableData
+ ID Name Surname
+ 1 John Wayne
+ 2 Al Pacino
+ endTableData
+
+6. Other commands.
+
+* closeWindow
+ Closes the currently opened table designer window without asking for saving changes.
+
+* stop
+ Stops processing immediately. For example, this can be inserted temporarily to stop testing
+ (with success result). This command is available in any place.
+
+* quit
+ Executes "closeWindow" command and quits the application (with success result).
+
+6. Comments
+
+Comments can be inserted by adding # on the left hand as in bash shell
+or using /* and */ for multiple rows. Empty rows are ignored.
+
+
+The result of executing the "altertable" test
+---------------------------------------------
+
+On errors, kexialtertabletest program will show an appropriate error message with line number
+where the error encountered and stop executing the tests.
+
+A given "checkSchema" command should result in "Schema check for table 'foo': OK" message.
+Entire test from a give .altertable file 'foo' should end with "Tests from file 'foo': OK" message.
diff --git a/kexi/tests/altertable/TODO b/kexi/tests/altertable/TODO
new file mode 100644
index 00000000..f54a4b50
--- /dev/null
+++ b/kexi/tests/altertable/TODO
@@ -0,0 +1,3 @@
+TODOs for the "altertable" test
+
+- support server databases
diff --git a/kexi/tests/altertable/alltypes.altertable b/kexi/tests/altertable/alltypes.altertable
new file mode 100644
index 00000000..70435a60
--- /dev/null
+++ b/kexi/tests/altertable/alltypes.altertable
@@ -0,0 +1,109 @@
+openDatabase 1.kexi
+
+/*
+ This test checks:
+ - creating table fields of all possible types
+ - adding new fields to the table with preserving the original content
+ Additionally:
+ - as "booleanField" field is type of bool, and by default
+ it is declared as NOT NULL, values for it are filled with "false".
+ - 3rd (original) field is removed before adding new fields
+
+ Used tables: cars
+*/
+designTable cars
+ i=3
+ removeField i
+ insertField i textField
+ changeFieldProperty i type string text
+ i++
+ insertField i longTextField
+ changeFieldProperty i type string longText
+ i++
+ insertField i byteField
+ changeFieldProperty i type string byte
+ i++
+ insertField i shortIntField
+ changeFieldProperty i type string shortInteger
+ i++
+ insertField i intField
+ changeFieldProperty i type string integer
+ i++
+ insertField i bigIntField
+ changeFieldProperty i type string bigInteger
+ i++
+ insertField i booleanField
+ changeFieldProperty i type string boolean
+ i++
+ insertField i dateField
+ changeFieldProperty i type string date
+ i++
+ insertField i dateTimeField
+ changeFieldProperty i type string dateTime
+ i++
+ insertField i timeField
+ changeFieldProperty i type string time
+ i++
+ insertField i floatField
+ changeFieldProperty i type string float
+ i++
+ insertField i doubleField
+ changeFieldProperty i type string double
+ i++
+ insertField i blobField
+ changeFieldProperty i type string blob
+endDesign
+
+ showSchema
+
+ checkSchema
+ id UNSIGNED Integer AUTOINC UNIQUE PKEY NOTNULL NOTEMPTY
+ owner UNSIGNED Integer
+ textfield Text(200)
+ longtextfield LongText
+ bytefield Byte
+ shortintfield ShortInteger
+ intfield Integer
+ bigintfield BigInteger
+ booleanfield Boolean NOTNULL DEFAULT=[bool]false
+ datefield Date
+ datetimefield DateTime
+ timefield Time
+ floatfield Float
+ doublefield Double
+ blobfield BLOB
+ endSchema
+
+ showActions
+
+ checkActions
+ Remove table field "model"
+ Insert table field "textfield" at position 2 (textfield Text(200))
+ Insert table field "longtextfield" at position 3 (longtextfield LongText)
+ Insert table field "bytefield" at position 4 (bytefield Byte)
+ Insert table field "shortintfield" at position 5 (shortintfield ShortInteger)
+ Insert table field "intfield" at position 6 (intfield Integer)
+ Insert table field "bigintfield" at position 7 (bigintfield BigInteger)
+ Insert table field "booleanfield" at position 8 (booleanfield Boolean NOTNULL DEFAULT=[bool]false)
+ Insert table field "datefield" at position 9 (datefield Date)
+ Insert table field "datetimefield" at position 10 (datetimefield DateTime)
+ Insert table field "timefield" at position 11 (timefield Time)
+ Insert table field "floatfield" at position 12 (floatfield Float)
+ Insert table field "doublefield" at position 13 (doublefield Double)
+ Insert table field "blobfield" at position 14 (blobfield BLOB)
+ endActions
+
+ saveTableDesign #executes Alter Table
+
+ showTableData clipboard
+ stop
+
+ checkTableData
+"ID" "Car owner" "textField" "longTextField" "byteField" "shortIntField" "intField" "bigIntField" "booleanField" "dateField" "dateTimeField" "timeField" "floatField" "doubleField" "blobField"
+1 2 false
+2 2 false
+3 3 false
+5 4 false
+6 3 false
+ endTableData
+
diff --git a/kexi/tests/altertable/altertable.cpp b/kexi/tests/altertable/altertable.cpp
new file mode 100644
index 00000000..bf14bc00
--- /dev/null
+++ b/kexi/tests/altertable/altertable.cpp
@@ -0,0 +1,716 @@
+/* This file is part of the KDE project
+ Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "altertable.h"
+
+#include <unistd.h>
+
+#include <qapplication.h>
+#include <qfile.h>
+#include <qdir.h>
+#include <qregexp.h>
+#include <qclipboard.h>
+
+#include <kdebug.h>
+
+#include <main/keximainwindowimpl.h>
+#include <core/kexiaboutdata.h>
+#include <core/kexidialogbase.h>
+#include <core/kexiviewbase.h>
+#include <core/kexipartitem.h>
+#include <core/kexitabledesignerinterface.h>
+#include <core/kexiinternalpart.h>
+#include <kexiutils/utils.h>
+#include <koproperty/set.h>
+#include <kexidb/connection.h>
+#include <kexidb/utils.h>
+
+QString testFilename;
+QFile testFile;
+QTextStream testFileStream;
+QStringList testFileLine;
+uint testLineNumber = 0;
+QString origDbFilename, dbFilename;
+int variableI = 1; // simple variable 'i' support
+int newArgc;
+char** newArgv;
+KexiMainWindowImpl* win = 0;
+KexiProject* prj = 0;
+
+void showError(const QString& msg)
+{
+ QString msg_(msg);
+ msg_.prepend(QString("Error at line %1: ").arg(testLineNumber));
+ kdDebug() << msg_ << endl;
+}
+
+/* Reads a single line from testFileStream, fills testFileLine, updates testLineNumber
+ text in quotes is extracted, e.g. \"ab c\" is treat as one item "ab c"
+ Returns flas on failure (e.g. end of file).
+ Empty lines and lines or parts of lines with # (comments) are omitted. */
+tristate readLineFromTestFile(const QString& expectedCommandName = QString::null)
+{
+ QString s;
+ bool blockComment = false;
+ while (true) {
+ if (testFileStream.atEnd())
+ return cancelled;
+ testLineNumber++;
+ s = testFileStream.readLine().stripWhiteSpace();
+ if (blockComment) {
+ if (s.endsWith("*/"))
+ blockComment = false;
+ continue;
+ }
+ if (!blockComment && s.startsWith("/*")) {
+ blockComment = true;
+ continue;
+ }
+ if (s.startsWith("#"))
+ continue; //skip commented line
+ if (!s.isEmpty())
+ break;
+ }
+ s.append(" "); //sentinel
+ QString item;
+ testFileLine.clear();
+ const int len = s.length();
+ bool skipWhiteSpace = true, quoted = false;
+ for (int i=0; i<len; i++) {
+ const QChar ch( s.ref(i) );
+ if (skipWhiteSpace) {
+ if (ch=='#')
+ break; //eoln
+ if (ch==' ' || ch=='\t')
+ continue;
+ skipWhiteSpace = false;
+ if (ch=='\"') {
+ quoted = true;
+ continue;
+ }
+ item.append(ch);
+ }
+ else {
+ if ((quoted && ch=='\"') || (!quoted && (ch==' ' || ch=='\t'))) { //end of item
+ skipWhiteSpace = true;
+ quoted = false;
+ testFileLine.append( item );
+ item = QString::null;
+ continue;
+ }
+ item.append(ch);
+ }
+ }
+ if (!expectedCommandName.isEmpty() && testFileLine[0]!=expectedCommandName) {
+ showError( QString("Invalid command '%1', expected '%2'")
+ .arg(testFileLine[0]).arg(expectedCommandName));
+ return false;
+ }
+ if (quoted) {
+ showError( "Invalid contents" );
+ return false;
+ }
+ return true;
+}
+
+bool checkItemsNumber(int expectedNumberOfItems, int optionalNumberOfItems = -1)
+{
+ bool ok = expectedNumberOfItems==(int)testFileLine.count();
+ if (optionalNumberOfItems>0)
+ ok = ok || optionalNumberOfItems==(int)testFileLine.count();
+ if (!ok) {
+ QString msg = QString("Invalid number of args (%1) for command '%2', expected: %3")
+ .arg(testFileLine.count()).arg(testFileLine[0]).arg(expectedNumberOfItems);
+ if (optionalNumberOfItems>0)
+ msg.append( QString(" or %1").arg(optionalNumberOfItems) );
+ showError( msg );
+ return false;
+ }
+ return true;
+}
+
+QVariant::Type typeNameToQVariantType(const QCString& name_)
+{
+ QCString name( name_.lower() );
+ if (name=="string")
+ return QVariant::String;
+ if (name=="int")
+ return QVariant::Int;
+ if (name=="bool" || name=="boolean")
+ return QVariant::Bool;
+ if (name=="double" || name=="float")
+ return QVariant::Double;
+ if (name=="date")
+ return QVariant::Date;
+ if (name=="datetime")
+ return QVariant::DateTime;
+ if (name=="time")
+ return QVariant::Time;
+ if (name=="bytearray")
+ return QVariant::ByteArray;
+ if (name=="longlong")
+ return QVariant::LongLong;
+//todo more types
+ showError(QString("Invalid type '%1'").arg(name_));
+ return QVariant::Invalid;
+}
+
+// casts string to QVariant
+bool castStringToQVariant( const QString& string, const QCString& type, QVariant& result )
+{
+ if (string.lower()=="<null>") {
+ result = QVariant();
+ return true;
+ }
+ if (string=="\"\"") {
+ result = QString("");
+ return true;
+ }
+ const QVariant::Type vtype = typeNameToQVariantType( type );
+ bool ok;
+ result = KexiDB::stringToVariant( string, vtype, ok );
+ return ok;
+}
+
+// returns a number parsed from argument; if argument is i or i++, variableI is used
+// 'ok' is set to false on failure
+static int getNumber(const QString& argument, bool& ok)
+{
+ int result;
+ ok = true;
+ if (argument=="i" || argument=="i++") {
+ result = variableI;
+ if (argument=="i++")
+ variableI++;
+ }
+ else {
+ result = argument.toInt(&ok);
+ if (!ok) {
+ showError(QString("Invalid value '%1'").arg(argument));
+ return -1;
+ }
+ }
+ return result;
+}
+
+//---------------------------------------
+
+AlterTableTester::AlterTableTester()
+ : QObject()
+ , m_finishedCopying(false)
+{
+ //copy the db file to a temp file
+ qInitNetworkProtocols();
+ QPtrList<QNetworkOperation> list = m_copyOperator.copy(
+ "file://" + QDir::current().path() + "/" + origDbFilename,
+ "file://" + QDir::current().path() + "/" + dbFilename, false, false );
+ connect(&m_copyOperator, SIGNAL(finished(QNetworkOperation*)),
+ this, SLOT(slotFinishedCopying(QNetworkOperation*)));
+}
+
+AlterTableTester::~AlterTableTester()
+{
+ QFile(dbFilename).remove();
+}
+
+void AlterTableTester::slotFinishedCopying(QNetworkOperation* oper)
+{
+ if (oper->operation()==QNetworkProtocol::OpPut)
+ m_finishedCopying = true;
+}
+
+bool AlterTableTester::changeFieldProperty(KexiTableDesignerInterface* designerIface)
+{
+ if (!checkItemsNumber(5))
+ return false;
+ QVariant newValue;
+ QCString propertyName( testFileLine[2].latin1() );
+ QCString propertyType( testFileLine[3].latin1() );
+ QString propertyValueString(testFileLine[4]);
+ if (propertyName=="type")
+ newValue = (int)KexiDB::Field::typeForString(testFileLine[4]);
+ else {
+ if (!castStringToQVariant(propertyValueString, propertyType, newValue)) {
+ showError( QString("Could not set property '%1' value '%2' of type '%3'")
+ .arg(propertyName).arg(propertyValueString).arg(propertyType) );
+ return false;
+ }
+ }
+ bool ok;
+ int row = getNumber(testFileLine[1], ok)-1;
+ if (!ok)
+ return false;
+ designerIface->changeFieldPropertyForRow( row, propertyName, newValue, 0, true );
+ if (propertyName=="type") {
+ //clean subtype name, e.g. from "longText" to "LongText", because dropdown list is case-sensitive
+ QString realSubTypeName;
+ if (KexiDB::Field::BLOB == KexiDB::Field::typeForString(testFileLine[4]))
+//! @todo hardcoded!
+ realSubTypeName = "image";
+ else
+ realSubTypeName = KexiDB::Field::typeString( KexiDB::Field::typeForString(testFileLine[4]) );
+ designerIface->changeFieldPropertyForRow( row, "subType", realSubTypeName, 0, true );
+ }
+ return true;
+}
+
+//helper
+bool AlterTableTester::getSchemaDump(KexiDialogBase* dlg, QString& schemaDebugString)
+{
+ KexiTableDesignerInterface* designerIface
+ = dynamic_cast<KexiTableDesignerInterface*>( dlg->selectedView() );
+ if (!designerIface)
+ return false;
+
+ // Get the result
+ tristate result;
+ schemaDebugString = designerIface->debugStringForCurrentTableSchema(result);
+ if (true!=result) {
+ showError( QString("Loading modified schema failed. Result: %1")
+ .arg(~result ? "cancelled" : "false") );
+ return false;
+ }
+ schemaDebugString.remove(QRegExp(",$")); //no need to have "," at the end of lines
+ return true;
+}
+
+bool AlterTableTester::showSchema(KexiDialogBase* dlg, bool copyToClipboard)
+{
+ QString schemaDebugString;
+ if (!getSchemaDump(dlg, schemaDebugString))
+ return false;
+ if (copyToClipboard)
+ QApplication::clipboard()->setText( schemaDebugString );
+ else
+ kdDebug() << QString("Schema for '%1' table:\n").arg(dlg->partItem()->name())
+ + schemaDebugString + "\nendSchema" << endl;
+ return true;
+}
+
+bool AlterTableTester::checkInternal(KexiDialogBase* dlg,
+ QString& debugString, const QString& endCommand, bool skipColonsAndStripWhiteSpace)
+{
+ Q_UNUSED(dlg);
+ QTextStream resultStream(&debugString, IO_ReadOnly);
+ // Load expected result, compare
+ QString expectedLine, resultLine;
+ while (true) {
+ const bool testFileStreamAtEnd = testFileStream.atEnd();
+ if (!testFileStreamAtEnd) {
+ testLineNumber++;
+ expectedLine = testFileStream.readLine();
+ if (skipColonsAndStripWhiteSpace) {
+ expectedLine = expectedLine.stripWhiteSpace();
+ expectedLine.remove(QRegExp(",$")); //no need to have "," at the end of lines
+ }
+ }
+ if (testFileStreamAtEnd || endCommand==expectedLine.stripWhiteSpace()) {
+ if (!resultStream.atEnd()) {
+ showError( "Test file ends unexpectedly." );
+ return false;
+ }
+ break;
+ }
+ //test line loaded, load result
+ if (resultStream.atEnd()) {
+ showError( QString("Result ends unexpectedly. There is at least one additinal test line: '")
+ + expectedLine +"'" );
+ return false;
+ }
+ resultLine = resultStream.readLine();
+ if (skipColonsAndStripWhiteSpace) {
+ resultLine = resultLine.stripWhiteSpace();
+ resultLine.remove(QRegExp(",$")); //no need to have "," at the end of lines
+ }
+ if (resultLine!=expectedLine) {
+ showError(
+ QString("Result differs from the expected:\nExpected: ")
+ +expectedLine+"\n????????: "+resultLine+"\n");
+ return false;
+ }
+ }
+ return true;
+}
+
+bool AlterTableTester::checkSchema(KexiDialogBase* dlg)
+{
+ QString schemaDebugString;
+ if (!getSchemaDump(dlg, schemaDebugString))
+ return false;
+ bool result = checkInternal(dlg, schemaDebugString, "endSchema", true /*skipColonsAndStripWhiteSpace*/);
+ kdDebug() << QString("Schema check for table '%1': %2").arg(dlg->partItem()->name())
+ .arg(result ? "OK" : "Failed") << endl;
+ return result;
+}
+
+bool AlterTableTester::getActionsDump(KexiDialogBase* dlg, QString& actionsDebugString)
+{
+ KexiTableDesignerInterface* designerIface
+ = dynamic_cast<KexiTableDesignerInterface*>( dlg->selectedView() );
+ if (!designerIface)
+ return false;
+ tristate result = designerIface->simulateAlterTableExecution(&actionsDebugString);
+ if (true!=result) {
+ showError( QString("Computing simplified actions for table '%1' failed.").arg(dlg->partItem()->name()) );
+ return false;
+ }
+ return true;
+}
+
+bool AlterTableTester::showActions(KexiDialogBase* dlg, bool copyToClipboard)
+{
+ QString actionsDebugString;
+ if (!getActionsDump(dlg, actionsDebugString))
+ return false;
+ if (copyToClipboard)
+ QApplication::clipboard()->setText( actionsDebugString );
+ else
+ kdDebug() << QString("Simplified actions for altering table '%1':\n").arg(dlg->partItem()->name())
+ + actionsDebugString+"\n" << endl;
+ return true;
+}
+
+bool AlterTableTester::checkActions(KexiDialogBase* dlg)
+{
+ QString actionsDebugString;
+ if (!getActionsDump(dlg, actionsDebugString))
+ return false;
+ bool result = checkInternal(dlg, actionsDebugString, "endActions", true /*skipColonsAndStripWhiteSpace*/);
+ kdDebug() << QString("Actions check for table '%1': %2").arg(dlg->partItem()->name())
+ .arg(result ? "OK" : "Failed") << endl;
+ return result;
+}
+
+bool AlterTableTester::saveTableDesign(KexiDialogBase* dlg)
+{
+ KexiTableDesignerInterface* designerIface
+ = dynamic_cast<KexiTableDesignerInterface*>( dlg->selectedView() );
+ if (!designerIface)
+ return false;
+ tristate result = designerIface->executeRealAlterTable();
+ if (true!=result) {
+ showError( QString("Saving design of table '%1' failed.").arg(dlg->partItem()->name()) );
+ return false;
+ }
+ return true;
+}
+
+bool AlterTableTester::getTableDataDump(KexiDialogBase* dlg, QString& dataString)
+{
+ KexiTableDesignerInterface* designerIface
+ = dynamic_cast<KexiTableDesignerInterface*>( dlg->selectedView() );
+ if (!designerIface)
+ return false;
+
+ QMap<QString,QString> args;
+ QTextStream ts( &dataString, IO_WriteOnly );
+ args["textStream"] = KexiUtils::ptrToString<QTextStream>( &ts );
+ args["destinationType"]="file";
+ args["delimiter"]="\t";
+ args["textQuote"]="\"";
+ args["itemId"] = QString::number(
+ prj->dbConnection()->tableSchema( dlg->partItem()->name() )->id() );
+ if (!KexiInternalPart::executeCommand("csv_importexport", win, "KexiCSVExport", &args)) {
+ showError( "Error exporting table contents." );
+ return false;
+ }
+ return true;
+}
+
+bool AlterTableTester::showTableData(KexiDialogBase* dlg, bool copyToClipboard)
+{
+ QString dataString;
+ if (!getTableDataDump(dlg, dataString))
+ return false;
+ if (copyToClipboard)
+ QApplication::clipboard()->setText( dataString );
+ else
+ kdDebug() << QString("Contents of table '%1':\n").arg(dlg->partItem()->name())+dataString+"\n" << endl;
+ return true;
+}
+
+bool AlterTableTester::checkTableData(KexiDialogBase* dlg)
+{
+ QString dataString;
+ if (!getTableDataDump(dlg, dataString))
+ return false;
+ bool result = checkInternal(dlg, dataString, "endTableData", false /*!skipColonsAndStripWhiteSpace*/);
+ kdDebug() << QString("Table '%1' contents: %2").arg(dlg->partItem()->name())
+ .arg(result ? "OK" : "Failed") << endl;
+ return result;
+}
+
+bool AlterTableTester::closeWindow(KexiDialogBase* dlg)
+{
+ if (!dlg)
+ return true;
+ QString name = dlg->partItem()->name();
+ tristate result = true == win->closeDialog(dlg, true/*layoutTaskBar*/, true/*doNotSaveChanges*/);
+ kdDebug() << QString("Closing window for table '%1': %2").arg(name)
+ .arg(result==true ? "OK" : (result==false ? "Failed" : "Cancelled")) << endl;
+ return result == true;
+}
+
+//! Processes test file
+tristate AlterTableTester::run(bool &closeAppRequested)
+{
+ closeAppRequested = false;
+ while (!m_finishedCopying)
+ qApp->processEvents(300);
+
+ kdDebug() << "Database copied to temporary: " << dbFilename << endl;
+
+ if (!checkItemsNumber(2))
+ return false;
+
+ tristate res = win->openProject( dbFilename, 0 );
+ if (true != res)
+ return res;
+ prj = win->project();
+
+ //open table in design mode
+ res = readLineFromTestFile("designTable");
+ if (true != res)
+ return ~res;
+
+ QString tableName(testFileLine[1]);
+ KexiPart::Item *item = prj->itemForMimeType("kexi/table", tableName);
+ if (!item) {
+ showError(QString("No such table '%1'").arg(tableName));
+ return false;
+ }
+ bool openingCancelled;
+ KexiDialogBase* dlg = win->openObject(item, Kexi::DesignViewMode, openingCancelled);
+ if (!dlg) {
+ showError(QString("Could not open table '%1'").arg(item->name()));
+ return false;
+ }
+ KexiTableDesignerInterface* designerIface
+ = dynamic_cast<KexiTableDesignerInterface*>( dlg->selectedView() );
+ if (!designerIface)
+ return false;
+
+ //dramatic speedup: temporary hide the window and propeditor
+ QWidget * propeditor
+ = KexiUtils::findFirstChild<QWidget>(qApp->mainWidget(), "KexiPropertyEditorView");
+ if (propeditor)
+ propeditor->hide();
+ dlg->hide();
+
+ bool designTable = true;
+ while (!testFileStream.atEnd()) {
+ res = readLineFromTestFile();
+ if (true != res)
+ return ~res;
+ QString command( testFileLine[0] );
+ if (designTable) {
+ //subcommands available within "designTable" commands
+ if (command=="endDesign") {
+ if (!checkItemsNumber(1))
+ return false;
+ //end of the design session: unhide the window and propeditor
+ dlg->show();
+ if (propeditor)
+ propeditor->show();
+ designTable = false;
+ continue;
+ }
+ else if (command=="removeField") {
+ if (!checkItemsNumber(2))
+ return false;
+ bool ok;
+ int row = getNumber(testFileLine[1], ok)-1;
+ if (!ok)
+ return false;
+ designerIface->deleteRow( row, true );
+ continue;
+ }
+ else if (command=="insertField") {
+ if (!checkItemsNumber(3))
+ return false;
+ bool ok;
+ int row = getNumber(testFileLine[1], ok)-1;
+ if (!ok)
+ return false;
+ designerIface->insertField( row, testFileLine[2], true );
+ continue;
+ }
+ else if (command=="insertEmptyRow") {
+ if (!checkItemsNumber(2))
+ return false;
+ bool ok;
+ int row = getNumber(testFileLine[1], ok)-1;
+ if (!ok)
+ return false;
+ designerIface->insertEmptyRow( row, true );
+ continue;
+ }
+ else if (command=="changeFieldProperty") {
+ if (!checkItemsNumber(5) || !changeFieldProperty(designerIface))
+ return false;
+ continue;
+ }
+ else if (command.startsWith("i=")) {
+ bool ok;
+ variableI = command.mid(2).toInt(&ok);
+ if (!ok) {
+ showError(QString("Invalid variable initialization '%1'").arg(command));
+ return false;
+ }
+ continue;
+ }
+ else if (command.startsWith("i++")) {
+ variableI++;
+ continue;
+ }
+ }
+ else {
+ //top-level commands available outside of "designTable"
+ if (command=="showSchema") {
+ if (!checkItemsNumber(1, 2) || !showSchema(dlg, testFileLine[1]=="clipboard"))
+ return false;
+ continue;
+ }
+ else if (command=="checkSchema") {
+ if (!checkItemsNumber(1) || !checkSchema(dlg))
+ return false;
+ continue;
+ }
+ else if (command=="showActions") {
+ if (!checkItemsNumber(1, 2) || !showActions(dlg, testFileLine[1]=="clipboard"))
+ return false;
+ continue;
+ }
+ else if (command=="checkActions") {
+ if (!checkItemsNumber(1) || !checkActions(dlg))
+ return false;
+ continue;
+ }
+ else if (command=="saveTableDesign") {
+ if (!checkItemsNumber(1) || !saveTableDesign(dlg))
+ return false;
+ continue;
+ }
+ else if (command=="showTableData") {
+ if (!checkItemsNumber(1, 2) || !showTableData(dlg, testFileLine[1]=="clipboard"))
+ return false;
+ continue;
+ }
+ else if (command=="checkTableData") {
+ if (!checkItemsNumber(1) || !checkTableData(dlg))
+ return false;
+ continue;
+ }
+ }
+ //common commands
+ if (command=="stop") {
+ if (!checkItemsNumber(1))
+ return false;
+ kdDebug() << QString("Test STOPPED at line %1.").arg(testLineNumber) << endl;
+ break;
+ }
+ else if (command=="closeWindow") {
+ if (!checkItemsNumber(1) || !closeWindow(dlg))
+ return false;
+ else
+ dlg = 0;
+ continue;
+ }
+ else if (command=="quit") {
+ if (!checkItemsNumber(1) || !closeWindow(dlg))
+ return false;
+ closeAppRequested = true;
+ kdDebug() << QString("Quitting the application...") << endl;
+ break;
+ }
+ else {
+ showError( QString("No such command '%1'").arg(command) );
+ return false;
+ }
+ }
+ return true;
+}
+
+//---------------------------------------
+
+int quit(int result)
+{
+ testFile.close();
+ delete qApp;
+ if (newArgv)
+ delete [] newArgv;
+ return result;
+}
+
+int main(int argc, char *argv[])
+{
+ // args: <.altertable test filename>
+ if (argc < 2) {
+ kdWarning() << "Please specify test filename.\nOptions: \n"
+ "\t-close - closes the main window when test finishes" << endl;
+ return quit(1);
+ }
+
+ // options:
+ const bool closeOnFinish = argc > 2 && 0==qstrcmp(argv[1], "-close");
+
+ // open test file
+ testFilename = argv[argc-1];
+ testFile.setName(testFilename);
+ if (!testFile.open(IO_ReadOnly)) {
+ kdWarning() << QString("Opening test file %1 failed.").arg(testFilename) << endl;
+ return quit(1);
+ }
+ //load db name
+ testFileStream.setDevice( &testFile );
+ tristate res = readLineFromTestFile("openDatabase");
+ if (true != res)
+ return quit( ~res ? 0 : 1 );
+ origDbFilename = testFileLine[1];
+ dbFilename = origDbFilename + ".tmp";
+
+ newArgc = 2;
+ newArgv = new char*[newArgc];
+ newArgv[0] = qstrdup(argv[0]);
+ newArgv[1] = qstrdup( "--skip-startup-dialog" );
+
+ KAboutData* aboutdata = Kexi::createAboutData();
+ aboutdata->setProgramName( "Kexi Alter Table Test" );
+ int result = KexiMainWindowImpl::create(newArgc, newArgv, aboutdata);
+ if (!qApp)
+ return quit(result);
+
+ win = KexiMainWindowImpl::self();
+ AlterTableTester tester;
+ //QObject::connect(win, SIGNAL(projectOpened()), &tester, SLOT(run()));
+
+ bool closeAppRequested;
+ res = tester.run(closeAppRequested);
+ if (true != res) {
+ if (false == res)
+ kdWarning() << QString("Running test for file '%1' failed.").arg(testFilename) << endl;
+ return quit(res==false ? 1 : 0);
+ }
+ kdDebug() << QString("Tests from file '%1': OK").arg(testFilename) << endl;
+ result = (closeOnFinish || closeAppRequested) ? 0 : qApp->exec();
+ quit(result);
+ return result;
+}
+
+#include "altertable.moc"
diff --git a/kexi/tests/altertable/altertable.h b/kexi/tests/altertable/altertable.h
new file mode 100644
index 00000000..455c2bf5
--- /dev/null
+++ b/kexi/tests/altertable/altertable.h
@@ -0,0 +1,63 @@
+/* This file is part of the KDE project
+ Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef AlterTableTester_H
+#define AlterTableTester_H
+
+#include <qurloperator.h>
+#include <qnetwork.h>
+#include <qnetworkprotocol.h>
+#include <kexiutils/tristate.h>
+
+class KexiTableDesignerInterface;
+class KexiDialogBase;
+
+class AlterTableTester : public QObject
+{
+ Q_OBJECT
+ public:
+ AlterTableTester();
+ ~AlterTableTester();
+
+ tristate run(bool &closeAppRequested);
+
+ protected slots:
+ void slotFinishedCopying(QNetworkOperation*);
+
+ private:
+ bool changeFieldProperty(KexiTableDesignerInterface* designerIface);
+ bool getSchemaDump(KexiDialogBase* dlg, QString& schemaDebugString);
+ bool showSchema(KexiDialogBase* dlg, bool copyToClipboard);
+ bool checkSchema(KexiDialogBase* dlg);
+ bool getActionsDump(KexiDialogBase* dlg, QString& actionsDebugString);
+ bool showActions(KexiDialogBase* dlg, bool copyToClipboard);
+ bool checkActions(KexiDialogBase* dlg);
+ bool checkInternal(KexiDialogBase* dlg, QString& debugString,
+ const QString& endCommand, bool skipColons);
+ bool saveTableDesign(KexiDialogBase* dlg);
+ bool getTableDataDump(KexiDialogBase* dlg, QString& dataString);
+ bool showTableData(KexiDialogBase* dlg, bool copyToClipboard);
+ bool checkTableData(KexiDialogBase* dlg);
+ bool closeWindow(KexiDialogBase* dlg);
+
+ QUrlOperator m_copyOperator;
+ bool m_finishedCopying;
+};
+
+#endif
diff --git a/kexi/tests/altertable/defaultvalues.altertable b/kexi/tests/altertable/defaultvalues.altertable
new file mode 100644
index 00000000..1ed27440
--- /dev/null
+++ b/kexi/tests/altertable/defaultvalues.altertable
@@ -0,0 +1,129 @@
+openDatabase 1.kexi
+
+/*
+ This test checks:
+ - creating table fields of all possible types with specific default values
+ - adding new fields to the table with preserving the original content
+
+ All the existing columns are removed
+
+ Used tables: cars
+*/
+
+designTable cars #initially there are 3rows
+ removeField 2
+ removeField 2
+ i=2
+ insertField i textField
+ changeFieldProperty i type string text
+ changeFieldProperty i defaultValue string abc
+ i++
+ insertField i longTextField
+ changeFieldProperty i type string longText
+ changeFieldProperty i defaultValue string def
+ i++
+ insertField i byteField
+ changeFieldProperty i type string byte
+ changeFieldProperty i defaultValue int 11
+ i++
+ insertField i shortIntField
+ changeFieldProperty i type string shortInteger
+ changeFieldProperty i defaultValue int 22
+ i++
+ insertField i intField
+ changeFieldProperty i type string integer
+ changeFieldProperty i defaultValue int 333
+ i++
+ insertField i bigIntField
+ changeFieldProperty i type string bigInteger
+ changeFieldProperty i defaultValue longlong 1234567891011
+ i++
+ insertField i booleanField
+ changeFieldProperty i type string boolean
+ changeFieldProperty i defaultValue bool true
+ i++
+ insertField i dateField
+ changeFieldProperty i type string date
+ changeFieldProperty i defaultValue date 2006-08-09
+ i++
+ insertField i dateTimeField
+ changeFieldProperty i type string dateTime
+ changeFieldProperty i defaultValue dateTime 2006-08-09T10:36:01
+ i++
+ insertField i timeField
+ changeFieldProperty i type string time
+ changeFieldProperty i defaultValue time 10:36:02
+ i++
+ insertField i floatField
+ changeFieldProperty i type string float
+ changeFieldProperty i defaultValue float 1.98
+ i++
+ insertField i doubleField
+ changeFieldProperty i type string double
+ changeFieldProperty i defaultValue double 3.1415926
+ i++
+ insertField i blobField
+ changeFieldProperty i type string blob
+ changeFieldProperty i defaultValue byteArray fdfeff
+endDesign
+
+ showSchema
+
+ checkSchema
+ id UNSIGNED Integer AUTOINC UNIQUE PKEY NOTNULL NOTEMPTY
+ textfield Text(200) DEFAULT=[QString]abc,
+ longtextfield LongText DEFAULT=[QString]def,
+ bytefield Byte DEFAULT=[int]11,
+ shortintfield ShortInteger DEFAULT=[int]22,
+ intfield Integer DEFAULT=[int]333,
+ bigintfield BigInteger DEFAULT=[Q_LLONG]1234567891011,
+ booleanfield Boolean NOTNULL DEFAULT=[bool]true,
+ datefield Date DEFAULT=[QDate]2006-08-09,
+ datetimefield DateTime DEFAULT=[QDateTime]2006-08-09T10:36:01,
+ timefield Time DEFAULT=[QTime]10:36:02,
+ floatfield Float DEFAULT=[double]1.98,
+ doublefield Double DEFAULT=[double]3.1415926,
+ blobfield BLOB DEFAULT=[QByteArray]FDFEFF
+ endSchema
+
+# showActions clipboard
+
+ checkActions
+Remove table field "owner"
+Remove table field "model"
+Insert table field "textfield" at position 1 (textfield Text(200) DEFAULT=[QString]abc)
+Insert table field "longtextfield" at position 2 (longtextfield LongText DEFAULT=[QString]def)
+Insert table field "bytefield" at position 3 (bytefield Byte DEFAULT=[int]11)
+Insert table field "shortintfield" at position 4 (shortintfield ShortInteger DEFAULT=[int]22)
+Insert table field "intfield" at position 5 (intfield Integer DEFAULT=[int]333)
+Insert table field "bigintfield" at position 6 (bigintfield BigInteger DEFAULT=[Q_LLONG]1234567891011)
+Insert table field "booleanfield" at position 7 (booleanfield Boolean NOTNULL DEFAULT=[bool]true)
+Insert table field "datefield" at position 8 (datefield Date DEFAULT=[QDate]2006-08-09)
+Insert table field "datetimefield" at position 9 (datetimefield DateTime DEFAULT=[QDateTime]2006-08-09T10:36:01)
+Insert table field "timefield" at position 10 (timefield Time DEFAULT=[QTime]10:36:02)
+Insert table field "floatfield" at position 11 (floatfield Float DEFAULT=[double]1.98)
+Insert table field "doublefield" at position 12 (doublefield Double DEFAULT=[double]3.1415926)
+Insert table field "blobfield" at position 13 (blobfield BLOB DEFAULT=[QByteArray]FDFEFF)
+ endActions
+
+saveTableDesign #executes Alter Table
+
+#closeWindow
+
+#stop
+#quit
+
+# copyTableDataToClipboard
+ showTableData clipboard
+# stop
+
+ checkTableData
+"ID" "textField" "longTextField" "byteField" "shortIntField" "intField" "bigIntField" "booleanField" "dateField" "dateTimeField" "timeField" "floatField" "doubleField" "blobField"
+1 "abc" "def" 11 22 333 1234567891011 true 2006-08-09 2006-08-09 10:36:01 10:36:02 1.98 3.1415926 "FDFEFF"
+2 "abc" "def" 11 22 333 1234567891011 true 2006-08-09 2006-08-09 10:36:01 10:36:02 1.98 3.1415926 "FDFEFF"
+3 "abc" "def" 11 22 333 1234567891011 true 2006-08-09 2006-08-09 10:36:01 10:36:02 1.98 3.1415926 "FDFEFF"
+5 "abc" "def" 11 22 333 1234567891011 true 2006-08-09 2006-08-09 10:36:01 10:36:02 1.98 3.1415926 "FDFEFF"
+6 "abc" "def" 11 22 333 1234567891011 true 2006-08-09 2006-08-09 10:36:01 10:36:02 1.98 3.1415926 "FDFEFF"
+ endTableData
+
+
diff --git a/kexi/tests/gui/finddialog/finddialog.pro b/kexi/tests/gui/finddialog/finddialog.pro
new file mode 100644
index 00000000..f76b5372
--- /dev/null
+++ b/kexi/tests/gui/finddialog/finddialog.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+
+include( $(KEXI)/common.pro )
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../include
+
+system( bash kmoc )
+
+TARGET = finddialogtest
+DESTDIR=.
+
+system( bash kmoc )
+system( bash kdcopidl )
+
+SOURCES = kexifinddialog.cpp main.cpp
+
+FORMS = kexifinddialogbase.ui
diff --git a/kexi/tests/gui/finddialog/kexifinddialog.cpp b/kexi/tests/gui/finddialog/kexifinddialog.cpp
new file mode 100644
index 00000000..64f54d51
--- /dev/null
+++ b/kexi/tests/gui/finddialog/kexifinddialog.cpp
@@ -0,0 +1,67 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "kexifinddialog.h"
+
+#include <kstdguiitem.h>
+#include <kpushbutton.h>
+#include <kcombobox.h>
+#include <klocale.h>
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+
+KexiFindDialog::KexiFindDialog( bool replaceMode, QWidget* parent, const char* name, bool modal )
+ : KexiFindDialogBase(parent, name, modal)
+ , m_replaceMode(true)
+{
+ m_btnFind->setIconSet(KStdGuiItem::find().iconSet());
+ m_btnClose->setIconSet(KStdGuiItem::close().iconSet());
+ setReplaceMode(replaceMode);
+ m_lookIn->insertItem(i18n("(All columns)"));
+}
+
+void KexiFindDialog::setReplaceMode(bool set)
+{
+ if (m_replaceMode == set)
+ return;
+ m_replaceMode = set;
+ if (m_replaceMode) {
+ m_promptOnReplace->show();
+ m_replaceLbl->show();
+ m_textToReplace->show();
+ m_btnReplace->show();
+ m_btnReplaceAll->show();
+ }
+ else {
+ m_promptOnReplace->hide();
+ m_replaceLbl->hide();
+ m_textToReplace->hide();
+ m_btnReplace->hide();
+ m_btnReplaceAll->hide();
+ resize(width(),height()-30);
+ }
+ updateGeometry();
+}
+
+KexiFindDialog::~KexiFindDialog()
+{
+}
+
+#include "kexifinddialog.moc"
diff --git a/kexi/tests/gui/finddialog/kexifinddialog.h b/kexi/tests/gui/finddialog/kexifinddialog.h
new file mode 100644
index 00000000..9025d152
--- /dev/null
+++ b/kexi/tests/gui/finddialog/kexifinddialog.h
@@ -0,0 +1,66 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KEXIFINDDIALOG_H
+#define KEXIFINDDIALOG_H
+
+#include "kexifinddialogbase.h"
+
+/*! @brief A Kexi-specific "Find text" dialog.
+
+ Also used for replace.
+*/
+class KexiFindDialog : public KexiFindDialogBase
+{
+ Q_OBJECT
+ public:
+ KexiFindDialog( bool replaceMode, QWidget* parent = 0, const char* name = 0, bool modal = FALSE );
+ virtual ~KexiFindDialog();
+
+#if 0
+TODO TODO TODO TODO TODO TODO
+ /*! Sets \a columnNames list for 'look in column' combo box.
+ "(All columns)" item is also prepended. */
+ void setLookInColumnList(const QStringList& columnNames);
+
+ /*! \return a list for 'look in column' combo box.
+ "(All columns)" item is also prepended. */
+ QStringList* lookInColumnList() const;
+
+ /*! \return column name selected in 'look in column' combo box.
+ If "(All columns)" item is selected, "*" is returned. */
+ QString lookInColumn() const;
+
+ /*! Selects \a columnName to be selected 'look in column'.
+ By default "(All columns)" item is selected. To select this item, pass "*". */
+ void setLookInColumn(const QString& columnName);
+
+#endif
+
+ public slots:
+ /*! Sets or clears replace mode.
+ For replace mode 'prompt or replace' option is visible.
+ */
+ void setReplaceMode(bool set);
+
+ protected:
+ bool m_replaceMode : 1;
+};
+
+#endif
diff --git a/kexi/tests/gui/finddialog/kexifinddialogbase.ui b/kexi/tests/gui/finddialog/kexifinddialogbase.ui
new file mode 100644
index 00000000..f4684bff
--- /dev/null
+++ b/kexi/tests/gui/finddialog/kexifinddialogbase.ui
@@ -0,0 +1,326 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KexiFindDialogBase</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>KexiFindDialogBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>476</width>
+ <height>224</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Find Text</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KHistoryCombo" row="1" column="1" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_textToReplace</cstring>
+ </property>
+ <property name="insertionPolicy">
+ <enum>AtTop</enum>
+ </property>
+ <property name="autoCompletion">
+ <bool>true</bool>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="4" column="2">
+ <property name="name">
+ <cstring>m_caseSensitive</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>WheelFocus</enum>
+ </property>
+ <property name="text">
+ <string>C&amp;ase sensitive</string>
+ </property>
+ </widget>
+ <widget class="KHistoryCombo" row="0" column="1" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_textToFind</cstring>
+ </property>
+ <property name="insertionPolicy">
+ <enum>AtTop</enum>
+ </property>
+ <property name="autoCompletion">
+ <bool>true</bool>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="4" column="1">
+ <item>
+ <property name="text">
+ <string>Any Part of Field</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Whole Field</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Start of Field</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>m_match</cstring>
+ </property>
+ <property name="insertionPolicy">
+ <enum>NoInsertion</enum>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Fi&amp;nd:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>m_textToFind</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>m_replaceLbl</cstring>
+ </property>
+ <property name="text">
+ <string>Re&amp;place with:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>m_textToReplace</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textLabel2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Search:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>m_search</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>textLabel2_2_3</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Match:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>m_match</cstring>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="3" column="1">
+ <item>
+ <property name="text">
+ <string>Up</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Down</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>All Rows</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>m_search</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>WheelFocus</enum>
+ </property>
+ <property name="insertionPolicy">
+ <enum>NoInsertion</enum>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="2" column="1">
+ <property name="name">
+ <cstring>m_lookIn</cstring>
+ </property>
+ <property name="insertionPolicy">
+ <enum>NoInsertion</enum>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Look in column:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>m_lookIn</cstring>
+ </property>
+ </widget>
+ <spacer row="4" column="3">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox" row="5" column="2">
+ <property name="name">
+ <cstring>m_wholeWords</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>WheelFocus</enum>
+ </property>
+ <property name="text">
+ <string>&amp;Whole words only</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="6" column="2">
+ <property name="name">
+ <cstring>m_promptOnReplace</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>WheelFocus</enum>
+ </property>
+ <property name="text">
+ <string>Prompt on replace</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer row="7" column="2">
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="0" column="4" rowspan="8" colspan="1">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_btnFind</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Find Next</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_btnClose</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_btnReplace</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Replace</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_btnReplaceAll</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Replace All</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer8</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>m_btnClose</sender>
+ <signal>clicked()</signal>
+ <receiver>KexiFindDialogBase</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>m_textToFind</tabstop>
+ <tabstop>m_textToReplace</tabstop>
+ <tabstop>m_lookIn</tabstop>
+ <tabstop>m_search</tabstop>
+ <tabstop>m_match</tabstop>
+ <tabstop>m_caseSensitive</tabstop>
+ <tabstop>m_wholeWords</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kcombobox.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/kexi/tests/gui/finddialog/main.cpp b/kexi/tests/gui/finddialog/main.cpp
new file mode 100644
index 00000000..7da98bf4
--- /dev/null
+++ b/kexi/tests/gui/finddialog/main.cpp
@@ -0,0 +1,36 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <kapplication.h>
+#include <klocale.h>
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
+
+#include "kexifinddialog.h"
+
+int main( int argc, char ** argv )
+{
+ KAboutData aboutData( "test", I18N_NOOP("KFind"), "0", "", KAboutData::License_LGPL );
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KApplication app;
+
+ KexiFindDialog dlg(true, 0, "dialog");
+
+ return dlg.exec();
+}
diff --git a/kexi/tests/newapi/Makefile.am b/kexi/tests/newapi/Makefile.am
new file mode 100644
index 00000000..3694806d
--- /dev/null
+++ b/kexi/tests/newapi/Makefile.am
@@ -0,0 +1,32 @@
+include $(top_srcdir)/kexi/Makefile.global
+
+# unused: kexidbmysqlcursor kexidbfirebirdcursor
+
+noinst_PROGRAMS = kexidbtest
+
+# unused: kexidbmysqlcursor
+
+INCLUDES = -I$(top_srcdir)/kexi \
+ -I$(top_srcdir)/kexi/widget \
+ -I$(top_srcdir)/kexi/core \
+ $(all_includes)
+
+SUBDIRS = .
+
+METASOURCES = AUTO
+
+kexidbtest_SOURCES = main.cpp
+kexidbtest_LDADD = $(LIB_QT) $(LIB_KDECORE) $(top_builddir)/kexi/kexidb/libkexidb.la \
+ ../../kexidb/parser/libkexidbparser.la \
+ $(top_builddir)/kexi/widget/libkexiextendedwidgets.la
+kexidbtest_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+#kexidbmysqlcursor_SOURCES = mysqlcursor.cpp
+#kexidbmysqlcursor_LDADD = $(LIB_QT) $(LIB_KDECORE) $(top_builddir)/kexi/kexidb/libkexidb.la \
+# ../../kexidb/parser/libkexidbparser.la
+#kexidbmysqlcursor_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+#kexidbfirebirdcursor_SOURCES = firebirdcursor.cpp
+#kexidbfirebirdcursor_LDADD = $(LIB_QT) $(LIB_KDECORE) $(top_builddir)/kexi/kexidb/libkexidb.la
+#kexidbfirebirdcursor_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
diff --git a/kexi/tests/newapi/README b/kexi/tests/newapi/README
new file mode 100644
index 00000000..a9be5621
--- /dev/null
+++ b/kexi/tests/newapi/README
@@ -0,0 +1,59 @@
+1. kexidbtest
+-------------
+
+This is a set of tests for the new, common KexiDB API.
+Every test is driver-independent.
+
+Usage: run 'kexidbtest --help' for usage details.
+
+
+2. sqltest
+----------
+
+Script for easier executing 'parser' subtest within kexidbtest.
+Usage: run './sqltest' without arguments for usage details.
+
+There is also sqltest_int script accepting interactive mode.
+Usage: run './sqltest_int' without arguments for usage details.
+
+
+3. Important documents
+----------------------
+-Kexi API Documentation in html
+http://koffice.org/developer/apidocs/kexi/html
+
+-KexiDB Drivers section of KexiWiki Web Page
+http://www.kexi-project.org/wiki/wikiview/index.php?KexiDBDrivers
+
+
+
+4. Information for KexiDB drivers developers
+--------------------------------------------
+
+While you're developing new driver or improving existing one,
+you may want to test a number of aspects to see if the behaviour
+looks like expected.
+
+Following tests should be passed (the order is from most simple
+test to more complicated):
+
+-dbcreation
+-schema
+-tables
+-cursors
+-tableview
+-parser
+-dr_prop
+
+If the given driver does not pass one of these tests, and you have found:
+- that the problem is at the KexiDB library side (e.g. crash, or improper
+behaviour), or
+- that the problem can be solved by extending KexiDB API, or
+- that the documentation is not correct or not enough detailed, or
+- whatever like that,
+
+..please contact:
+
+KexiDB maintainer
+Jaroslaw Staniek, js @ iidea . pl, irc://irc.freenode.net #kexi
+
diff --git a/kexi/tests/newapi/cursors_test.h b/kexi/tests/newapi/cursors_test.h
new file mode 100644
index 00000000..36bd3dd8
--- /dev/null
+++ b/kexi/tests/newapi/cursors_test.h
@@ -0,0 +1,60 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef CURSORS_TEST_H
+#define CURSORS_TEST_H
+
+int tablesTest();
+
+int cursorsTest()
+{
+ if (!conn->databaseExists( db_name )) {
+ if (tablesTest()!=0)
+ return 1;
+ kdDebug() << "DB created & filled"<< endl;
+ }
+
+ if (!conn->useDatabase( db_name )) {
+ conn->debugError();
+ return 1;
+ }
+
+ KexiDB::Cursor *cursor = conn->executeQuery( "select * from persons", cursor_options );//KexiDB::Cursor::Buffered );
+ kdDebug()<<"executeQuery() = "<<!!cursor<<endl;
+ if (!cursor)
+ return 1;
+
+ kdDebug()<<"Cursor::moveLast() ---------------------" << endl;
+ kdDebug()<<"-- Cursor::moveLast() == " << cursor->moveLast() << endl;
+ cursor->moveLast();
+ kdDebug()<<"Cursor::moveFirst() ---------------------" << endl;
+ kdDebug()<<"-- Cursor::moveFirst() == " << cursor->moveFirst() << endl;
+
+/* kdDebug()<<"Cursor::moveNext() == "<<cursor->moveNext()<<endl;
+ kdDebug()<<"Cursor::moveNext() == "<<cursor->moveNext()<<endl;
+ kdDebug()<<"Cursor::moveNext() == "<<cursor->moveNext()<<endl;
+ kdDebug()<<"Cursor::moveNext() == "<<cursor->moveNext()<<endl;
+ kdDebug()<<"Cursor::eof() == "<<cursor->eof()<<endl;*/
+ conn->deleteCursor(cursor);
+
+ return 0;
+}
+
+#endif
+
diff --git a/kexi/tests/newapi/dbcreation_test.h b/kexi/tests/newapi/dbcreation_test.h
new file mode 100644
index 00000000..741859c1
--- /dev/null
+++ b/kexi/tests/newapi/dbcreation_test.h
@@ -0,0 +1,61 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef DBCREATION_TEST_H
+#define DBCREATION_TEST_H
+
+int dbCreationTest()
+{
+ if (conn->databaseExists( db_name )) {
+ if (!conn->dropDatabase( db_name )) {
+ conn->debugError();
+ return 1;
+ }
+ kdDebug() << "DB '" << db_name << "' dropped"<< endl;
+ }
+ if (!conn->createDatabase( db_name )) {
+ conn->debugError();
+ return 1;
+ }
+ kdDebug() << "DB '" << db_name << "' created"<< endl;
+ if (!conn->useDatabase( db_name )) {
+ conn->debugError();
+ return 1;
+ }
+/* KexiDB::Cursor *cursor = conn->executeQuery( "select * from osoby", KexiDB::Cursor::Buffered );
+ kdDebug()<<"executeQuery() = "<<!!cursor<<endl;
+ if (cursor) {
+ kdDebug()<<"Cursor::moveLast() ---------------------" << endl;
+ kdDebug()<<"-- Cursor::moveLast() == " << cursor->moveLast() << endl;
+ cursor->moveLast();
+ kdDebug()<<"Cursor::moveFirst() ---------------------" << endl;
+ kdDebug()<<"-- Cursor::moveFirst() == " << cursor->moveFirst() << endl;
+*/
+/* kdDebug()<<"Cursor::moveNext() == "<<cursor->moveNext()<<endl;
+ kdDebug()<<"Cursor::moveNext() == "<<cursor->moveNext()<<endl;
+ kdDebug()<<"Cursor::moveNext() == "<<cursor->moveNext()<<endl;
+ kdDebug()<<"Cursor::moveNext() == "<<cursor->moveNext()<<endl;
+ kdDebug()<<"Cursor::eof() == "<<cursor->eof()<<endl;*/
+// conn->deleteCursor(cursor);
+// }
+ return 0;
+}
+
+#endif
+
diff --git a/kexi/tests/newapi/dr_prop_test.h b/kexi/tests/newapi/dr_prop_test.h
new file mode 100644
index 00000000..71e882e3
--- /dev/null
+++ b/kexi/tests/newapi/dr_prop_test.h
@@ -0,0 +1,41 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef DR_PROP_TEST_H
+#define DR_PROP_TEST_H
+
+int drPropTest()
+{
+ QValueList<QCString> names = driver->propertyNames();
+ kdDebug() << QString("%1 properties found:").arg(names.count()) << endl;
+ for (QValueList<QCString>::ConstIterator it = names.constBegin(); it!=names.constEnd(); ++it) {
+ kdDebug() << " - " << (*it) << ":"
+ << " caption=\"" << driver->propertyCaption(*it) << "\""
+ << " type=" << driver->propertyValue(*it).typeName()
+ << " value=\""<<driver->propertyValue(*it).toString()<<"\"" << endl;
+ }
+// QVariant propertyValue( const QCString& propName ) const;
+
+// QVariant propertyCaption( const QCString& propName ) const;
+
+ return 0;
+}
+
+#endif
+
diff --git a/kexi/tests/newapi/main.cpp b/kexi/tests/newapi/main.cpp
new file mode 100644
index 00000000..514538f3
--- /dev/null
+++ b/kexi/tests/newapi/main.cpp
@@ -0,0 +1,254 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qfileinfo.h>
+#include <qguardedptr.h>
+
+#include <kdebug.h>
+#include <kcmdlineargs.h>
+#include <kapplication.h>
+#include <kinstance.h>
+#include <kiconloader.h>
+#include <kaboutdata.h>
+
+#include <kexidb/drivermanager.h>
+#include <kexidb/driver.h>
+#include <kexidb/connection.h>
+#include <kexidb/cursor.h>
+#include <kexidb/field.h>
+#include <kexidb/tableschema.h>
+#include <kexidb/queryschema.h>
+#include <kexidb/indexschema.h>
+#include <kexidb/parser/parser.h>
+
+#include <iostream>
+
+using namespace std;
+
+QCString prgname;
+QCString db_name;
+QCString drv_name;
+QCString test_name;
+int cursor_options = 0;
+bool db_name_required = true;
+
+KexiDB::ConnectionData conn_data;
+QGuardedPtr<KexiDB::Connection> conn;
+QGuardedPtr<KexiDB::Driver> driver;
+KApplication *app = 0;
+KInstance *instance = 0;
+
+static KCmdLineOptions options[] =
+{
+ { "test <test_name>",
+ "Available tests:\n"
+ "- cursors: test for cursors behaviour\n"
+ "- schema: test for db schema retrieving\n"
+ "- dbcreation: test for new db creation\n"
+ "- tables: test for tables creation and data\n"
+ " inserting\n"
+ "- tableview: test for KexiDataTableView data-aware\n"
+ " widget\n"
+ "- parser: test for parsing sql statements,\n"
+ " returns debug string for a given\n"
+ " sql statement or error message\n"
+ "- dr_prop: shows properties of selected driver"
+ , 0},
+ { "buffered-cursors",
+ "Optional switch :turns cursors used in any tests\n"
+ " to be buffered", 0},
+ { "query-params <params>", "Query parameters separated\n"
+ "by '|' character that will be passed to query\n"
+ "statement to replace [...] placeholders.", 0 },
+ { "", " Notes:\n"
+ "1. 'dr_prop' requires <db_name> argument.\n"
+ "2. 'parser' test requires <db_name>,\n"
+ " <driver_name> and <sql_statement> arguments\n"
+ "3. All other tests require <db_name>\n"
+ " and <driver_name> arguments.\n"
+ "4. 'tables' test automatically runs 'dbcreation'\n"
+ " test. (<new_db_name> is removed if already exists.\n"
+ "5. <db_name> must be a valid kexi database\n"
+ " e.g. created with 'tables' test.", 0},
+ { "+driver_name", "Driver name", 0},
+ { "+[db_name]", "Database name", 0},
+ { "+[sql_statement]", "Optional SQL statement (for parser test)", 0},
+ KCmdLineLastOption
+};
+
+#include "dbcreation_test.h"
+#include "cursors_test.h"
+#include "schema_test.h"
+#include "tables_test.h"
+#include "tableview_test.h"
+#include "parser_test.h"
+#include "dr_prop_test.h"
+
+#define RETURN(code) \
+ kdDebug()<< test_name << " TEST: " << (code==0?"PASSED":"ERROR") << endl; \
+ return code
+
+int main(int argc, char** argv)
+{
+ int minargs = 2;
+ bool gui = false;
+/* if (argc < minargs) {
+ usage();
+ RETURN(0);
+ }*/
+ QFileInfo info=QFileInfo(argv[0]);
+ prgname = info.baseName().latin1();
+
+ KCmdLineArgs::init(argc, argv,
+ new KAboutData( prgname, "KexiDBTest",
+ "0.1.2", "", KAboutData::License_GPL,
+ "(c) 2003-2006, Kexi Team\n"
+ "(c) 2003-2006, OpenOffice Polska Ltd.\n",
+ "",
+ "http://www.koffice.org/kexi",
+ "submit@bugs.kde.org"
+ )
+ );
+ KCmdLineArgs::addCmdLineOptions( options );
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+ QCStringList tests;
+ tests << "cursors" << "schema" << "dbcreation" << "tables"
+ << "tableview" << "parser" << "dr_prop";
+ if (!args->isSet("test")) {
+ kdDebug() << "No test specified. Use --help." << endl;
+ RETURN(1);
+ }
+ test_name = args->getOption("test");
+ if (!tests.contains(test_name)) {
+ kdDebug() << QString("No such test \"%1\". Use --help.").arg(test_name) << endl;
+ RETURN(1);
+ }
+
+ if (test_name=="tableview") {
+ gui = true;
+ }
+ else if (test_name=="parser") {
+ minargs = 3;
+ }
+ else if (test_name=="dr_prop") {
+ minargs = 1;
+ db_name_required = false;
+ }
+ if ((int)args->count()<minargs) {
+ kdDebug() << QString("Not enough args (%1 required). Use --help.").arg(minargs) << endl;
+ RETURN(1);
+ }
+
+ if (gui) {
+ app = new KApplication(true, true);
+ instance = app;
+ KGlobal::iconLoader()->addAppDir("kexi");
+ }
+ else {
+ instance = new KInstance(prgname);
+ }
+
+ drv_name = args->arg(0);
+
+ KexiDB::DriverManager manager;
+ QStringList names = manager.driverNames();
+ kdDebug() << "DRIVERS: " << endl;
+ for (QStringList::ConstIterator it = names.constBegin(); it != names.constEnd() ; ++it)
+ kdDebug() << *it << endl;
+ if (manager.error() || names.isEmpty()) {
+ manager.debugError();
+ RETURN(1);
+ }
+
+ //get driver
+ driver = manager.driver(drv_name);
+ if (!driver || manager.error()) {
+ manager.debugError();
+ RETURN(1);
+ }
+ kdDebug() << "MIME type for '" << driver->name() << "': " << driver->fileDBDriverMimeType() << endl;
+
+ //open connection
+ if (args->count() >= 2)
+ db_name = args->arg(1);
+ if (db_name_required && db_name.isEmpty()) {
+ kdDebug() << prgname << ": database name?" << endl;
+ RETURN(1);
+ }
+ if (!db_name.isEmpty()) {
+ //additional switches:
+ if (args->isSet("buffered-cursors")) {
+ cursor_options |= KexiDB::Cursor::Buffered;
+ }
+ conn_data.setFileName( db_name );
+ conn = driver->createConnection(conn_data);
+
+ if (!conn || driver->error()) {
+ driver->debugError();
+ RETURN(1);
+ }
+ if (!conn->connect()) {
+ conn->debugError();
+ RETURN(1);
+ }
+ }
+
+ //start test:
+ int r=0;
+ if (test_name == "cursors")
+ r=cursorsTest();
+ else if (test_name == "schema")
+ r=schemaTest();
+ else if (test_name == "dbcreation")
+ r=dbCreationTest();
+ else if (test_name == "tables")
+ r=tablesTest();
+ else if (test_name == "tableview")
+ r=tableViewTest();
+ else if (test_name == "parser") {
+ QStringList params;
+ if (args->isSet("query-params"))
+ params = QStringList::split("|", args->getOption("query-params"));
+ r=parserTest(args->arg(2), params);
+ }
+ else if (test_name == "dr_prop")
+ r=drPropTest();
+ else {
+ kdWarning() << "No such test: " << test_name << endl;
+// usage();
+ RETURN(1);
+ }
+
+ if (app && r==0)
+ app->exec();
+
+ if (r)
+ kdDebug() << "RECENT SQL STATEMENT: " << conn->recentSQLString() << endl;
+
+ if (conn && !conn->disconnect())
+ r = 1;
+
+// kdDebug() << "!!! KexiDB::Transaction::globalcount == " << KexiDB::Transaction::globalCount() << endl;
+// kdDebug() << "!!! KexiDB::TransactionData::globalcount == " << KexiDB::TransactionData::globalCount() << endl;
+
+ delete app;
+
+ RETURN(r);
+}
diff --git a/kexi/tests/newapi/mysqlcursor.cpp b/kexi/tests/newapi/mysqlcursor.cpp
new file mode 100644
index 00000000..7f0e9223
--- /dev/null
+++ b/kexi/tests/newapi/mysqlcursor.cpp
@@ -0,0 +1,121 @@
+
+#include <kdebug.h>
+#include <kinstance.h>
+
+#include <kexidb/drivermanager.h>
+#include <kexidb/driver.h>
+#include <kexidb/connection.h>
+#include <kexidb/cursor.h>
+
+int main(int argc, char * argv[])
+{
+ KInstance instance("newapi");
+ KexiDB::DriverManager manager;
+ QStringList names = manager.driverNames();
+ kdDebug() << "DRIVERS: " << endl;
+ for (QStringList::ConstIterator it = names.constBegin(); it != names.constEnd() ; ++it)
+ kdDebug() << *it << endl;
+ if (manager.error()) {
+ kdDebug() << manager.errorMsg() << endl;
+ return 1;
+ }
+
+ //get driver
+ KexiDB::Driver *driver = manager.driver("mySQL");
+ if (manager.error()) {
+ kdDebug() << manager.errorMsg() << endl;
+ return 1;
+ }
+
+ //connection data that can be later reused
+ KexiDB::ConnectionData conn_data;
+
+ conn_data.userName="root";
+ if (argc>1)
+ conn_data.password=argv[1];
+ else
+ conn_data.password="mysql";
+ conn_data.hostName="localhost";
+
+ KexiDB::Connection *conn = driver->createConnection(conn_data);
+ if (driver->error()) {
+ kdDebug() << driver->errorMsg() << endl;
+ return 1;
+ }
+ if (!conn->connect()) {
+ kdDebug() << conn->errorMsg() << endl;
+ return 1;
+ }
+ if (!conn->useDatabase( "test" )) {
+ kdDebug() <<"use db:"<< conn->errorMsg() << endl;
+ return 1;
+ }
+
+ kdDebug()<<"Creating first cursor"<<endl;
+ KexiDB::Cursor *c=conn->executeQuery("select * from Applications");
+ if (!c) kdDebug()<<conn->errorMsg()<<endl;
+ kdDebug()<<"Creating second cursor"<<endl;
+ KexiDB::Cursor *c2=conn->executeQuery("select * from Applications");
+ if (!c2) kdDebug()<<conn->errorMsg()<<endl;
+
+ QStringList l=conn->databaseNames();
+ if (l.isEmpty()) kdDebug()<<conn->errorMsg()<<endl;
+ kdDebug()<<"Databases:"<<endl;
+ for (QStringList::ConstIterator it = l.constBegin(); it != l.constEnd() ; ++it)
+ kdDebug() << *it << endl;
+
+ if (c) {
+ while (c->moveNext()) {
+ kdDebug()<<"Cursor: Value(0)"<<c->value(0).asString()<<endl;
+ kdDebug()<<"Cursor: Value(1)"<<c->value(1).asString()<<endl;
+ }
+ kdDebug()<<"Cursor error:"<<c->errorMsg()<<endl;
+ }
+ if (c2) {
+ while (c2->moveNext()) {
+ kdDebug()<<"Cursor2: Value(0)"<<c2->value(0).asString()<<endl;
+ kdDebug()<<"Cursor2: Value(1)"<<c2->value(1).asString()<<endl;
+ }
+ }
+ if (c) {
+ kdDebug()<<"Cursor::prev"<<endl;
+ while (c->movePrev()) {
+ kdDebug()<<"Cursor: Value(0)"<<c->value(0).asString()<<endl;
+ kdDebug()<<"Cursor: Value(1)"<<c->value(1).asString()<<endl;
+
+ }
+ kdDebug()<<"up/down"<<endl;
+ c->moveNext();
+ kdDebug()<<"Cursor: Value(0)"<<c->value(0).asString()<<endl;
+ kdDebug()<<"Cursor: Value(1)"<<c->value(1).asString()<<endl;
+ c->moveNext();
+ kdDebug()<<"Cursor: Value(0)"<<c->value(0).asString()<<endl;
+ kdDebug()<<"Cursor: Value(1)"<<c->value(1).asString()<<endl;
+ c->movePrev();
+ kdDebug()<<"Cursor: Value(0)"<<c->value(0).asString()<<endl;
+ kdDebug()<<"Cursor: Value(1)"<<c->value(1).asString()<<endl;
+ c->movePrev();
+ kdDebug()<<"Cursor: Value(0)"<<c->value(0).asString()<<endl;
+ kdDebug()<<"Cursor: Value(1)"<<c->value(1).asString()<<endl;
+
+ }
+#if 0
+ KexiDB::Table *t = conn->tableSchema( "persons" );
+ if (t)
+ t->debug();
+ t = conn->tableSchema( "cars" );
+ if (t)
+ t->debug();
+
+// conn->tableNames();
+
+ if (!conn->disconnect()) {
+ kdDebug() << conn->errorMsg() << endl;
+ return 1;
+ }
+ debug("before del");
+ delete conn;
+ debug("after del");
+#endif
+ return 0;
+}
diff --git a/kexi/tests/newapi/mysqlcursortest_create.sql b/kexi/tests/newapi/mysqlcursortest_create.sql
new file mode 100644
index 00000000..750603c1
--- /dev/null
+++ b/kexi/tests/newapi/mysqlcursortest_create.sql
@@ -0,0 +1,41 @@
+-- MySQL dump 9.08
+--
+-- Host: localhost Database: test
+---------------------------------------------------------
+-- Server version 4.0.14
+
+--
+-- Table structure for table 'Applications'
+--
+
+CREATE TABLE Applications (
+ id int(11) NOT NULL default '0',
+ value varchar(20) default NULL,
+ PRIMARY KEY (id)
+) TYPE=MyISAM;
+
+--
+-- Dumping data for table 'Applications'
+--
+
+INSERT INTO Applications VALUES (0,'A');
+INSERT INTO Applications VALUES (1,'B');
+INSERT INTO Applications VALUES (2,'C');
+INSERT INTO Applications VALUES (3,'D');
+INSERT INTO Applications VALUES (4,'E');
+
+--
+-- Table structure for table 'jw1'
+--
+
+CREATE TABLE jw1 (
+ id int(11) NOT NULL default '0',
+ txt varchar(20) default NULL,
+ PRIMARY KEY (id)
+) TYPE=MyISAM;
+
+--
+-- Dumping data for table 'jw1'
+--
+
+
diff --git a/kexi/tests/newapi/mysqlcursortest_expectedoutput b/kexi/tests/newapi/mysqlcursortest_expectedoutput
new file mode 100644
index 00000000..58ce8aa3
--- /dev/null
+++ b/kexi/tests/newapi/mysqlcursortest_expectedoutput
@@ -0,0 +1,128 @@
+KexiDB: DriverManagerInternal::incRefCount(): 1
+kio (KTrader): KServiceTypeProfile::offers( Kexi/DBDriver, )
+kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-jowenn/ksycoca
+kio (KTrader): Returning 2 offers
+KexiDB: KexiDB::DriverManager::lookupDrivers(): registered driver: mySQL(kexidb_mysqldriver)
+KexiDB: KexiDB::DriverManager::lookupDrivers(): registered driver: SQLite(kexidb_sqlitedriver)
+newapi: DRIVERS:
+newapi: SQLite
+newapi: mySQL
+KexiDB: DriverManager::driver(): loading mySQL
+KexiDB: KexiDBInterfaceManager::load(): library: kexidb_mysqldriver
+KexiDB (driver impl): MySqlDriver::MySqlDriver()
+KexiDB: KexiDBInterfaceManager::load(): loading succeed: mySQL
+KexiDB: drv=134779696
+KexiDB (driver impl): MySqlConnection::connect()
+KexiDB: Connection::databaseExists(test,true)
+KexiDB: Connection::databaseNames(true)
+KexiDB (driver impl): MySqlConnection::drv_getDatabasesList()
+newapi: Creating first cursor
+newapi: Creating second cursor
+KexiDB: Connection::databaseNames(false)
+KexiDB (driver impl): MySqlConnection::drv_getDatabasesList()
+KexiDB: Connection::databaseNames(): mysql
+KexiDB: Connection::databaseNames(): test
+KexiDB: add
+newapi: Databases:
+newapi: test
+KexiDB: m_at < m_records_in_buf :: 0 < 0
+KexiDB (driver impl): ==== (buffered) sqlite_step ====
+KexiDB (driver impl): m_at == 1
+newapi: Cursor: Value(0)0
+newapi: Cursor: Value(1)A
+KexiDB: m_at < m_records_in_buf :: 1 < 1
+KexiDB (driver impl): ==== (buffered) sqlite_step ====
+KexiDB (driver impl): m_at == 2
+newapi: Cursor: Value(0)1
+newapi: Cursor: Value(1)B
+KexiDB: m_at < m_records_in_buf :: 2 < 2
+KexiDB (driver impl): ==== (buffered) sqlite_step ====
+KexiDB (driver impl): m_at == 3
+newapi: Cursor: Value(0)2
+newapi: Cursor: Value(1)C
+KexiDB: m_at < m_records_in_buf :: 3 < 3
+KexiDB (driver impl): ==== (buffered) sqlite_step ====
+KexiDB (driver impl): m_at == 4
+newapi: Cursor: Value(0)3
+newapi: Cursor: Value(1)D
+KexiDB: m_at < m_records_in_buf :: 4 < 4
+KexiDB (driver impl): ==== (buffered) sqlite_step ====
+KexiDB (driver impl): m_at == 5
+newapi: Cursor: Value(0)4
+newapi: Cursor: Value(1)E
+KexiDB: m_at < m_records_in_buf :: 5 < 5
+KexiDB (driver impl): ==== (buffered) sqlite_step ====
+KexiDB (driver impl): m_result != FetchOK ********
+newapi: Cursor error:
+KexiDB: m_at < m_records_in_buf :: 0 < 0
+KexiDB (driver impl): ==== (buffered) sqlite_step ====
+KexiDB (driver impl): m_at == 1
+newapi: Cursor2: Value(0)0
+newapi: Cursor2: Value(1)A
+KexiDB: m_at < m_records_in_buf :: 1 < 1
+KexiDB (driver impl): ==== (buffered) sqlite_step ====
+KexiDB (driver impl): m_at == 2
+newapi: Cursor2: Value(0)1
+newapi: Cursor2: Value(1)B
+KexiDB: m_at < m_records_in_buf :: 2 < 2
+KexiDB (driver impl): ==== (buffered) sqlite_step ====
+KexiDB (driver impl): m_at == 3
+newapi: Cursor2: Value(0)2
+newapi: Cursor2: Value(1)C
+KexiDB: m_at < m_records_in_buf :: 3 < 3
+KexiDB (driver impl): ==== (buffered) sqlite_step ====
+KexiDB (driver impl): m_at == 4
+newapi: Cursor2: Value(0)3
+newapi: Cursor2: Value(1)D
+KexiDB: m_at < m_records_in_buf :: 4 < 4
+KexiDB (driver impl): ==== (buffered) sqlite_step ====
+KexiDB (driver impl): m_at == 5
+newapi: Cursor2: Value(0)4
+newapi: Cursor2: Value(1)E
+KexiDB: m_at < m_records_in_buf :: 5 < 5
+KexiDB (driver impl): ==== (buffered) sqlite_step ====
+KexiDB (driver impl): m_result != FetchOK ********
+newapi: Cursor::prev
+newapi: Cursor: Value(0)4
+newapi: Cursor: Value(1)E
+newapi: Cursor: Value(0)3
+newapi: Cursor: Value(1)D
+newapi: Cursor: Value(0)2
+newapi: Cursor: Value(1)C
+newapi: Cursor: Value(0)1
+newapi: Cursor: Value(1)B
+newapi: Cursor: Value(0)0
+newapi: Cursor: Value(1)A
+newapi: up/down
+KexiDB: m_at < m_records_in_buf :: -1 < 5
+KexiDB (driver impl): m_at == 1
+newapi: Cursor: Value(0)0
+newapi: Cursor: Value(1)A
+KexiDB: m_at < m_records_in_buf :: 1 < 5
+KexiDB (driver impl): m_at == 2
+newapi: Cursor: Value(0)1
+newapi: Cursor: Value(1)B
+newapi: Cursor: Value(0)1
+newapi: Cursor: Value(1)B
+newapi: Cursor: Value(0)0
+newapi: Cursor: Value(1)A
+KexiDB: DriverManager::~DriverManager()
+KexiDB: DriverManagerInternal::decRefCount(): 0
+KexiDB: DriverManagerInternal::~DriverManagerInternal()
+KexiDB: Driver::~Driver()
+KexiDB: Cursor::close() == true
+KexiDB: Cursor::~Cursor() 'select * from Applications'
+KexiDB: Cursor::close() == true
+KexiDB: Cursor::~Cursor() 'select * from Applications'
+KexiDB: Connection::closeDatabase(): true
+KexiDB (driver impl): MySqlConnection::disconnect()
+KexiDB: Connection::~Connection()
+KexiDB: ~Transaction(): null
+KexiDB: -- Transaction::globalcount == 0
+KexiDB: ~Transaction(): null
+KexiDB: -- Transaction::globalcount == 0
+KexiDB: Driver::~Driver() ok
+KexiDB: DriverManagerInternal::~DriverManagerInternal() ok
+KexiDB: DriverManager::~DriverManager() ok
+KexiDB: ~Transaction(): null
+KexiDB: -- Transaction::globalcount == 0
diff --git a/kexi/tests/newapi/newapi.pro b/kexi/tests/newapi/newapi.pro
new file mode 100644
index 00000000..9caf6926
--- /dev/null
+++ b/kexi/tests/newapi/newapi.pro
@@ -0,0 +1,33 @@
+TEMPLATE = app
+
+include( $(KEXI)/common.pro )
+
+unix {
+ LIBS += -lkexidb
+}
+
+win32 {
+
+ LIBS += \
+ $$KDELIBDESTDIR/kexicore$$KEXILIB_SUFFIX \
+ $$KDELIBDESTDIR/kexidatatable$$KEXILIB_SUFFIX \
+ $$KDELIBDESTDIR/kexiextendedwidgets$$KEXILIB_SUFFIX
+
+QMAKE_CXXFLAGS += $(KEXI_OPTIONS)
+
+# test specific:
+ LIBS += \
+ $$KDELIBDESTDIR/kexidb$$KEXILIB_SUFFIX
+
+#allow to select target independently from debug information
+ CONFIG += console
+ CONFIG -= windows
+}
+
+DESTDIR = . # no # $KDEDIR/bin
+TARGET = kexidbtest
+
+SOURCES = \
+main.cpp
+
+HEADERS =
diff --git a/kexi/tests/newapi/parser_test.h b/kexi/tests/newapi/parser_test.h
new file mode 100644
index 00000000..14409961
--- /dev/null
+++ b/kexi/tests/newapi/parser_test.h
@@ -0,0 +1,62 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef PARSER_TEST_H
+#define PARSER_TEST_H
+
+int parserTest(const char *st, const QStringList& params)
+{
+ int r = 0;
+
+ if (!conn->useDatabase( db_name )) {
+ conn->debugError();
+ return 1;
+ }
+
+ KexiDB::Parser parser(conn);
+
+ const bool ok = parser.parse(QString::fromLocal8Bit( st ));
+ KexiDB::QuerySchema *q = parser.query();
+ QValueList<QVariant> variantParams;
+ foreach( QStringList::ConstIterator, it, params )
+ variantParams.append(*it);
+ if (ok && q) {
+ cout << q->debugString().latin1() << '\n';
+ cout << "-STATEMENT:\n" << conn->selectStatement( *q, variantParams ).latin1() << '\n';
+ }
+ else {
+ KexiDB::ParserError err = parser.error();
+ kdDebug() << QString("Error = %1\ntype = %2\nat = %3").arg(err.error())
+ .arg(err.type()).arg(err.at()) << endl;
+ r = 1;
+ }
+ delete q;
+ q=0;
+
+
+ if (!conn->closeDatabase()) {
+ conn->debugError();
+ return 1;
+ }
+
+ return r;
+}
+
+#endif
+
diff --git a/kexi/tests/newapi/schema.sql b/kexi/tests/newapi/schema.sql
new file mode 100644
index 00000000..f918c639
--- /dev/null
+++ b/kexi/tests/newapi/schema.sql
@@ -0,0 +1,38 @@
+
+begin;
+
+drop table kexi__objects;
+drop table kexi__fields;
+drop table kexi__querydata;
+drop table kexi__db;
+
+CREATE TABLE kexi__objects (o_id Integer, o_type Byte, o_name Text(200),
+o_caption Text, o_help LongText);
+
+CREATE TABLE kexi__fields (t_id Integer, f_type Byte, f_name Text(200),
+f_length Integer, f_precision Integer,
+f_constraints Integer, f_options Integer, f_order Integer,
+f_caption Text(200), f_help Text);
+
+CREATE TABLE kexi__querydata (q_id Integer, q_sql LongText, q_valid Boolean );
+
+CREATE TABLE kexi__parts (p_id Integer, p_name Text, p_mime Text, p_url Text);
+
+CREATE TABLE kexi__db (db_property Text(32), db_value LongText );
+
+insert into kexi__objects values (1, 1, 'persons', 'Persons', 'Persons group in our factory');
+insert into kexi__fields values (1, 3, 'id', 0, 0, 16, 0, 0, null, null);
+insert into kexi__fields values (1, 1, 'age', 0, 0, 16, 0, 1, null, null);
+insert into kexi__fields values (1, 11, 'name', 30, 0, 16, 0, 2, null, null);
+insert into kexi__fields values (1, 11, 'surname', 30, 0, 16, 0, 3, null, null);
+
+insert into kexi__objects values (2, 1, 'cars', 'Cars', 'Cars owned by persons');
+insert into kexi__fields values (2, 3, 'id', 0, 0, 16, 0, 0, null, null);
+insert into kexi__fields values (2, 3, 'owner', 0, 0, 16, 0, 1, null, null);
+insert into kexi__fields values (2, 11, 'model', 30, 0, 16, 0, 2, null, null);
+
+insert into kexi__db values ('kexidb_major_ver', '1');
+insert into kexi__db values ('kexidb_minor_ver', '2');
+
+commit;
+
diff --git a/kexi/tests/newapi/schema_test.h b/kexi/tests/newapi/schema_test.h
new file mode 100644
index 00000000..6eec76d1
--- /dev/null
+++ b/kexi/tests/newapi/schema_test.h
@@ -0,0 +1,55 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SCHEMA_TEST_H
+#define SCHEMA_TEST_H
+
+int schemaTest()
+{
+ if (!conn->useDatabase( db_name )) {
+ kdDebug() << conn->errorMsg() << endl;
+ return 1;
+ }
+
+ KexiDB::TableSchema *t = conn->tableSchema( "persons" );
+ if (t)
+ t->debug();
+ else
+ kdDebug() << "!persons" << endl;
+ t = conn->tableSchema( "cars" );
+ if (t)
+ t->debug();
+ else
+ kdDebug() << "!cars" << endl;
+/*
+// some tests
+ {
+ KexiDB::Field::ListIterator iter = t->fieldsIterator();
+ KexiDB::Field::List *lst = t->fields();
+ lst->clear();
+ for (;iter.current();++iter) {
+ kdDebug() << "FIELD=" << iter.current()->name() << endl;
+// iter.current()->setName(" ");
+ }
+ }*/
+ return 0;
+}
+
+#endif
+
diff --git a/kexi/tests/newapi/sqltest b/kexi/tests/newapi/sqltest
new file mode 100755
index 00000000..cd63134b
--- /dev/null
+++ b/kexi/tests/newapi/sqltest
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# sqltest - fast parser testing using sqlite database.
+# Type sqltest --help for usage info.
+# Copyright (C) 2004, 2006 Jaroslaw Staniek <js@iidea.pl>
+
+[ $# -lt 1 ] && echo "Usage: $0 <sqlite-database-name> <sql-statement> [-v] [other_options]" && \
+ echo " -v Verbose mode" && exit 1
+
+dbname=$1
+shift
+
+sql=$1
+shift
+
+verbose=0
+if [ "$1" = "-v" ] ; then
+ verbose=1
+ shift
+fi
+
+temp=`mktemp /tmp/$0.XXXXXX`
+
+./kexidbtest -test parser sqlite3 "$dbname" "$sql" $* 2> $temp || \
+ cat $temp && test "$verbose" -eq 1 && cat $temp
+
+rm -f $temp
diff --git a/kexi/tests/newapi/sqltest_int b/kexi/tests/newapi/sqltest_int
new file mode 100755
index 00000000..6cbe47ac
--- /dev/null
+++ b/kexi/tests/newapi/sqltest_int
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# sqltest_int - fast parser testing using sqlite database (interactive)
+# Type sqltest_int for usage info.
+
+[ $# -lt 1 ] && echo "Usage: $0 <sqlite-database-name> [-v] [other_options]" && \
+ echo " -v Verbose mode" && exit 1
+
+dbname=$1
+shift
+
+echo "Enter SQL Statement:"
+read
+
+./sqltest "$dbname" "$REPLY" $*
diff --git a/kexi/tests/newapi/statements.txt b/kexi/tests/newapi/statements.txt
new file mode 100644
index 00000000..3d108ce7
--- /dev/null
+++ b/kexi/tests/newapi/statements.txt
@@ -0,0 +1,89 @@
+---------- TOPIC000: GENERAL ISSUES --------------
+-- OK000: the same field used in two columns
+select id, id from persons;
+-- OK001: whitespace between table-identifier, dot field-identifier/asterisk
+select persons . id from persons;
+select persons . * from persons;
+-- OK002: multiple asterisks
+select *, * from persons;
+-- ER003: identifier cannot start with a number
+select 1id from persons;
+-- ER004: asterisk not allowed: no tables specified
+select *;
+-- OK005: empty tables set
+select 1, 2;
+-- OK006: empty column set (KEXISQL EXTENSION!)
+select from cars;
+-- OK007: totally empty statement (KEXISQL EXTENSION!)
+select;
+
+---------- TOPIC100: ALIASES IN SELECT STATEMENT --------------
+-- OK100: aliases for columns
+select id myid from persons;
+-- OK101: aliases for tables
+select id from persons p;
+-- ER102: there's no "persons" table in this query (alias "p" covers it)
+select persons.id from persons p;
+-- OK103: alias "p" for table "persons" is used
+select p.id from persons p;
+-- OK104: multiple aliases for the same table
+select persons.id from persons, persons p, persons p2
+-- ER105: column "id" is defined in both tables (so "id" column is ambiguous)
+select id from persons p, cars p;
+-- ER106: alias "p" is used twice for tables and both have "id" column (so "p" column is ambiguous)
+select p.id from persons p, cars p;
+select p.* from persons p, cars p;
+select persons.* from persons, cars persons;
+-- ER107: alias not allowed for asterisk
+select * as c from cars;
+select cars.* as c from cars;
+
+---------- TOPIC200: EXPRESSIONS IN COLUMNS OF SELECT STATEMENT --------------
+-- OK200: like ER106, but it's ok, because we're not using fields from "p" tables
+select 1 from persons p, cars p;
+-- OK201: complex expressions support, operators precedence, and brackets
+select NULL IS NOT NULL from cars;
+select 2+3*4 from cars;
+select (2+3)*4 from cars;
+-- OK202: support for aliases for complex-expression columns
+select (2+3)*4 from cars;
+-- ER203: column names are invalidated inside a complex expressions
+select one*two from persons;
+-- ER204: like ER106, but ambiguous column is inside a complex expression
+select id*2 from persons p, cars p;
+
+---------- TOPIC300: EXPRESSIONS IN 'WHERE' SECTION OF SELECT STATEMENT --------------
+-- OK300: complex expressions in WHERE section
+select id from cars where (id > 2 OR cars.owner IS NULL) AND NOT 2 * id < 5;
+
+---------- TOPIC400: 'ORDER BY' SECTION OF SELECT STATEMENT --------------
+-- OK400: simple ORDER BY
+select id from cars order by id;
+-- OK401: simple ORDER BY with DESC
+select id from cars order by id DESC;
+-- OK402: simple ORDER BY with ASC
+select id from cars order by id ASC;
+-- OK403: simple ORDER BY with WHERE
+select id from cars order by id WHERE id < 5;
+-- OK404: simple ORDER BY with WHERE; opposite direction
+select id from cars WHERE id < 5 order by id;
+-- OK405: simple ORDER BY, sorting field 'owner' is not in the list of displayed fields
+select id from cars order by owner;
+-- OK406: ORDER BY with many arguments
+select id from cars order by owner, model, id;
+-- OK407: ORDER BY where column numbers are used instead of names
+select id, model from cars order by 2, 1;
+-- ER408: ORDER BY column number 2 out of range - should be between 1 and 1
+-- (there's only one visible field)
+select id from cars order by 2, 1;
+
+---------- TOPIC500: EXPRESSIONS --------------
+-- OK500: operators precedence: arithmetic before relational
+select 1 + 2 < 3;
+-- OK501: *,/ before +,-
+select 1+2*3;
+-- OK501: unary expressions before binary expressions
+select 1+-2;
+
+-- TODO
+-'--' comments
diff --git a/kexi/tests/newapi/tables_test.h b/kexi/tests/newapi/tables_test.h
new file mode 100644
index 00000000..67516db0
--- /dev/null
+++ b/kexi/tests/newapi/tables_test.h
@@ -0,0 +1,117 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef TABLETEST_H
+#define TABLETEST_H
+
+int tablesTest()
+{
+ if (dbCreationTest()!=0)
+ return 1;
+
+ if (!conn->useDatabase( db_name )) {
+ conn->debugError();
+ return 1;
+ }
+
+ conn->setAutoCommit(false);
+ KexiDB::Transaction t = conn->beginTransaction();
+ if (conn->error()) {
+ conn->debugError();
+ return 1;
+ }
+
+ //now: lets create tables:
+ KexiDB::Field *f;
+ KexiDB::TableSchema *t_persons = new KexiDB::TableSchema("persons");
+ t_persons->setCaption("Persons in our factory");
+ t_persons->addField( f=new KexiDB::Field("id", KexiDB::Field::Integer, KexiDB::Field::PrimaryKey | KexiDB::Field::AutoInc, KexiDB::Field::Unsigned) );
+ f->setCaption("ID");
+ t_persons->addField( f=new KexiDB::Field("age", KexiDB::Field::Integer, 0, KexiDB::Field::Unsigned) );
+ f->setCaption("Age");
+ t_persons->addField( f=new KexiDB::Field("name", KexiDB::Field::Text) );
+ f->setCaption("Name");
+ t_persons->addField( f=new KexiDB::Field("surname", KexiDB::Field::Text) );
+ f->setCaption("Surname");
+ if (!conn->createTable( t_persons )) {
+ conn->debugError();
+ return 1;
+ }
+ kdDebug() << "-- PERSONS created --" << endl;
+ t_persons->debug();
+
+ if (!conn->insertRecord(*t_persons, QVariant(1), QVariant(27), QVariant("Jaroslaw"), QVariant("Staniek"))
+ ||!conn->insertRecord(*t_persons, QVariant(2), QVariant(60), QVariant("Lech"), QVariant("Walesa"))
+ ||!conn->insertRecord(*t_persons, QVariant(3), QVariant(45), QVariant("Bill"), QVariant("Gates"))
+ ||!conn->insertRecord(*t_persons, QVariant(4), QVariant(35), QVariant("John"), QVariant("Smith"))
+ )
+ {
+ kdDebug() << "-- PERSONS data err. --" << endl;
+ return 1;
+ }
+ kdDebug() << "-- PERSONS data created --" << endl;
+
+
+ KexiDB::TableSchema *t_cars = new KexiDB::TableSchema("cars");
+ t_cars->setCaption("Cars owned by persons");
+ t_cars->addField( f=new KexiDB::Field("id", KexiDB::Field::Integer, KexiDB::Field::PrimaryKey | KexiDB::Field::AutoInc, KexiDB::Field::Unsigned) );
+ f->setCaption("ID");
+ t_cars->addField( f=new KexiDB::Field("owner", KexiDB::Field::Integer, 0, KexiDB::Field::Unsigned) );
+ f->setCaption("Car owner");
+ t_cars->addField( f=new KexiDB::Field("model", KexiDB::Field::Text) );
+ f->setCaption("Car model");
+ if (!conn->createTable( t_cars )) {
+ conn->debugError();
+ return 1;
+ }
+ kdDebug() << "-- CARS created --" << endl;
+ if (!conn->insertRecord(*t_cars, QVariant(1), QVariant(1), QVariant("Fiat"))
+ ||!conn->insertRecord(*t_cars, QVariant(2), QVariant(2), QVariant("Syrena"))
+ ||!conn->insertRecord(*t_cars, QVariant(3), QVariant(3), QVariant("Chrysler"))
+ ||!conn->insertRecord(*t_cars, QVariant(4), QVariant(3), QVariant("BMW"))
+ ||!conn->insertRecord(*t_cars, QVariant(5), QVariant(4), QVariant("Volvo"))
+ )
+ {
+ kdDebug() << "-- CARS data err. --" << endl;
+ return 1;
+ }
+ kdDebug() << "-- CARS data created --" << endl;
+
+ if (!conn->commitTransaction(t)) {
+ conn->debugError();
+ return 1;
+ }
+
+ kdDebug() << "NOW, TABLE LIST: " << endl;
+ QStringList tnames = conn->tableNames();
+ for (QStringList::iterator it = tnames.begin(); it!=tnames.end(); ++it) {
+ kdDebug() << " - " << (*it) << endl;
+ }
+
+
+ if (!conn->closeDatabase()) {
+ conn->debugError();
+ return 1;
+ }
+
+ return 0;
+}
+
+#endif
+
diff --git a/kexi/tests/newapi/tableview_test.h b/kexi/tests/newapi/tableview_test.h
new file mode 100644
index 00000000..2b5ef6c8
--- /dev/null
+++ b/kexi/tests/newapi/tableview_test.h
@@ -0,0 +1,60 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef TABLEVIEW_TEST_H
+#define TABLEVIEW_TEST_H
+
+#include <widget/tableview/kexidatatableview.h>
+#include <kexidb/cursor.h>
+
+int tableViewTest()
+{
+ if (!conn->useDatabase( db_name )) {
+ conn->debugError();
+ return 1;
+ }
+
+ KexiDB::TableSchema *persons = conn->tableSchema( "persons" );
+ if (!persons) {
+ conn->debugError();
+ kdDebug() << "tableViewTest(): !persons" <<endl;
+ return 1;
+ }
+
+// KexiTableView *tv = new KexiTableView(0, "tv", /*KexiTableList *contents=*/0);
+// KexiDB::Cursor *cursor = conn->executeQuery( "select * from persons", KexiDB::Cursor::Buffered );
+ KexiDB::Cursor *cursor = conn->prepareQuery( *persons , cursor_options );//KexiDB::Cursor::Buffered );
+ if (!cursor) {
+ conn->debugError();
+ kdDebug() << "tableViewTest(): !cursor" <<endl;
+ return 1;
+ }
+
+ KexiDataTableView *tv = new KexiDataTableView(0, "tv", cursor);
+
+ app->setMainWidget(tv);
+ tv->move((qApp->desktop()->width() - tv->width())/2, (qApp->desktop()->height() - tv->height())/2);
+ tv->show();
+ tv->setFocus();
+
+ return 0;
+}
+
+#endif
+
diff --git a/kexi/tests/parser/Makefile.am b/kexi/tests/parser/Makefile.am
new file mode 100644
index 00000000..ec1a3441
--- /dev/null
+++ b/kexi/tests/parser/Makefile.am
@@ -0,0 +1,13 @@
+include $(top_srcdir)/kexi/Makefile.global
+
+bin_PROGRAMS = kexidbparser
+
+noinst_PROGRAMS = kexidbparser
+
+INCLUDES = -I$(top_srcdir)/kexi $(all_includes)
+
+kexidbparser_SOURCES = main.cpp
+kexidbparser_LDADD = $(LIB_QT) $(LIB_KDECORE) $(top_builddir)/kexi/kexidb/libkexidb.la $(top_builddir)/kexi/kexidb/parser/libkexidbparser.la $(all_libraries)
+kexidbparser_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(VER_INFO) --no-undefined
+
+
diff --git a/kexi/tests/parser/README b/kexi/tests/parser/README
new file mode 100644
index 00000000..d6f2ed44
--- /dev/null
+++ b/kexi/tests/parser/README
@@ -0,0 +1,9 @@
+Parser - Interactive test of KEXISQL parser
+
+Usage:
+<program_name> <driver_name> <db_name>
+
+Notes:
+<driver_name> can be just any existing - no database is changed, but only opened
+because of parser requirements.
+Predefined "db" database file for sqlite is available in this dir.
diff --git a/kexi/tests/parser/db b/kexi/tests/parser/db
new file mode 100644
index 00000000..d27cda22
--- /dev/null
+++ b/kexi/tests/parser/db
Binary files differ
diff --git a/kexi/tests/parser/main.cpp b/kexi/tests/parser/main.cpp
new file mode 100644
index 00000000..f6ee5742
--- /dev/null
+++ b/kexi/tests/parser/main.cpp
@@ -0,0 +1,103 @@
+#include <iostream>
+#include <string>
+
+#include <qfileinfo.h>
+
+#include <kdebug.h>
+#include <kinstance.h>
+
+#include <kexidb/drivermanager.h>
+#include <kexidb/driver.h>
+#include <kexidb/connection.h>
+#include <kexidb/cursor.h>
+#include <kexidb/parser/parser.h>
+
+using namespace std;
+QCString prgname;
+
+int main(int argc, char **argv)
+{
+ kdDebug() << "main()" << endl;
+ QFileInfo info=QFileInfo(argv[0]);
+ prgname = info.baseName().latin1();
+ KInstance instance( prgname );
+ if (argc<2) {
+ return 1;
+ }
+ QCString drv_name(argv[1]);
+ QCString db_name = QString(argv[2]).lower().latin1();
+
+ KexiDB::DriverManager manager; // = KexiDB::DriverManager::self();
+ QStringList names = manager.driverNames();
+ kdDebug() << "DRIVERS: " << endl;
+ for (QStringList::ConstIterator it = names.constBegin(); it != names.constEnd() ; ++it)
+ kdDebug() << *it << endl;
+ if (manager.error()) {
+ kdDebug() << manager.errorMsg() << endl;
+ return 1;
+ }
+
+ //get driver
+ KexiDB::Driver *driver = manager.driver(drv_name);
+ if (!driver || manager.error()) {
+ kdDebug() << manager.errorMsg() << endl;
+ return 1;
+ }
+
+ //connection data that can be later reused
+ KexiDB::ConnectionData conn_data;
+ conn_data.setFileName(db_name);
+
+ KexiDB::Connection *conn = driver->createConnection(conn_data);
+ if (!conn || driver->error()) {
+ kdDebug() << "error: " << driver->errorMsg() << endl;
+ return 1;
+ }
+ if (!conn->connect()) {
+ kdDebug() << "error: " << conn->errorMsg() << endl;
+ return 1;
+ }
+ if (!conn->useDatabase( db_name )) {
+ kdDebug() << "error: " << conn->errorMsg() << endl;
+ return 1;
+ }
+
+ KexiDB::Parser *parser = new KexiDB::Parser(conn);
+
+ std::string cmd;
+ while(cmd != "quit")
+ {
+ std::cout << "SQL> ";
+ getline(std::cin, cmd);
+ parser->parse(cmd.c_str());
+ switch(parser->operation())
+ {
+ case KexiDB::Parser::OP_Error:
+ kdDebug() << "***********************" << endl;
+ kdDebug() << "* error *" << endl;
+ kdDebug() << "***********************" << endl;
+ break;
+ case KexiDB::Parser::OP_CreateTable:
+ {
+ kdDebug() << "Schema of table: " << parser->table()->name() << endl;
+ parser->table()->debug();
+ break;
+ }
+ case KexiDB::Parser::OP_Select:
+ {
+ kdDebug() << "Select statement: " << endl;
+ KexiDB::QuerySchema *q = parser->query();
+ q->debug();
+ delete q;
+ break;
+ }
+ default:
+ kdDebug() << "main(): not implemented in main.cpp" << endl;
+
+
+ }
+ parser->clear();
+ }
+ return 0;
+}
+
diff --git a/kexi/tests/parser/parser.pro b/kexi/tests/parser/parser.pro
new file mode 100644
index 00000000..4629417a
--- /dev/null
+++ b/kexi/tests/parser/parser.pro
@@ -0,0 +1,24 @@
+TEMPLATE = app
+
+include( $(KEXI)/common.pro )
+
+win32 {
+
+QMAKE_CXXFLAGS += $(KEXI_OPTIONS)
+
+# test specific:
+ LIBS += \
+ $$KDELIBDESTDIR/kexidb$$KEXILIB_SUFFIX
+
+#allow to select target independently from debug information
+ CONFIG += console
+ CONFIG -= windows
+}
+
+DESTDIR = . # no # $KDEDIR/bin
+TARGET = parser
+
+SOURCES = \
+main.cpp
+
+HEADERS =
diff --git a/kexi/tests/startup/Makefile.am b/kexi/tests/startup/Makefile.am
new file mode 100644
index 00000000..ab6cc9c5
--- /dev/null
+++ b/kexi/tests/startup/Makefile.am
@@ -0,0 +1,19 @@
+include $(top_srcdir)/kexi/Makefile.global
+
+bin_PROGRAMS = kexistartuptest
+
+noinst_PROGRAMS = kexistartuptest
+
+INCLUDES = -I$(top_srcdir)/kexi $(all_includes)
+
+SUBDIRS = .
+
+METASOURCES = AUTO
+
+kexistartuptest_SOURCES = main.cpp
+kexistartuptest_LDADD = $(LIB_QT) $(LIB_KDECORE) $(top_builddir)/kexi/kexidb/libkexidb.la \
+ $(top_builddir)/kexi/core/libkexicore.la \
+ $(all_libraries)
+
+kexistartuptest_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(VER_INFO) --no-undefined
+
diff --git a/kexi/tests/startup/main.cpp b/kexi/tests/startup/main.cpp
new file mode 100644
index 00000000..dd2e86ce
--- /dev/null
+++ b/kexi/tests/startup/main.cpp
@@ -0,0 +1,119 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <kdebug.h>
+#include <kapplication.h>
+
+//#include <tableview/kexitableview.h>
+/*#include <kexidb/drivermanager.h>
+#include <kexidb/driver.h>
+#include <kexidb/connection.h>
+#include <kexidb/cursor.h>*/
+
+#include "main/startup/KexiStartupDialog.h"
+#include "main/startup/KexiConnSelector.h"
+#include "core/kexiprojectset.h"
+#include "core/kexiprojectdata.h"
+
+int main(int argc, char* argv[])
+{
+ KApplication app(argc, argv, "startup");
+
+// Widget w;
+// app.setMainWidget(&w);
+
+/* KexiTableView tv;
+ app.setMainWidget(&tv);
+
+ KexiTableViewData data;
+ KexiTableViewColumn col;
+ col.type = QVariant::Int; col.caption = "Id"; data.addColumn( col );
+ col.type = QVariant::String; col.caption = "Name"; data.addColumn( col );
+ col.type = QVariant::Int; col.caption = "Age"; data.addColumn( col );
+ tv.setData(&data, false);
+ tv.show();*/
+
+ //some connection data
+ KexiDBConnectionSet connset;
+ KexiDB::ConnectionData *conndata;
+ conndata = new KexiDB::ConnectionData();
+ conndata->name = "My connection 1";
+ conndata->driverName = "mysql";
+ conndata->hostName = "host.net";
+ conndata->userName = "user";
+ connset.addConnectionData(conndata);
+ conndata = new KexiDB::ConnectionData();
+ conndata->name = "My connection 2";
+ conndata->driverName = "mysql";
+ conndata->hostName = "myhost.org";
+ conndata->userName = "otheruser";
+ conndata->port = 53121;
+ connset.addConnectionData(conndata);
+
+ //some recent projects data
+ KexiProjectData *prjdata;
+ prjdata = new KexiProjectData( *conndata, "bigdb", "Big DB" );
+ prjdata->setCaption("My Big Project");
+ prjdata->setDescription("This is my first biger project started yesterday. Have fun!");
+ KexiProjectSet prj_set;
+ prj_set.addProjectData(prjdata);
+
+ KexiStartupDialog startup(KexiStartupDialog::Everything, 0, connset, prj_set, 0, "dlg");
+ int e=startup.exec();
+ kdDebug() << (e==QDialog::Accepted ? "Accepted" : "Rejected") << endl;
+
+ if (e==QDialog::Accepted) {
+ int r = startup.result();
+ if (r==KexiStartupDialog::TemplateResult) {
+ kdDebug() << "Template key == " << startup.selectedTemplateKey() << endl;
+ if (startup.selectedTemplateKey()=="blank") {
+#if 0
+ KexiConnSelectorDialog sel(connset, 0,"sel");
+ e = sel.exec();
+ kdDebug() << (e==QDialog::Accepted ? "Accepted" : "Rejected") << endl;
+ if (e==QDialog::Accepted) {
+ kdDebug() << "Selected conn. type: " << (sel.selectedConnectionType()==KexiConnSelectorWidget::FileBased ? "File based" : "Server based") << endl;
+ if (sel.selectedConnectionType()==KexiConnSelectorWidget::ServerBased) {
+ kdDebug() << "SERVER: " << sel.selectedConnectionData()->serverInfoString() << endl;
+ }
+ }
+#endif
+ }
+ }
+ else if (r==KexiStartupDialog::OpenExistingResult) {
+ kdDebug() << "Existing project --------" << endl;
+ QString selFile = startup.selectedExistingFile();
+ if (!selFile.isEmpty())
+ kdDebug() << "Project File: " << selFile << endl;
+ else if (startup.selectedExistingConnection()) {
+ kdDebug() << "Existing connection: " << startup.selectedExistingConnection()->serverInfoString() << endl;
+ //ok, now we are trying to show daabases for this conenction to this user
+ //todo
+ }
+ }
+ else if (r==KexiStartupDialog::OpenRecentResult) {
+ kdDebug() << "Recent project --------" << endl;
+ const KexiProjectData *data = startup.selectedProjectData();
+ if (data) {
+ kdDebug() << "Selected project: database=" << data->databaseName()
+ << " connection=" << data->constConnectionData()->serverInfoString() << endl;
+ }
+ }
+ }
+}
diff --git a/kexi/tests/startup/testdb.kexis b/kexi/tests/startup/testdb.kexis
new file mode 100644
index 00000000..06a558aa
--- /dev/null
+++ b/kexi/tests/startup/testdb.kexis
@@ -0,0 +1,63 @@
+#
+# This file contains information for accessing Kexi project(s)
+# stored on a database server
+#
+# Description: The file can contain one special "File Information"
+# section and one or more sections for defining database connections.
+#
+
+[File Information]
+# Version information for this file format, "1" is by default.
+# You can forget about adding this.
+version=1
+
+# begin of section for a shortcut to a single database
+[Test Database]
+
+# The type of this section. Can be:
+# - database: a single database project together with
+# it's connection parameters
+# - connection: connection arameters only, without database name
+# user will be able to see a list of databases provided
+# for the connection and open one of them. (not yet implemented)
+type=database
+
+# Database driver (engine) name like: mysql, postgresql.
+engine=mysql
+
+# Additional human-readable caption for informational purposes.
+caption=Test Project
+
+# Database name, or connection name, depending on type of this section.
+name=testdb
+
+# Server name, for local connection. Can be empty or equal to "localhost".
+server=localhost
+
+# TCP/IP port, leave it empty if default port for a given
+# engine should be used.
+port=3333
+
+# Username, leave empty if you want to reuse your login name.
+user=testuser
+
+# User password (DANGEROUS: currently plain text!).
+# Leave it empty, and you will be asked for password everytime
+# you're opening your database.
+# KDE Wallet will be supported in the future.
+password=testy
+
+# Additional (probably multiline) human-readable caption
+# for informational purposes. Line endings should be netered as \n.
+comment=My favourite test project
+
+# Set this to 1, if you want to use socket file (named pipe)
+# instead of TCP/IP for your local connection here.
+# Ignored for remote connections.
+useLocalSocketFile=0
+
+# Enter local socket file name (named pipe) for your local connection here.
+# Leave it empty if you want to use default socket file.
+# Ignored for remote connections.
+localSocketFile=
+
diff --git a/kexi/tests/tableview/Makefile.am b/kexi/tests/tableview/Makefile.am
new file mode 100644
index 00000000..714b5a62
--- /dev/null
+++ b/kexi/tests/tableview/Makefile.am
@@ -0,0 +1,16 @@
+include $(top_srcdir)/kexi/Makefile.global
+
+bin_PROGRAMS = kexitableviewtest #kexidbfirebirdcursor
+
+noinst_PROGRAMS = kexitableviewtest
+
+INCLUDES = -I$(top_srcdir)/kexi $(all_includes)
+
+SUBDIRS = .
+
+METASOURCES = AUTO
+
+kexitableviewtest_SOURCES = main.cpp
+kexitableviewtest_LDADD = $(LIB_QT) $(LIB_KDECORE) $(top_builddir)/kexi/kexidb/libkexidb.la $(top_builddir)/kexi/widget/libkexiextendedwidgets.la $(all_libraries)
+kexitableviewtest_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(VER_INFO) --no-undefined
+
diff --git a/kexi/tests/tableview/README b/kexi/tests/tableview/README
new file mode 100644
index 00000000..e389d8e9
--- /dev/null
+++ b/kexi/tests/tableview/README
@@ -0,0 +1,3 @@
+Parser - Test for not-data-aware KexiTableView widget
+
+Usage: just run the program.
diff --git a/kexi/tests/tableview/main.cpp b/kexi/tests/tableview/main.cpp
new file mode 100644
index 00000000..90a51b5f
--- /dev/null
+++ b/kexi/tests/tableview/main.cpp
@@ -0,0 +1,53 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+
+#include <tableview/kexitableview.h>
+
+/*#include <kexidb/drivermanager.h>
+#include <kexidb/driver.h>
+#include <kexidb/connection.h>
+#include <kexidb/cursor.h>*/
+
+int main(int argc, char* argv[])
+{
+ KApplication app(argc, argv, "tv_test");
+ KGlobal::iconLoader()->addAppDir("kexi");
+
+ KexiTableView tv;
+
+ KexiTableViewData data;
+ KexiDB::Field f1("id",KexiDB::Field::Integer),
+ f2("name",KexiDB::Field::Text),
+ f3("age",KexiDB::Field::Integer);
+ data.addColumn( new KexiTableViewColumn(f1) );
+ data.addColumn( new KexiTableViewColumn(f2) );
+ data.addColumn( new KexiTableViewColumn(f3) );
+
+ tv.setData(&data, false);
+
+ app.setMainWidget(&tv);
+ tv.show();
+
+ return app.exec();
+}
diff --git a/kexi/tests/tableview/tableview.pro b/kexi/tests/tableview/tableview.pro
new file mode 100644
index 00000000..bd851f80
--- /dev/null
+++ b/kexi/tests/tableview/tableview.pro
@@ -0,0 +1,32 @@
+TEMPLATE = app
+
+include( $(KEXI)/common.pro )
+
+unix {
+ LIBS += -lkexidb
+}
+
+win32 {
+
+ LIBS += \
+ $$KDELIBDESTDIR/kexicore$$KEXILIB_SUFFIX \
+ $$KDELIBDESTDIR/kexidatatable$$KEXILIB_SUFFIX \
+ $$KDELIBDESTDIR/kexiextendedwidgets$$KEXILIB_SUFFIX
+
+# test specific:
+ LIBS += \
+ $$KDELIBDESTDIR/kexidb$$KEXILIB_SUFFIX \
+ $$KDELIBDESTDIR/kexiwidgets$$KEXILIB_SUFFIX
+
+#allow to select target independently from debug information
+ CONFIG += console
+ CONFIG -= windows
+}
+
+DESTDIR = .
+TARGET = tableview
+
+SOURCES = \
+main.cpp
+
+HEADERS =
diff --git a/kexi/tests/tests.pro b/kexi/tests/tests.pro
new file mode 100644
index 00000000..65a90fd1
--- /dev/null
+++ b/kexi/tests/tests.pro
@@ -0,0 +1,6 @@
+TEMPLATE = subdirs
+
+SUBDIRS += newapi
+
+#parser
+
diff --git a/kexi/tests/widgets/Makefile.am b/kexi/tests/widgets/Makefile.am
new file mode 100644
index 00000000..83fe29f8
--- /dev/null
+++ b/kexi/tests/widgets/Makefile.am
@@ -0,0 +1,14 @@
+include $(top_srcdir)/kexi/Makefile.global
+
+noinst_PROGRAMS = kexidbdrivercombotest
+
+INCLUDES = -I$(top_srcdir)/kexi $(all_includes)
+
+kexidbdrivercombotest_SOURCES = kexidbdrivercombotest.cpp
+kexidbdrivercombotest_LDADD = $(LIB_QT) $(LIB_KDECORE) \
+ $(top_builddir)/kexi/kexidb/libkexidb.la \
+ $(top_builddir)/kexi/widget/libkexiextendedwidgets.la
+kexidbdrivercombotest_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+METASOURCES = AUTO
+
diff --git a/kexi/tests/widgets/kexidbdrivercombotest.cpp b/kexi/tests/widgets/kexidbdrivercombotest.cpp
new file mode 100644
index 00000000..8feb56fa
--- /dev/null
+++ b/kexi/tests/widgets/kexidbdrivercombotest.cpp
@@ -0,0 +1,76 @@
+/***************************************************************************
+ * This file is part of the KDE project *
+ * Copyright (C) 2005 Martin Ellis <martin.ellis@kdemail.net> *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining *
+ * a copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, sublicense, and/or sell copies of the Software, and to *
+ * permit persons to whom the Software is furnished to do so, subject to *
+ * the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be *
+ * included in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR *
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
+ * OTHER DEALINGS IN THE SOFTWARE. *
+ ***************************************************************************/
+
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <kdebug.h>
+#include <kcmdlineargs.h>
+#include <kapplication.h>
+#include <kinstance.h>
+
+#include <kexidb/drivermanager.h>
+#include <widget/kexidbdrivercombobox.h>
+
+/*
+ This is an example of the KexiDBDriverComboBox class, used to
+ allow the user to pick a database driver.
+
+ When run it shows two comboboxes. The top one allows the user to
+ pick any database driver. The second allows the user to pick
+ any of the drivers for database servers (i.e. it does not include
+ file based drivers).
+*/
+
+int main(int argc, char** argv)
+{
+ // Initialise the program
+ KCmdLineArgs::init(argc, argv, "kexidbcomboboxtest", "", "", "", true);
+ KApplication* app = new KApplication(true, true);
+
+ // Look for installed database drivers
+ KexiDB::DriverManager manager;
+ KexiDB::Driver::InfoMap drvs = manager.driversInfo();
+
+ // Set up a combo box and a quit widget in a new container
+ QWidget* vbox = new QWidget();
+ QVBoxLayout* vbLayout = new QVBoxLayout(vbox);
+
+ KexiDBDriverComboBox* all = new KexiDBDriverComboBox(vbox, drvs);
+ KexiDBDriverComboBox* srvOnly = new KexiDBDriverComboBox(vbox, drvs,
+ KexiDBDriverComboBox::ShowServerDrivers);
+
+ QPushButton* quit = new QPushButton("Quit", vbox);
+
+ vbLayout->addWidget(all); // Combobox listing all drivers
+ vbLayout->addWidget(srvOnly); // Combobox only drivers for DB servers
+ vbLayout->addWidget(quit);
+
+ // Show the whole lot
+ QObject::connect(quit, SIGNAL(clicked()), app, SLOT(quit()));
+ vbox->show();
+ app->exec();
+
+ delete app;
+}
+