Work on MockQAbstractListModel

This commit is contained in:
Filippo Cucchetto 2016-06-19 17:30:43 +02:00
parent e4801423ff
commit 87b10be514
2 changed files with 17 additions and 8 deletions

View File

@ -68,13 +68,23 @@ void MockQAbstractListModel::onRowCountCalled(void *selfVPtr, const DosQModelInd
void MockQAbstractListModel::onColumnCountCalled(void *selfVPtr, const DosQModelIndex *index, int *result)
{
auto self = static_cast<MockQAbstractListModel*>(selfVPtr);
*result = 0;
*result = 1;
}
void MockQAbstractListModel::onDataCalled(void *selfVPtr, const DosQModelIndex *index, int role, DosQVariant *result)
{
auto self = static_cast<MockQAbstractListModel*>(selfVPtr);
if (!dos_qmodelindex_isValid(index))
return;
const int row = dos_qmodelindex_row(index);
const int column = dos_qmodelindex_column(index);
if (row < 0 || row >= self->m_names.size() || column != 0)
return;
dos_qvariant_setString(result, self->m_names[row].c_str());
}
void MockQAbstractListModel::onSetDataCalled(void *selfVPtr, const DosQModelIndex *index, const DosQVariant *value, int role, bool *result)

View File

@ -5,18 +5,17 @@ QtObject {
objectName: "testCase"
function testRowCount() {
if (!testObject)
return false
return testObject.rowCount() === 4
return testObject && testObject.rowCount() === 4
}
function testColumnCount() {
if (!testObject)
return false
return testObject.columnCount() === 0;
return testObject && testObject.columnCount() === 1;
}
function testData() {
return true
return testObject && testObject.data(testObject.index(0,0, null)) === "John"
&& testObject.data(testObject.index(1,0, null)) === "Mary"
&& testObject.data(testObject.index(2,0, null)) === "Andy"
&& testObject.data(testObject.index(3,0, null)) === "Anna"
}
}