Added more tests and guard for null pointer access

This commit is contained in:
Magne Sjaastad
2017-09-19 12:01:16 +02:00
parent b078feb736
commit 31cbd35862
2 changed files with 37 additions and 7 deletions

View File

@@ -44,6 +44,9 @@ QList<caf::PdmOptionItemInfo> createOptions()
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -54,6 +57,8 @@ TEST(PdmUiTreeSelectionQModelTest, BasicUsage)
caf::PdmUiTreeSelectionQModel myModel;
myModel.setOptions(nullptr, options);
EXPECT_EQ(options.size(), myModel.optionItemCount());
EXPECT_EQ(4, myModel.rowCount(myModel.index(-1, -1)));
EXPECT_EQ(0, myModel.rowCount(myModel.index(0, 0)));
@@ -105,3 +110,24 @@ TEST(PdmUiTreeSelectionQModelTest, SetDataAndSignal)
myModel.setData(parentIndex, QVariant(true));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(PdmUiTreeSelectionQModelTest, SetCheckedStateForItems)
{
QList<caf::PdmOptionItemInfo> options = createOptions();
caf::PdmUiTreeSelectionQModel myModel;
myModel.setOptions(nullptr, options);
QModelIndex parentIndex = myModel.index(1, 0);
QModelIndex firstChildIndex = myModel.index(0, 0, parentIndex);
QModelIndexList indices;
indices << firstChildIndex;
myModel.setCheckedStateForItems(indices, false);
// No test code for this behaviour, only making sure this runs without any errors
}