~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to kde/src/test/account_test.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 *   Copyright (C) 2012-2013 by Savoir-Faire Linux                            *
 
2
 *   Copyright (C) 2012-2014 by Savoir-Faire Linux                            *
3
3
 *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com>   *
4
4
 *                                                                            *
5
5
 *   This library is free software; you can redistribute it and/or            *
19
19
#include <QtTest/QtTest>
20
20
//#include <QtCore>
21
21
 
22
 
#include "../src/lib/configurationmanager_interface_singleton.h"
23
 
#include "../src/lib/callmanager_interface_singleton.h"
24
 
#include "../src/lib/instance_interface_singleton.h"
 
22
#include "../src/lib/dbus/configurationmanager.h"
 
23
#include "../src/lib/dbus/callmanager.h"
 
24
#include "../src/lib/dbus/instancemanager.h"
25
25
#include "../src/lib/typedefs.h"
26
26
#include "../src/lib/account.h"
27
 
#include "../src/lib/accountlist.h"
 
27
#include "../src/lib/accountlistmodel.h"
28
28
#include "../src/lib/dbus/metatypes.h"
29
29
 
30
30
class AccountTests: public QObject
103
103
//BEGIN Getting a valid account
104
104
void AccountTests::testAccountList()
105
105
{
106
 
   AccountList* list = AccountList::getInstance();
 
106
   AccountList* list = AccountListModel::instance();
107
107
   QCOMPARE( list != nullptr , true);
108
108
   QCOMPARE( list->size() >= 1, true);
109
109
}
110
110
 
