From 52fd2c12a243e206617bdaf6e762407fb2939b94 Mon Sep 17 00:00:00 2001 From: Antonis Tsiapaliokas Date: Fri, 9 Aug 2013 16:34:50 +0300 Subject: [PATCH] Make all of our unit test to pass --- kcmkwin/kwincompositing/model.cpp | 6 +++++- kcmkwin/kwincompositing/test/effectmodeltest.cpp | 9 +++++++-- kcmkwin/kwincompositing/test/effectmodeltest.h | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/kcmkwin/kwincompositing/model.cpp b/kcmkwin/kwincompositing/model.cpp index 56af9da53c..d61aef09c0 100644 --- a/kcmkwin/kwincompositing/model.cpp +++ b/kcmkwin/kwincompositing/model.cpp @@ -60,7 +60,7 @@ EffectModel::EffectModel(QObject *parent) } QModelIndex EffectModel::index(int row, int column, const QModelIndex &parent) const { - if (!parent.isValid() || column > 0 || row < 0 || row >= rowCount()) { +if (parent.isValid() || column > 0 || column < 0 || row < 0 || row >= m_effectsList.count()) { return QModelIndex(); } @@ -69,6 +69,7 @@ QModelIndex EffectModel::index(int row, int column, const QModelIndex &parent) c QModelIndex EffectModel::parent(const QModelIndex &child) const { Q_UNUSED(child) + return QModelIndex(); } @@ -77,6 +78,9 @@ int EffectModel::columnCount(const QModelIndex &parent) const { } int EffectModel::rowCount(const QModelIndex &parent) const { + if (parent.isValid()) { + return 0; + } return m_effectsList.count(); } diff --git a/kcmkwin/kwincompositing/test/effectmodeltest.cpp b/kcmkwin/kwincompositing/test/effectmodeltest.cpp index 829d3a9cdf..ed0223c2f6 100644 --- a/kcmkwin/kwincompositing/test/effectmodeltest.cpp +++ b/kcmkwin/kwincompositing/test/effectmodeltest.cpp @@ -28,13 +28,18 @@ EffectModelTest::EffectModelTest(QObject *parent) } -void EffectModelTest::testModel() { +void EffectModelTest::testEffectModel() { + KWin::Compositing::EffectModel *effectModel = new KWin::Compositing::EffectModel(); + + new ModelTest(effectModel, this); +} + +void EffectModelTest::testEffectFilterModel() { KWin::Compositing::EffectFilterModel *model = new KWin::Compositing::EffectFilterModel(); KWin::Compositing::EffectModel *effectModel = new KWin::Compositing::EffectModel(); model->setEffectModel(effectModel); new ModelTest(model, this); - } QTEST_MAIN(EffectModelTest) diff --git a/kcmkwin/kwincompositing/test/effectmodeltest.h b/kcmkwin/kwincompositing/test/effectmodeltest.h index 20c40bb68c..cb71a76df8 100644 --- a/kcmkwin/kwincompositing/test/effectmodeltest.h +++ b/kcmkwin/kwincompositing/test/effectmodeltest.h @@ -32,6 +32,7 @@ public: EffectModelTest(QObject *parent = 0); private Q_SLOTS: - void testModel(); + void testEffectModel(); + void testEffectFilterModel(); }; #endif