NCL Composer  0.1.5
 All Classes Functions Variables Pages
tst_ModuleInit.cpp
1 /* Copyright (c) 2011 Telemidia/PUC-Rio.
2  * All rights reserved. This program and the accompanying materials
3  * are made available under the terms of the Eclipse Public License v1.0
4  * which accompanies this distribution, and is available at
5  * http://www.eclipse.org/legal/epl-v10.html
6  *
7  * Contributors:
8  * Telemidia/PUC-Rio - initial API and implementation
9  */
10 #include "tst_ModuleInit.h"
11 
12 void tst_ModuleInit::initTestCase()
13 {
14  QString baseDir = "C:";
15  baseDir += QDir::separator()+QString("Composer");
16  profileDir = baseDir+QDir::separator()+"lib"+QDir::separator()+"composer"+QDir::separator();
17  pluginDir = baseDir+QDir::separator()+"plugins"+QDir::separator();
18 }
19 
20 
21 void tst_ModuleInit::initBenchmark_data()
22 {
23  QTest::addColumn<bool>("instanciate");
24 
25  QTest::newRow("init") << true;
26  QTest::newRow("release") << false;
27 }
28 
29 void tst_ModuleInit::initBenchmark()
30 {
31  if (!isBenchmark)
32  QSKIP("This test is not a benchmark test", SkipSingle);
33 
34  QFETCH(bool,instanciate);
35 
36  if (instanciate)
37  {
38  QBENCHMARK {
39  // docControl = DocumentControl::getInstance();
40  // QVERIFY(docControl);
41  lgControl = LanguageControl::getInstance();
42  QVERIFY(lgControl);
43  pgControl = PluginControl::getInstance();
44  QVERIFY(pgControl);
45  }
46  // DocumentControl::releaseInstance();
47  LanguageControl::releaseInstance();
48  PluginControl::releaseInstance();
49  } else {
50  // docControl = DocumentControl::getInstance();
51  // QVERIFY(docControl);
52  lgControl = LanguageControl::getInstance();
53  QVERIFY(lgControl);
54  pgControl = PluginControl::getInstance();
55  QVERIFY(pgControl);
56 
57  QBENCHMARK {
58  // DocumentControl::releaseInstance();
59  LanguageControl::releaseInstance();
60  PluginControl::releaseInstance();
61  }
62  }
63 }
64 
65 void tst_ModuleInit::initTorture()
66 {
67 
68  for (int i = 0; i < interations ; i++)
69  {
70  // docControl = DocumentControl::getInstance();
71  // QVERIFY(docControl);
72  lgControl = LanguageControl::getInstance();
73  QVERIFY(lgControl);
74  pgControl = PluginControl::getInstance();
75  QVERIFY(pgControl);
76 
77  // DocumentControl::releaseInstance();
78  LanguageControl::releaseInstance();
79  PluginControl::releaseInstance();
80  }
81 
82 
83 }
84 
85 void tst_ModuleInit::languageProfile()
86 {
87  QList<ILanguageProfile*> list;
88 
89  /* Try to load the same profile */
90  QVERIFY(lgControl->loadProfile
91  (profileDir+"NCLLanguageProfile.so"));
92  list = lgControl->getLoadedProfiles();
93  QCOMPARE(list.size(),1);
94 
95 // /* remove the loaded profile */
96 // QVERIFY(lgControl->removeProfile(NCL));
97 // list = lgControl->getLoadedProfiles();
98 // QCOMPARE(list.isEmpty(),true);
99 
100 // /* reload the profile from fileName */
101 // QVERIFY(lgControl->loadProfile
102 // (profileDir+"libNCLLanguageProfile.dylib"));
103 // list = lgControl->getLoadedProfiles();
104 // QCOMPARE(list.size(),1);
105 
106 // /* Try to load a non existing profile */
107 // QVERIFY(!lgControl->loadProfile("blah"));
108 // list = lgControl->getLoadedProfiles();
109 // QCOMPARE(list.size(),1);
110 
111 }
112 
113 //void tst_ModuleInit::pluginProfile()
114 //{
115 // QList<IPluginFactory*> list;
116 
117 // pgControl->loadPlugins(pluginDir);
118 // list = pgControl->getLoadedPlugins();
119 // QCOMPARE(list.isEmpty(),false);
120 
121 // /* Load the same plugin */
122 // QVERIFY(pgControl->loadPlugin(pluginDir+"libdebug_console.dylib"));
123 // list = pgControl->getLoadedPlugins();
124 // QCOMPARE(list.size(),1);
125 
126 // /* load a non existent plugin */
127 // QVERIFY(!pgControl->loadPlugin("blah"));
128 // list = pgControl->getLoadedPlugins();
129 // QCOMPARE(list.size(),1);
130 
131 //}
132 
133 //void tst_ModuleInit::launchDocument_data()
134 //{
135 // QTest::addColumn<QString>("fileName");
136 
137 // QDir docDir(documentDir);
138 // docDir.setFilter(QDir::Files | QDir::NoSymLinks);
139 // docDir.setSorting(QDir::Size | QDir::Reversed);
140 
141 // QFileInfoList list = docDir.entryInfoList();
142 
143 // for (int i = 0; i != list.size(); i++)
144 // {
145 // QFileInfo file = list.at(i);
146 // QString absFile = file.absoluteFilePath();
147 // int size = file.size();
148 // qDebug() << absFile << size;
149 // QTest::newRow("openDoc") << absFile;
150 // }
151 //}
152 
153 //void tst_ModuleInit::closeDocument_data()
154 //{
155 // QTest::addColumn<QString>("fileName");
156 
157 // QDir docDir(documentDir);
158 // docDir.setFilter(QDir::Files | QDir::NoSymLinks);
159 // docDir.setSorting(QDir::Size | QDir::Reversed);
160 
161 // QFileInfoList list = docDir.entryInfoList();
162 
163 // for (int i = 0; i != list.size(); i++)
164 // {
165 // QFileInfo file = list.at(i);
166 // QString absFile = file.absoluteFilePath();
167 // int size = file.size();
168 // qDebug() << absFile << size;
169 // QTest::newRow("closeDoc") << absFile;
170 // }
171 //}
172 
173 //void tst_ModuleInit::launchAndCloseDocument_data()
174 //{
175 // QTest::addColumn<QString>("fileName");
176 // QTest::addColumn<bool>("openDoc");
177 
178 // QDir docDir(documentDir);
179 // docDir.setFilter(QDir::Files | QDir::NoSymLinks);
180 // docDir.setSorting(QDir::Size | QDir::Reversed);
181 
182 // QFileInfoList list = docDir.entryInfoList();
183 
184 // for (int i = 0; i != list.size(); i++)
185 // {
186 // QFileInfo file = list.at(i);
187 // QString absFile = file.absoluteFilePath();
188 // int size = file.size();
189 // qDebug() << absFile << size;
190 // QTest::newRow("openDoc") << absFile << true;
191 // QTest::newRow("closeDoc") << absFile << false;
192 // if (i == 1) break;
193 // }
194 //}
195 
196 //void tst_ModuleInit::launchDocument()
197 //{
198 
199 // QFETCH(QString, fileName);
200 
201 // QBENCHMARK
202 // {
203 // docControl->launchDocument("testing",fileName);
204 // }
205 //}
206 
207 //void tst_ModuleInit::closeDocument()
208 //{
209 // QFETCH(QString, fileName);
210 
211 // QBENCHMARK
212 // {
213 // docControl->closeDocument(fileName);
214 // }
215 //}
216 
217 //void tst_ModuleInit::launchAndCloseDocument()
218 //{
219 // QFETCH(QString, fileName);
220 // QFETCH(bool, openDoc);
221 
222 // if (openDoc)
223 // {
224 // QBENCHMARK
225 // {
226 // docControl->launchDocument("testing",fileName);
227 // }
228 // } else {
229 // QBENCHMARK
230 // {
231 // docControl->closeDocument(fileName);
232 // }
233 // }
234 //}
235 
236 
237 void tst_ModuleInit::cleanupTestCase()
238 {
239 
240 }