add dictcionary file for test
[mdictionary] / trunk / src / plugins / xdxf / tests / test.cpp
1 /*******************************************************************************
2
3     This file is part of mDictionary.
4
5     mDictionary is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9
10     mDictionary is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
17
18     Copyright 2010 Comarch S.A.
19
20 *******************************************************************************/
21
22 #include "test.h"
23 #include <QSignalSpy>
24
25 void XdxfTest::search() {
26     /*test for English-Polish dictionary */
27     XdxfPlugin xdxfPlugin(this);
28     xdxfPlugin.search("wino");
29    QCOMPARE(xdxfPlugin.search("."), QString("kropka\n"));
30    QCOMPARE(xdxfPlugin.search("1"), QString("one\n"));
31 }
32
33 void XdxfTest::searchWordList() {
34      /*test for English-Polish dictionary */
35     XdxfPlugin xdxfPlugin(this);
36     QList<Translation*> te=xdxfPlugin.searchWordList(".",10);
37     if(te.size()>0)
38         QCOMPARE(te.at(0)->key(), QString("."));
39     QList<Translation*> te2=xdxfPlugin.searchWordList("1",10);
40     QCOMPARE(te2.size(),5);
41
42     QList<Translation*> te3=xdxfPlugin.searchWordList("1",2);
43     QCOMPARE(te3.size(),2);
44
45     QList<Translation*> te4=xdxfPlugin.searchWordList("ho*SE",10);
46         QCOMPARE(te4.at(0)->key(), QString("house"));
47
48     QList<Translation*> te5=xdxfPlugin.searchWordList("*");
49         QCOMPARE(te5.size(),8);
50
51     QList<Translation*> te6=xdxfPlugin.searchWordList("*",8);
52         QCOMPARE(te6.size(),8);
53
54 }
55
56
57 void XdxfTest::getNew() {
58 /*    XdxfPlugin xdxfPlugin(this);
59     Settings settings;
60     settings.setValue("path","dict2");
61     XdxfPlugin * = xdxfPlugin.getNew(settings);
62 */
63 }
64
65 void XdxfTest::stop() {
66     /*test for English-Polish dictionary */
67     CommonDictInterface *xdxfPlugin = new XdxfPlugin(this);
68
69     QString string("*");
70     QFuture<QList<Translation*> > future = QtConcurrent::run(xdxfPlugin, &CommonDictInterface::searchWordList, string, 10);
71     QList<Translation*> te5 = future.result();
72
73     QCOMPARE(te5.size(),8);
74 }
75
76 void XdxfTest::langFrom() {
77      /*test for English-Polish dictionary */
78     XdxfPlugin xdxfPlugin(this);
79     xdxfPlugin.searchWordList("rope",10);
80     QCOMPARE(xdxfPlugin.langFrom(), QString("ENG"));
81 }
82
83 QTEST_MAIN(XdxfTest)
84 //#include "testqstring.moc"