111
111
void AccountTests::testIP2IP() {
112
 
   Account* acc = AccountList::getInstance()->getAccountById("IP2IP");
 
112
   Account* acc = AccountListModel::instance()->getAccountById("IP2IP");
113
113
   QCOMPARE( acc != nullptr, true);
114
114
   if (acc) {
115
115
      QCOMPARE( acc->getAlias(), QString("IP2IP"));
117
117
}
118
118
 
119
119
void AccountTests::testIP2IPAlias() {
120
 
   Account* acc = AccountList::getInstance()->getAccountById("IP2IP");
 
120
   Account* acc = AccountListModel::instance()->getAccountById("IP2IP");
121
121
   if (acc) {
122
122
      QCOMPARE( acc->getAlias(), QString("IP2IP"));
123
123
      QCOMPARE( acc->getAlias() != QString("qwerty"), true);
131
131
{
132
132
   Account* acc = Account::buildNewAccountFromAlias("unit_test_account");
133
133
   acc->save();
134
 
   id = acc->getAccountId();
 
134
   id = acc->accountId();
135
135
   QCOMPARE( acc != nullptr, true);
136
136
}
137
137
 
138
138
void AccountTests::testGetNewAccount()
139
139
{
140
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
140
   Account* acc = AccountListModel::instance()->getAccountById(id);
141
141
   QCOMPARE( acc != nullptr, true);
142
142
}
143
143
//END creating a new account
156
156
 
157
157
void AccountTests::testAccountAlias                  ()/*QString detail*/
158
158
{
159
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
159
   Account* acc = AccountListModel::instance()->getAccountById(id);
160
160
   //acc->setAccountAlias("unit_alias");
161
161
   //QCOMPARE( acc->getAccountAlias(), QString("unit_alias"));
162
162
 
169
169
 
170
170
void AccountTests::testAccountType                   ()/*QString detail*/
171
171
{
172
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
172
   Account* acc = AccountListModel::instance()->getAccountById(id);
173
173
   acc->setAccountType("IAX");
174
174
   acc->save();
175
175
   QCOMPARE( acc->getAccountType(), QString("IAX") );
194
194
//This test the various hostnames that should be allowed by the daemon
195
195
void AccountTests::testAccountHostname               ()
196
196
{
197
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
197
   Account* acc = AccountListModel::instance()->getAccountById(id);
198
198
   QFETCH(QString, hostname);
199
199
   acc->setAccountHostname(hostname);
200
200
   acc->save();
217
217
void AccountTests::testAccountHostnameInvalid        ()
218
218
{
219
219
   QFETCH(QString, hostname);
220
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
220
   Account* acc = AccountListModel::instance()->getAccountById(id);
221
221
   acc->setAccountHostname(hostname);
222
222
   acc->save();
223
223
   QVERIFY(acc->getAccountHostname() != hostname);
225
225
 
226
226
void AccountTests::testAccountUsername               ()/*QString detail*/
227
227
{
228
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
228
   Account* acc = AccountListModel::instance()->getAccountById(id);
229
229
   acc->setAccountHostname("1234567879");
230
230
   acc->save();
231
231
   QString username = acc->getAccountHostname();
244
244
void AccountTests::testAccountPassword               ()/*QString detail*/
245
245
{
246
246
   /*QFETCH(QString, password);
247
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
247
   Account* acc = AccountListModel::instance()->getAccountById(id);
248
248
   acc->setAccountPassword(password);
249
249
   QString pwd = acc->getAccountPassword();
250
250
   QCOMPARE(pwd,password);*/
252
252
 
253
253
void AccountTests::testAccountMailbox                ()/*QString detail*/
254
254
{
255
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
255
   Account* acc = AccountListModel::instance()->getAccountById(id);
256
256
   acc->setAccountMailbox("1234567879");
257
257
   acc->save();
258
258
   QString mailbox = acc->getAccountMailbox();
262
262
 
263
263
void AccountTests::testTlsPassword                   ()/*QString detail*/
264
264
{
265
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
265
   Account* acc = AccountListModel::instance()->getAccountById(id);
266
266
   acc->setTlsPassword("1234567879");
267
267
   acc->save();
268
268
   QString tlspass = acc->getTlsPassword();
271
271
 
272
272
void AccountTests::testTlsCaListFile                 ()/*QString detail*/
273
273
{
274
 
   //Account* acc = AccountList::getInstance()->getAccountById(id);
 
274
   //Account* acc = AccountListModel::instance()->getAccountById(id);
275
275
   QSKIP("TODO",SkipAll);
276
276
}
277
277
 
278
278
void AccountTests::testTlsCertificateFile            ()/*QString detail*/
279
279
{
280
 
   //Account* acc = AccountList::getInstance()->getAccountById(id);
 
280
   //Account* acc = AccountListModel::instance()->getAccountById(id);
281
281
   QSKIP("TODO",SkipAll);
282
282
}
283
283
 
284
284
void AccountTests::testTlsPrivateKeyFile             ()/*QString detail*/
285
285
{
286
 
   //Account* acc = AccountList::getInstance()->getAccountById(id);
 
286
   //Account* acc = AccountListModel::instance()->getAccountById(id);
287
287
   QSKIP("TODO",SkipAll);
288
288
}
289
289
 
290
290
void AccountTests::testTlsCiphers                    ()/*QString detail*/
291
291
{
292
 
   //Account* acc = AccountList::getInstance()->getAccountById(id);
 
292
   //Account* acc = AccountListModel::instance()->getAccountById(id);
293
293
   QSKIP("TODO",SkipAll);
294
294
}
295
295
 
296
296
void AccountTests::testTlsServerName                 ()/*QString detail*/
297
297
{
298
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
298
   Account* acc = AccountListModel::instance()->getAccountById(id);
299
299
   acc->setTlsServerName("qwerty");
300
300
   acc->save();
301
301
   QString tlsserver = acc->getTlsServerName();
304
304
 
305
305
void AccountTests::testAccountSipStunServer          ()/*QString detail*/
306
306
{
307
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
307
   Account* acc = AccountListModel::instance()->getAccountById(id);
308
308
   acc->setAccountSipStunServer("qwerty");
309
309
   acc->save();
310
310
   QString tlsserver = acc->getAccountSipStunServer();
313
313
 
314
314
void AccountTests::testPublishedAddress              ()/*QString detail*/
315
315
{
316
 
   //Account* acc = AccountList::getInstance()->getAccountById(id);
 
316
   //Account* acc = AccountListModel::instance()->getAccountById(id);
317
317
   QSKIP("TODO",SkipAll);
318
318
}
319
319
 
320
320
void AccountTests::testLocalInterface                ()/*QString detail*/
321
321
{
322
 
   //Account* acc = AccountList::getInstance()->getAccountById(id);
 
322
   //Account* acc = AccountListModel::instance()->getAccountById(id);
323
323
   QSKIP("TODO",SkipAll);
324
324
}
325
325
 
326
326
void AccountTests::testRingtonePath_data()
327
327
{
328
328
   QTest::addColumn<QString>("path");
329
 
   QMap<QString,QString> ringtonePaths = ConfigurationManagerInterfaceSingleton::getInstance().getRingtoneList();
 
329
   QMap<QString,QString> ringtonePaths = DBus::ConfigurationManager::instance().getRingtoneList();
330
330
   QMutableMapIterator<QString, QString> iter(ringtonePaths);
331
331
   while (iter.hasNext()) {
332
332
      iter.next();
356
356
 
357
357
void AccountTests::testRingtonePath                  ()/*QString detail*/
358
358
{
359
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
359
   Account* acc = AccountListModel::instance()->getAccountById(id);
360
360
   QFETCH(QString, path);
361
361
   acc->setRingtonePath(path);
362
362
   acc->save();
368
368
 
369
369
void AccountTests::testTlsMethod                     ()/*int     detail*/
370
370
{
371
 
   //Account* acc = AccountList::getInstance()->getAccountById(id);
 
371
   //Account* acc = AccountListModel::instance()->getAccountById(id);
372
372
   QSKIP("TODO",SkipAll);
373
373
}
374
374
 
375
375
void AccountTests::testAccountRegistrationExpire     ()/*int     detail*/
376
376
{
377
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
377
   Account* acc = AccountListModel::instance()->getAccountById(id);
378
378
   acc->setAccountRegistrationExpire(10000);
379
379
   acc->save();
380
380
   QCOMPARE(acc->getAccountRegistrationExpire(),10000);
387
387
 
388
388
void AccountTests::testTlsNegotiationTimeoutSec      ()/*int     detail*/
389
389
{
390
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
390
   Account* acc = AccountListModel::instance()->getAccountById(id);
391
391
   acc->setTlsNegotiationTimeoutSec(10000);
392
392
   acc->save();
393
393
 
401
401
 
402
402
void AccountTests::testTlsNegotiationTimeoutMsec     ()/*int     detail*/
403
403
{
404
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
404
   Account* acc = AccountListModel::instance()->getAccountById(id);
405
405
 
406
406
   acc->setTlsNegotiationTimeoutMsec(10000);
407
407
   acc->save();
427
427
 
428
428
void AccountTests::testLocalPort                     ()/*short   detail*/
429
429
{
430
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
430
   Account* acc = AccountListModel::instance()->getAccountById(id);
431
431
   QFETCH(int, port);
432
432
   acc->setLocalPort(port);
433
433
   acc->save();
451
451
 
452
452
void AccountTests::testTlsListenerPort               ()/*short   detail*/
453
453
{
454
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
454
   Account* acc = AccountListModel::instance()->getAccountById(id);
455
455
   QFETCH(int, port);
456
456
   acc->setTlsListenerPort(port);
457
457
   acc->save();
475
475
 
476
476
void AccountTests::testPublishedPort                 ()/*short   detail*/
477
477
{
478
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
478
   Account* acc = AccountListModel::instance()->getAccountById(id);
479
479
   QFETCH(int, port);
480
480
   acc->setPublishedPort(port);
481
481
   acc->save();
487
487
 
488
488
void AccountTests::testAccountEnabled                ()/*bool    detail*/
489
489
{
490
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
490
   Account* acc = AccountListModel::instance()->getAccountById(id);
491
491
   acc->setAccountEnabled(false);
492
492
   QCOMPARE(acc->isAccountEnabled(),false);
493
493
   acc->setAccountEnabled(true);
496
496
 
497
497
void AccountTests::testTlsVerifyServer               ()/*bool    detail*/
498
498
{
499
 
   //Account* acc = AccountList::getInstance()->getAccountById(id);
 
499
   //Account* acc = AccountListModel::instance()->getAccountById(id);
500
500
   QSKIP("TODO",SkipAll);
501
501
}
502
502
 
503
503
void AccountTests::testTlsVerifyClient               ()/*bool    detail*/
504
504
{
505
 
   //Account* acc = AccountList::getInstance()->getAccountById(id);
 
505
   //Account* acc = AccountListModel::instance()->getAccountById(id);
506
506
   QSKIP("TODO",SkipAll);
507
507
}
508
508
 
509
509
void AccountTests::testTlsRequireClientCertificate   ()/*bool    detail*/
510
510
{
511
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
511
   Account* acc = AccountListModel::instance()->getAccountById(id);
512
512
   acc->setTlsRequireClientCertificate(true);
513
513
   acc->save();
514
514
   QCOMPARE(acc->isTlsRequireClientCertificate(),true);
519
519
 
520
520
void AccountTests::testTlsEnable                     ()/*bool    detail*/
521
521
{
522
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
522
   Account* acc = AccountListModel::instance()->getAccountById(id);
523
523
   acc->setTlsEnable(true);
524
524
   acc->save();
525
525
   QCOMPARE(acc->isTlsEnable(),true);
530
530
 
531
531
void AccountTests::testAccountDisplaySasOnce         ()/*bool    detail*/
532
532
{
533
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
533
   Account* acc = AccountListModel::instance()->getAccountById(id);
534
534
   acc->setAccountDisplaySasOnce(true);
535
535
   acc->save();
536
536
   QCOMPARE(acc->isAccountDisplaySasOnce(),true);
541
541
 
542
542
void AccountTests::testAccountSrtpRtpFallback        ()/*bool    detail*/
543
543
{
544
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
544
   Account* acc = AccountListModel::instance()->getAccountById(id);
545
545
   acc->setAccountSrtpRtpFallback(true);
546
546
   acc->save();
547
547
   QCOMPARE(acc->isAccountSrtpRtpFallback(),true);
552
552
 
553
553
void AccountTests::testAccountZrtpDisplaySas         ()/*bool    detail*/
554
554
{
555
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
555
   Account* acc = AccountListModel::instance()->getAccountById(id);
556
556
   acc->setAccountSrtpRtpFallback(true);
557
557
   acc->save();
558
558
   QCOMPARE(acc->isAccountSrtpRtpFallback(),true);
563
563
 
564
564
void AccountTests::testAccountZrtpNotSuppWarning     ()/*bool    detail*/
565
565
{
566
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
566
   Account* acc = AccountListModel::instance()->getAccountById(id);
567
567
   acc->setAccountZrtpNotSuppWarning(true);
568
568
   acc->save();
569
569
   QCOMPARE(acc->isAccountZrtpNotSuppWarning(),true);
574
574
 
575
575
void AccountTests::testAccountZrtpHelloHash          ()/*bool    detail*/
576
576
{
577
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
577
   Account* acc = AccountListModel::instance()->getAccountById(id);
578
578
   acc->setAccountZrtpHelloHash(true);
579
579
   acc->save();
580
580
   QCOMPARE(acc->isAccountZrtpHelloHash(),true);
585
585
 
586
586
void AccountTests::testAccountSipStunEnabled         ()/*bool    detail*/
587
587
{
588
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
588
   Account* acc = AccountListModel::instance()->getAccountById(id);
589
589
   acc->setAccountSipStunEnabled(true);
590
590
   acc->save();
591
591
   QCOMPARE(acc->isAccountSipStunEnabled(),true);
596
596
 
597
597
void AccountTests::testPublishedSameAsLocal          ()/*bool    detail*/
598
598
{
599
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
599
   Account* acc = AccountListModel::instance()->getAccountById(id);
600
600
   acc->setPublishedSameAsLocal(true);
601
601
   acc->save();
602
602
   QCOMPARE(acc->isPublishedSameAsLocal(),true);
607
607
 
608
608
void AccountTests::testConfigRingtoneEnabled         ()/*bool    detail*/
609
609
{
610
 
   Account* acc = AccountList::getInstance()->getAccountById(id);
 
610
   Account* acc = AccountListModel::instance()->getAccountById(id);
611
611
   acc->setRingtoneEnabled(true);
612
612
   acc->save();
613
613
   QCOMPARE(acc->isRingtoneEnabled(),true);
624
624
{
625
625
   QList<bool> saveState;
626
626
   //Disable all accounts
627
 
   for (int i=0;i<AccountList::getInstance()->size();i++) {
628
 
      saveState << (*AccountList::getInstance())[i]->isAccountEnabled();
629
 
      (*AccountList::getInstance())[i]->setAccountEnabled(false);
630
 
      (*AccountList::getInstance())[i]->save();
 
627
   for (int i=0;i<AccountListModel::instance()->size();i++) {
 
628
      saveState << (*AccountListModel::instance())[i]->isAccountEnabled();
 
629
      (*AccountListModel::instance())[i]->setAccountEnabled(false);
 
630
      (*AccountListModel::instance())[i]->save();
631
631
   }
632
632
 
633
 
   QCOMPARE(AccountList::getCurrentAccount(),(Account*)nullptr);
 
633
   QCOMPARE(AccountListModel::currentAccount(),(Account*)nullptr);
634
634
 
635
635
   //Restore state
636
 
   for (int i=0;i<AccountList::getInstance()->size();i++) {
637
 
      (*AccountList::getInstance())[i]->setAccountEnabled(saveState[i]);
638
 
      (*AccountList::getInstance())[i]->save();
 
636
   for (int i=0;i<AccountListModel::instance()->size();i++) {
 
637
      (*AccountListModel::instance())[i]->setAccountEnabled(saveState[i]);
 
638
      (*AccountListModel::instance())[i]->save();
639
639
   }
640
640
}
641
641
 
643
643
 
644
644
//BEGIN cleanup
645
645
void AccountTests::cleanupTestCase() {
646
 
   AccountList::getInstance()->removeAccount(AccountList::getInstance()->getAccountById(id));
647
 
   QCOMPARE( AccountList::getInstance()->getAccountById(id) == nullptr, true);
 
646
   AccountListModel::instance()->removeAccount(AccountListModel::instance()->getAccountById(id));
 
647
   QCOMPARE( AccountListModel::instance()->getAccountById(id) == nullptr, true);
648
648
}
649
649
//END cleanup
650
650