#include "kdganttconstraintmodel.h"
#include "kdganttconstraintmodel_p.h"
#include <QDebug>
#include <cassert>
#include <QStandardItemModel>
#include "unittest/test.h"
#include "moc_kdganttconstraintmodel.cpp"
Go to the source code of this file.
Defines | |
#define | d d_func() |
Functions | |
KDAB_SCOPED_UNITTEST_SIMPLE (KDGantt, ConstraintModel,"test") | |
std::ostream & | operator<< (std::ostream &os, const QModelIndex &idx) |
QDebug | operator<< (QDebug dbg, const KDGantt::ConstraintModel &model) |
#define d d_func() |
Definition at line 91 of file kdganttconstraintmodel.cpp.
KDAB_SCOPED_UNITTEST_SIMPLE | ( | KDGantt | , | |
ConstraintModel | , | |||
"test" | ||||
) |
Definition at line 240 of file kdganttconstraintmodel.cpp.
References KDGantt::ConstraintModel::addConstraint(), assertEqual, assertFalse, assertTrue, KDGantt::ConstraintModel::constraints(), KDGantt::ConstraintModel::constraintsForIndex(), KDGantt::ConstraintModel::hasConstraint(), and KDGantt::ConstraintModel::removeConstraint().
00241 { 00242 QStandardItemModel dummyModel( 100, 100 ); 00243 ConstraintModel model; 00244 00245 QModelIndex invalidIndex; 00246 assertEqual( invalidIndex, invalidIndex ); 00247 00248 assertEqual( model.constraints().count(), 0 ); 00249 00250 model.addConstraint( Constraint( QModelIndex(), QModelIndex() ) ); 00251 assertEqual( model.constraints().count(), 1 ); 00252 00253 model.addConstraint( Constraint( QModelIndex(), QModelIndex() ) ); 00254 assertEqual( model.constraints().count(), 1 ); 00255 00256 QPersistentModelIndex idx1 = dummyModel.index( 7, 17, QModelIndex() ); 00257 QPersistentModelIndex idx2 = dummyModel.index( 42, 17, QModelIndex() ); 00258 00259 model.addConstraint( Constraint( idx1, idx2 ) ); 00260 assertEqual( model.constraints().count(), 2 ); 00261 assertTrue( model.hasConstraint( Constraint( idx1, idx2 ) ) ); 00262 00263 assertEqual( model.constraintsForIndex( QModelIndex() ).count(), 1 ); 00264 00265 assertEqual( model.constraints().count(), 2 ); 00266 model.removeConstraint( Constraint( QModelIndex(), QModelIndex() ) ); 00267 assertEqual( model.constraints().count(), 1 ); 00268 assertFalse( model.hasConstraint( Constraint( QModelIndex(), QModelIndex() ) ) ); 00269 00270 model.removeConstraint( Constraint( QModelIndex(), QModelIndex() ) ); 00271 assertEqual( model.constraints().count(), 1 ); 00272 00273 model.removeConstraint( Constraint( idx1, idx2 ) ); 00274 assertEqual( model.constraints().count(), 0 ); 00275 assertFalse( model.hasConstraint( Constraint( idx1, idx2 ) ) ); 00276 00277 model.addConstraint( Constraint( idx1, idx2 ) ); 00278 assertTrue( model.hasConstraint( Constraint( idx1, idx2 ) ) ); 00279 dummyModel.removeRow( 8 ); 00280 assertTrue( model.hasConstraint( Constraint( idx1, idx2 ) ) ); 00281 dummyModel.removeRow( 7 ); 00282 assertTrue( model.hasConstraint( Constraint( idx1, idx2 ) ) ); 00283 }
std::ostream& operator<< | ( | std::ostream & | os, | |
const QModelIndex & | idx | |||
) |
Definition at line 228 of file kdganttconstraintmodel.cpp.
00229 { 00230 QString str; 00231 QDebug( &str )<<idx; 00232 #ifdef QT_NO_STL 00233 os<<str.toLatin1().constData(); 00234 #else 00235 os<<str.toStdString(); 00236 #endif 00237 return os; 00238 }
QDebug operator<< | ( | QDebug | dbg, | |
const KDGantt::ConstraintModel & | model | |||
) |
Definition at line 211 of file kdganttconstraintmodel.cpp.
References KDGantt::ConstraintModel::constraints().
00212 { 00213 dbg << "KDGantt::ConstraintModel[ " << static_cast<const QObject*>( &model ) << ":" 00214 << model.constraints() << "]"; 00215 return dbg; 00216 }