mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added more tests and guard for null pointer access
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user