NCL Composer  0.1.5
 All Classes Functions Variables Pages
tst_ModuleLanguage.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_ModuleLanguage.h"
11 
12 
13 void tst_ModuleLanguage::initTestCase()
14 {
15  QString baseDir = "C:";
16  baseDir += QDir::separator()+QString("Composer");
17  profileDir = baseDir+QDir::separator()+"lib"+QDir::separator()+"composer"+QDir::separator();
18  lgControl = LanguageControl::getInstance();
19 }
20 
21 void tst_ModuleLanguage::cleanupTestCase()
22 {
23  LanguageControl::releaseInstance();
24  lgControl = NULL;
25 }
26 
27 void tst_ModuleLanguage::languageLoadBenchmark_data()
28 {
29  QTest::addColumn<QString>("fileName");
30 
31 #ifdef Q_WS_MAC
32  QTest::newRow("NCL") << profileDir+"libNCLLanguageProfile.dylib";
33 #elif WIN32
34  QTest::newRow("NCL") << profileDir+"NCLLanguageProfile.dll";
35 #else
36  QTest::newRow("NCL") << profileDir+"libNCLLanguageProfile.so";
37 #endif
38 }
39 
40 void tst_ModuleLanguage::languageLoadBenchmark()
41 {
42  if (!isBenchmark)
43  QSKIP("This test is not a benchmark test", SkipSingle);
44 
45  QFETCH(QString,fileName);
46 
47  QBENCHMARK
48  {
49  lgControl->loadProfile(fileName);
50  lgControl->removeProfile(NCL);
51  }
52 }
53 
54 void tst_ModuleLanguage::languageProfile_data()
55 {
56  QTest::addColumn<QString>("fileName");
57 
58 #ifdef Q_WS_MAC
59  QTest::newRow("NCL") << profileDir+"libNCLLanguageProfile.dylib";
60 #elif WIN32
61  QTest::newRow("NCL") << profileDir+"NCLLanguageProfile.dll";
62 #else
63  QTest::newRow("NCL") << profileDir+"libNCLLanguageProfile.so";
64 #endif
65 }
66 
67 void tst_ModuleLanguage::languageProfile()
68 {
69  QFETCH(QString, fileName);
70 
71  QList<ILanguageProfile*> list;
72 
73  /* Try to load the same profile */
74  QVERIFY(lgControl->loadProfile
75  (fileName));
76  list = lgControl->getLoadedProfiles();
77  QCOMPARE(list.size(),1);
78 
79  /* remove the loaded profile */
80  QVERIFY(lgControl->removeProfile(NCL));
81  list = lgControl->getLoadedProfiles();
82  QCOMPARE(list.isEmpty(),true);
83 
84  /* reload the profile from fileName */
85  QVERIFY(lgControl->loadProfile
86  (fileName));
87  list = lgControl->getLoadedProfiles();
88  QCOMPARE(list.size(),1);
89 
90  /* Try to load a non existing profile */
91  QVERIFY(!lgControl->loadProfile("blah"));
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