-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreeUnitTests.cpp
107 lines (72 loc) · 3 KB
/
TreeUnitTests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "tree.h"
#include <QMessageBox>
#include "time.h"
#include "TreeUnitTests.h"
#include "maininterface.h"
TreeUnitTests::TreeUnitTests() {
test = false;
testInterface = true;
}
bool TreeUnitTests::getTest() {
return test;
}
bool TreeUnitTests::getTestInterface() {
return testInterface;
}
void message(QString msg) {
QMessageBox msgBox;
msgBox.setText("Error");
msgBox.setInformativeText(msg);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
void TreeUnitTests::DisplayMessage(QString str_display) {
QMessageBox msgBox;
msgBox.setText("Test");
msgBox.setInformativeText(str_display);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
void TreeUnitTests::CreationTreeTest() {
// NE PAS MODIFIER LES VALEURS
QString name = "test";
QDir* path = new QDir(QDir::currentPath() + "/Tests Results");
QDir* backupPath = new QDir(QDir::currentPath() + "/Tests Results/Backup");
QDateTime updateDate = QDateTime::currentDateTime();
// SUPPRESSION DES FICHIERS TEST EXISTANTS
QFile file(path->path() + "/" + name + ".tree");
file.remove();
QFile backupFile(backupPath->path() + "/" + name + ".tree");
backupFile.remove();
// MODIFIER VALEURS BACKUP PATH SI ON VEUT
backupPath->setPath("");
//CREATION DE L'ARBRE
currentTree = new Tree(name, updateDate, *path, *backupPath);
// VERIFICATION
QFileInfo check_file(path->path() + "/" + name + ".tree");
// check if file exists and if yes: Is it really a file and no directory?
if (check_file.exists() && check_file.isFile()) {
}
else {
message("Creation de l'arbre non effectuee");
}
QFileInfo check_Backupfile(backupPath->path() + "/" + name + ".tree");
// check if file exists and if yes: Is it really a file and no directory?
if (check_Backupfile.exists() && check_Backupfile.isFile() || backupPath->path() == "") {
}
else {
message("Creation du backup de l'arbre non effectuee");
}
}
void TreeUnitTests::AddingSonAndParents() {
// CREATION OF TREE BEFIRE
currentTree->newPerson(std::make_shared<Person>("Annick", "Demongeot", "demongeot,annick", "Eliane Demongeot, Claude Demongeot", QDate::fromString("28/07/1962", "dd/MM/yyyy"), "D:\\Dropbox\\Documents\\Codage\\C++\\Qt\\Tree\\Tests Results\\Annick Demongeot.jpg"));
currentTree->newPerson(std::make_shared<Person>("Jean-marc", "Thiriet", "jean-marc,thiriet", "Claude THIRIET, Marie-Thérèse THIRIET", QDate::fromString("21/02/1962", "dd/MM/yyyy"), "D:\\Dropbox\\Documents\\Codage\\C++\\Qt\\Tree\\Tests Results\\Jean-marc Thiriet.jpg"));
currentTree->newPerson(std::make_shared<Person>("Rémi", "Thiriet", "remi,thiriet,rémi", "Annick Demongeot, Jean-Marc THIRIET", QDate::fromString("01/08/1993", "dd/MM/yyyy"), "D:\\Dropbox\\Documents\\Codage\\C++\\Qt\\Tree\\Tests Results\\Rémi THIRIET.jpg"));
if (TreeUnitTests().getTestInterface()) {
TreeUnitTests().DisplayMessage(currentTree->Test_DiplayTree());
}
//MainInterface().DisplayTree();
}