]> Creatis software - clitk.git/blob - tests/vv/vvRegisterFormTest.cxx
Let vvSlicer handle visibility
[clitk.git] / tests / vv / vvRegisterFormTest.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================*/
18 #include "vvRegisterForm.h"
19 #include <QUrl>
20 #include <QSettings>
21 #include "gtest/gtest.h"
22 #include "vvCommon.h"
23 #include <stdio.h>
24 #include <fstream>
25 const std::string data_path = "/home/mpech/workspace/vvSource/tests/data/";
26 TEST(vvRegisterForm, canPush){
27   QUrl url;
28   //the file exists with some old lines
29   vvRegisterForm* v=new vvRegisterForm(url, QString::fromStdString(data_path+".settingsCanPush.txt"), QSettings::NativeFormat);
30   std::ifstream inFile((data_path+".settingsCanPush.txt").c_str(), std::ifstream::in);
31   ASSERT_FALSE(inFile.fail());
32   EXPECT_TRUE(v->canPush());
33   
34   //the file doesn't exist
35   vvRegisterForm* v2=new vvRegisterForm(url, QString::fromStdString(data_path+".settings_notFound.txt"), QSettings::NativeFormat);
36   EXPECT_TRUE(v2->canPush());
37   
38   //the current version is the same
39   QString strSettings=QString::fromStdString(data_path+".settings2.txt");
40   QSettings settings(strSettings, QSettings::NativeFormat);
41   settings.setValue("vvVersion", VV_VERSION);
42   vvRegisterForm* v3=new vvRegisterForm(url, strSettings, QSettings::NativeFormat);
43   EXPECT_FALSE(v3->canPush());
44 }
45 TEST(vvRegisterForm, acquitPushed){
46   QUrl url;
47   vvRegisterForm* v=new vvRegisterForm(url, QString::fromStdString(data_path+".settingsAcquit.txt"), QSettings::NativeFormat);
48   ASSERT_TRUE(v->canPush());
49   v->acquitPushed();
50   EXPECT_FALSE(v->canPush());
51   remove((data_path+".settingsAcquit.txt").c_str());
52 }