source: branches/release-0.3.0-rc1/src/mediadb/tests/projectsmodeltest.cpp @ 223

Last change on this file since 223 was 223, checked in by Joachim Langenbach, 11 years ago
  • forgotten some tests
File size: 2.2 KB
Line 
1/*
2    MediaDB - A media management software
3    Copyright (C) 2010  Joachim Langenbach
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18*/
19
20#include "projectsmodeltest.h"
21
22#include <projectsmodel.h>
23#include "modeltest.h"
24#include <project.h>
25#include <medium.h>
26
27#include <QtTest/QtTest>
28#include <QSqlRecord>
29
30ProjectsModelTest::ProjectsModelTest(QObject* parent): QObject(parent)
31{
32        model = new ProjectsModel(this);
33        modeltest = new ModelTest(model, 0, this);
34}
35
36ProjectsModelTest::~ProjectsModelTest()
37{
38        delete modeltest;
39        delete model;
40}
41
42void ProjectsModelTest::testModel()
43{
44        QList<Project*> items;
45        items << new Project();
46        items << new Project();
47        items[items.size() - 1]->setName("Test");
48        items << new Project();
49        items[items.size() - 1]->setName("Test 1");
50        items[items.size() - 1]->setId(12);
51        items[items.size() - 1]->addMaterial(0);
52        items[items.size() - 1]->addMaterial(QSqlRecord());
53        items << new Project();
54        items[items.size() - 1]->setName("Test 1");
55        items[items.size() - 1]->setId(12);
56        items[items.size() - 1]->addMaterial(new Medium());
57        items[items.size() - 1]->setDescription("Super Project");
58       
59        // insert mins
60        foreach(Project *project, items){
61                model->addProject(project);
62        }
63       
64        QCOMPARE(model->rowCount(), items.size());
65       
66        // remove a min from the beginning, the middle and the end
67        if(model->rowCount() > 0)
68                model->removeRow(0);
69       
70        if(model->rowCount() > 0)
71                model->removeRow(model->rowCount() - 1);
72       
73        if(model->rowCount() > 2){
74                int half = model->rowCount() / 2;
75                model->removeRow(half);
76        }
77}
78
79QTEST_MAIN(ProjectsModelTest)
80
81#include "projectsmodeltest.moc"
Note: See TracBrowser for help on using the repository browser.