#include "keduvocdocument.h"
#include "keduvoclesson.h"
#include "keduvocexpression.h"
+#include "keduvocleitnerbox.h"
#include <QTemporaryFile>
-
+#include <QDebug>
+#include <QList>
class RmzTest : public QObject
{
const QString comment = QString::fromLatin1( "comment" );
const QString category = QString::fromLatin1( "test document" );
const QString title = QString::fromLatin1( "Validator Test Title" );
+ const QString lang1 = QString::fromLatin1( "English" );
+ const QString lang2 = QString::fromLatin1( "German" );
+ const QString locale1 = QString::fromLatin1( "en" );
+ const QString locale2 = QString::fromLatin1( "de" );
+ const QString translation1 = QString::fromLatin1( "this is English" );
+ const QString translation2 = QString::fromLatin1( "das ist Deutsch" );
+ const QString lessonName = QString::fromLatin1( "Lesson No 1" );
KEduVocDocument doc;
doc.setAuthor( author );
doc.appendIdentifier();
doc.appendIdentifier();
- doc.identifier(0).setName("0");
- doc.identifier(1).setName("1");
-
- KEduVocLesson* lesson = new KEduVocLesson("lesson", doc.lesson());
+ doc.identifier(0).setName( lang1 );
+ doc.identifier(0).setLocale( locale1 );
+ doc.identifier(1).setName( lang2 );
+ doc.identifier(1).setLocale( locale2 );
+
+ KEduVocLesson* lesson = new KEduVocLesson(lessonName, doc.lesson());
doc.lesson()->appendChildContainer(lesson);
lesson->appendEntry(new KEduVocExpression);
- lesson->entry(0)->setTranslation(0, "0");
- lesson->entry(0)->setTranslation(1, "1");
-
+ lesson->entry(0)->setTranslation(0, translation1);
+ lesson->entry(0)->setTranslation(1, translation2);
+
doc.saveAs(fileName, KEduVocDocument::Kvtml, generator);
-
+
KEduVocDocument docRead;
docRead.open(fileName);
+
+
+
+ QList<KEduVocContainer *> lessons = docRead.lesson()->childContainers();
+ KEduVocLesson *m_lesson;
+
+ foreach(KEduVocContainer * c, lessons) {
+ if (c->containerType() == KEduVocLesson::Lesson) {
+ m_lesson = static_cast<KEduVocLesson *>(c);
+ }
+ }
+
QCOMPARE( docRead.generator(), generator );
QCOMPARE( docRead.author(), author );
QCOMPARE( docRead.license(), license );
QCOMPARE( docRead.documentComment(), comment );
QCOMPARE( docRead.category(), category );
QCOMPARE( docRead.title(), title );
- QCOMPARE(doc.identifierCount(), 2);
- QCOMPARE(lesson->entry(0)->translationIndices().size(), 2);
- QCOMPARE(lesson->entry(0)->translation(0)->text(), QString("0"));
- QCOMPARE(lesson->entry(0)->translation(1)->text(), QString("1"));
-
+ QCOMPARE( docRead.identifierCount(), 2);
+ QCOMPARE( docRead.identifier(0).name(), lang1);
+ QCOMPARE( docRead.identifier(1).name(), lang2);
+ QCOMPARE( docRead.identifier(0).locale(), locale1);
+ QCOMPARE( docRead.identifier(1).locale(), locale2);
+ QCOMPARE( m_lesson->name(), lessonName);
+ QCOMPARE( m_lesson->entry(0)->translationIndices().size(), 2);
+ QCOMPARE( m_lesson->entry(0)->translation(0)->text(), translation1);
+ QCOMPARE( m_lesson->entry(0)->translation(1)->text(), translation2);
}
};
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE kvtml PUBLIC "kvtml2.dtd" "http://edu.kde.org/kvtml/kvtml2.dtd">
+<kvtml version="2.0" >
+ <information>
+ <generator>Validator Unit Tests</generator>
+ <title>Validator Test Title</title>
+ <author>Validator Test</author>
+ <license>test license</license>
+ <comment>comment</comment>
+ <date>2010-03-13</date>
+ <category>test document</category>
+ </information>
+ <identifiers>
+ <identifier id="0" >
+ <name>English</name>
+ <locale>en</locale>
+ </identifier>
+ <identifier id="1" >
+ <name>German</name>
+ <locale>de</locale>
+ </identifier>
+ </identifiers>
+ <entries>
+ <entry id="0" >
+ <translation id="0" >
+ <text>this is English</text>
+ </translation>
+ <translation id="1" >
+ <text>das ist Deutsch</text>
+ </translation>
+ </entry>
+ </entries>
+ <lessons>
+ <container>
+ <name>lesson No 1</name>
+ <inpractice>true</inpractice>
+ <entry id="0" />
+ </container>
+ </lessons>
+</kvtml>