mirror of
https://github.com/status-im/dotherside.git
synced 2025-02-12 04:26:43 +00:00
Work on MockQAbstractListModel
This commit is contained in:
parent
e4801423ff
commit
87b10be514
@ -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)
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user