LibEngsas
modeltest.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 ** Copyright (C) 2010 - 2012 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved. (QDebug and verbose part)
6 **
7 ** This file is part of the test suite of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** Commercial License Usage
11 ** Licensees holding valid commercial Qt licenses may use this file in
12 ** accordance with the commercial license agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Digia. For licensing terms and
15 ** conditions see http://qt.digia.com/licensing. For further information
16 ** use the contact form at http://qt.digia.com/contact-us.
17 **
18 ** GNU Lesser General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU Lesser
20 ** General Public License version 2.1 as published by the Free Software
21 ** Foundation and appearing in the file LICENSE.LGPL included in the
22 ** packaging of this file. Please review the following information to
23 ** ensure the GNU Lesser General Public License version 2.1 requirements
24 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** In addition, as a special exception, Digia gives you certain additional
27 ** rights. These rights are described in the Digia Qt LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file. Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 **
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42 
43 
44 #ifndef MODELTEST_H
45 #define MODELTEST_H
46 
47 #include "etesting.h"
48 
49 #include <QtCore/QObject>
50 #include <QtCore/QAbstractItemModel>
51 #include <QtCore/QStack>
52 
71 class E_TESTING_EXPORT ModelTest : public QObject
72 {
73  Q_OBJECT
74 
75 public:
76  ModelTest(QAbstractItemModel *model, QObject *parent = NULL, int verbose = 1);
77 
78 private Q_SLOTS:
79  void nonDestructiveBasicTest();
80  void rowCount();
81  void columnCount();
82  void hasIndex();
83  void index();
84  void parent();
85  void data();
86 
87 protected Q_SLOTS:
88  void runAllTests();
89  void layoutAboutToBeChanged();
90  void layoutChanged();
91  void rowsAboutToBeInserted( const QModelIndex& parent, int start, int);
92  void rowsInserted( const QModelIndex & parent, int start, int end );
93  void rowsAboutToBeRemoved( const QModelIndex &parent, int start, int end );
94  void rowsRemoved( const QModelIndex & parent, int start, int end );
95 
96 private:
97  void checkChildren( const QModelIndex &parent, int currentDepth = 0 );
98  void init();
99 
100 
101  QAbstractItemModel *model;
102 
103  struct Changing {
104  QModelIndex parent;
105  int oldSize;
106  QVariant last;
107  QVariant next;
108  };
109  QStack<Changing> insert;
110  QStack<Changing> remove;
111 
113 
115 
116  QList<QPersistentModelIndex> changing;
117 };
118 
119 #endif
int oldSize
Definition: modeltest.h:105
QModelIndex parent
Definition: modeltest.h:104
bool fetchingMore
Definition: modeltest.h:112
#define E_TESTING_EXPORT
Definition: etesting.h:36
QStack< Changing > insert
Definition: modeltest.h:109
QAbstractItemModel * model
Definition: modeltest.h:101
QVariant last
Definition: modeltest.h:106
int verboseLevel
Definition: modeltest.h:114
QList< QPersistentModelIndex > changing
Definition: modeltest.h:116
Definition: modeltest.h:103
QVariant next
Definition: modeltest.h:107
Class to test all basic stuff of QAbstractItemModels.
Definition: modeltest.h:71