/* Copyright (c) 2010 Stephen Kelly This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kselectionproxymodeltestsuite.h" #include #include #include "../itemviews/kselectionproxymodel.h" #include "modelselector.h" //BEGIN NoSelection /** When there is no selection, everything from the source model should be a noop in the proxy. */ template class TestData : public NoSelectionStrategy { public: TestData(ProxyModelTest *proxyModelTest) : NoSelectionStrategy(proxyModelTest), m_proxyModelTest(proxyModelTest) { } // If there is no selection, changes in the source model have no effect. void noselection_testMoveData() { QTest::addColumn("signalList"); QTest::addColumn("changeList"); noopTest("move01"); noopTest("move02"); noopTest("move03"); noopTest("move04"); noopTest("move05"); } KSelectionProxyModel::FilterBehavior filterBehaviour() { return _filterBehaviour; } void testInsertWhenEmptyData() { noop_testInsertWhenEmptyData(); } void testInsertInRootData() { noop_testInsertInRootData(); } void testInsertInTopLevelData() { noop_testInsertInTopLevelData(); } void testInsertInSecondLevelData() { noop_testInsertInSecondLevelData(); } void testRemoveFromRootData() { noop_testRemoveFromRootData(); } void testRemoveFromTopLevelData() { noop_testRemoveFromTopLevelData(); } void testRemoveFromSecondLevelData() { noop_testRemoveFromSecondLevelData(); } void testMoveFromRootData() { noselection_testMoveData(); } void testMoveFromTopLevelData() { noselection_testMoveData(); } void testMoveFromSecondLevelData() { noselection_testMoveData(); } void testModifyInRootData() { noop_testModifyInRootData(); } void testModifyInTopLevelData() { noop_testModifyInTopLevelData(); } void testModifyInSecondLevelData() { noop_testModifyInSecondLevelData(); } private: ProxyModelTest *m_proxyModelTest; }; //END NoSelection //BEGIN ImmediateSelectionStrategy //BEGIN ChildrenOfExactSelection template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testInsertWhenEmptyData() { noop_testInsertWhenEmptyData(); } template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testInsertInRootData() { noop_testInsertInRootData(); } template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testInsertInTopLevelData() { QTest::addColumn("signalList"); QTest::addColumn("changeList"); IndexFinder indexFinder; newInsertTest("insert01", indexFinder, 0, 0, 10); newInsertTest("insert02", indexFinder, 0, 9, 10); newInsertTest("insert03", indexFinder, 10, 10, 10); newInsertTest("insert04", indexFinder, 10, 19, 10); newInsertTest("insert05", indexFinder, 4, 4, 10); newInsertTest("insert06", indexFinder, 4, 13, 10); newInsertTest("insert07", indexFinder, 0, 0, 10); newInsertTest("insert08", indexFinder, 10, 10, 10); newInsertTest("insert09", indexFinder, 4, 4, 10); newInsertTest("insert10", indexFinder, 0, 4, 10); newInsertTest("insert11", indexFinder, 10, 14, 10); newInsertTest("insert12", indexFinder, 4, 8, 10); noopTest("insert13"); noopTest("insert14"); noopTest("insert15"); noopTest("insert16"); noopTest("insert17"); noopTest("insert18"); } template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testInsertInSecondLevelData() { noop_testInsertInSecondLevelData(); } template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testRemoveFromRootData() { noop_testRemoveFromRootData(); } template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testRemoveFromTopLevelData() { QTest::addColumn("signalList"); QTest::addColumn("changeList"); IndexFinder indexFinder; newRemoveTest("remove01", indexFinder, 0, 0, 10); newRemoveTest("remove02", indexFinder, 0, 4, 10); newRemoveTest("remove03", indexFinder, 9, 9, 10); } template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testRemoveFromSecondLevelData() { noop_testRemoveFromSecondLevelData(); } template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testMoveFromRootData() { noop_testMoveFromRootData(); } template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testMoveFromTopLevelData() { IndexFinder indexFinder; testForwardingMoveData(indexFinder, indexFinder); } template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testMoveFromSecondLevelData() { noop_testMoveFromSecondLevelData(); } template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testModifyInRootData() { noop_testModifyInRootData(); } template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testModifyInTopLevelData() { QTest::addColumn("signalList"); QTest::addColumn("changeList"); newModifyTest("modify01", IndexFinder(), 0, 0 ); newModifyTest("modify02", IndexFinder(), 0, 4 ); newModifyTest("modify03", IndexFinder(), 9, 9 ); newModifyTest("modify04", IndexFinder(), 6, 9 ); newModifyTest("modify05", IndexFinder(), 4, 4 ); newModifyTest("modify06", IndexFinder(), 3, 7 ); newModifyTest("modify07", IndexFinder(), 0, 9 ); } template<> void TestData, KSelectionProxyModel::ChildrenOfExactSelection>::testModifyInSecondLevelData() { noop_testModifyInSecondLevelData(); } //END ChildrenOfExactSelection //BEGIN ExactSelection template<> void TestData, KSelectionProxyModel::ExactSelection>::testInsertWhenEmptyData() { QTest::addColumn("signalList"); QTest::addColumn("changeList"); IndexFinder indexFinder; noopTest("insert01"); newInsertTest("insert02", indexFinder, 0, 0, 0); newInsertTest("insert03", indexFinder, 0, 0, 0); } template<> void TestData, KSelectionProxyModel::ExactSelection>::testInsertInRootData() { noop_testInsertInRootData(); } template<> void TestData, KSelectionProxyModel::ExactSelection>::testInsertInTopLevelData() { noop_testInsertInTopLevelData(); } template<> void TestData, KSelectionProxyModel::ExactSelection>::testInsertInSecondLevelData() { noop_testInsertInSecondLevelData(); } template<> void TestData, KSelectionProxyModel::ExactSelection>::testRemoveFromRootData() { noop_testRemoveFromRootData(); } template<> void TestData, KSelectionProxyModel::ExactSelection>::testRemoveFromTopLevelData() { noop_testRemoveFromTopLevelData(); } template<> void TestData, KSelectionProxyModel::ExactSelection>::testRemoveFromSecondLevelData() { noop_testRemoveFromSecondLevelData(); } template<> void TestData, KSelectionProxyModel::ExactSelection>::testMoveFromRootData() { noop_testMoveFromRootData(); } template<> void TestData, KSelectionProxyModel::ExactSelection>::testMoveFromTopLevelData() { noop_testMoveFromTopLevelData(); } template<> void TestData, KSelectionProxyModel::ExactSelection>::testMoveFromSecondLevelData() { noop_testMoveFromSecondLevelData(); } template<> void TestData, KSelectionProxyModel::ExactSelection>::testModifyInRootData() { QTest::addColumn("signalList"); QTest::addColumn("changeList"); noopTest("modify01"); noopTest("modify02"); noopTest("modify03"); noopTest("modify04"); noopTest("modify05"); newModifyTest("modify06", IndexFinder(), 0, 0 ); newModifyTest("modify07", IndexFinder(), 0, 0 ); } template<> void TestData, KSelectionProxyModel::ExactSelection>::testModifyInTopLevelData() { noop_testModifyInTopLevelData(); } template<> void TestData, KSelectionProxyModel::ExactSelection>::testModifyInSecondLevelData() { noop_testModifyInSecondLevelData(); } //END ExactSelection //BEGIN SubTrees template<> void TestData, KSelectionProxyModel::SubTrees>::testInsertWhenEmptyData() { QTest::addColumn("signalList"); QTest::addColumn("changeList"); IndexFinder indexFinder; noopTest("insert01"); newInsertTest("insert02", indexFinder, 0, 0, 0); newInsertTest("insert03", indexFinder, 0, 0, 0); } template<> void TestData, KSelectionProxyModel::SubTrees>::testInsertInRootData() { noop_testInsertInRootData(); } template<> void TestData, KSelectionProxyModel::SubTrees>::testInsertInTopLevelData() { testForwardingInsertData(IndexFinder(QList() << 0)); } template<> void TestData, KSelectionProxyModel::SubTrees>::testInsertInSecondLevelData() { testForwardingInsertData(IndexFinder(QList() << 0 << 5)); } template<> void TestData, KSelectionProxyModel::SubTrees>::testRemoveFromRootData() { noop_testRemoveFromRootData(); } template<> void TestData, KSelectionProxyModel::SubTrees>::testRemoveFromTopLevelData() { testForwardingRemoveData(IndexFinder(QList() << 0)); } template<> void TestData, KSelectionProxyModel::SubTrees>::testRemoveFromSecondLevelData() { testForwardingRemoveData(IndexFinder(QList() << 0 << 5)); } template<> void TestData, KSelectionProxyModel::SubTrees>::testMoveFromRootData() { noop_testMoveFromRootData(); } template<> void TestData, KSelectionProxyModel::SubTrees>::testMoveFromTopLevelData() { testForwardingMoveData(IndexFinder(QList() << 0), IndexFinder(QList() << 0)); } template<> void TestData, KSelectionProxyModel::SubTrees>::testMoveFromSecondLevelData() { testForwardingMoveData(IndexFinder(QList() << 0 << 5), IndexFinder(QList() << 0 << 5)); } template<> void TestData, KSelectionProxyModel::SubTrees>::testModifyInRootData() { QTest::addColumn("signalList"); QTest::addColumn("changeList"); noopTest("modify01"); noopTest("modify02"); noopTest("modify03"); noopTest("modify04"); noopTest("modify05"); newModifyTest("modify06", IndexFinder(), 0, 0 ); newModifyTest("modify07", IndexFinder(), 0, 0 ); } template<> void TestData, KSelectionProxyModel::SubTrees>::testModifyInTopLevelData() { testForwardingModifyData(IndexFinder(QList() << 0)); } template<> void TestData, KSelectionProxyModel::SubTrees>::testModifyInSecondLevelData() { testForwardingModifyData(IndexFinder(QList() << 0 << 5)); } //END SubTrees //END ImmediateSelectionStrategy PROXYMODELTEST_MAIN(SelectionProxyModelTest, SELECTIONPROXYMODELSIMPLETEST(NoSelectionStrategy, KSelectionProxyModel::ChildrenOfExactSelection) SELECTIONPROXYMODELSIMPLETEST(NoSelectionStrategy, KSelectionProxyModel::ExactSelection) SELECTIONPROXYMODELSIMPLETEST(NoSelectionStrategy, KSelectionProxyModel::SubTreeRoots) SELECTIONPROXYMODELSIMPLETEST(NoSelectionStrategy, KSelectionProxyModel::SubTrees) SELECTIONPROXYMODELSIMPLETEST(NoSelectionStrategy, KSelectionProxyModel::SubTreesWithoutRoots) SELECTIONCOMPLETETEST1(ImmediateSelectionStrategy, 9, KSelectionProxyModel::ChildrenOfExactSelection) SELECTIONCOMPLETETEST1(ImmediateSelectionStrategy, 9, KSelectionProxyModel::ExactSelection) SELECTIONCOMPLETETEST1(ImmediateSelectionStrategy, 9, KSelectionProxyModel::SubTrees) )