Add autotest for roommodel and user classes
ClosedPublic

Authored by velurimithun on Jan 3 2018, 6:52 PM.

Details

Summary

test roommodel methods

Diff Detail

Repository
R865 Ruqola
Branch
myBranch
Lint
No Linters Available
Unit
No Unit Test Coverage
There are a very large number of changes, so older changes are hidden. Show Older Changes
velurimithun added inline comments.Jan 3 2018, 7:12 PM
autotests/roommodeltest.cpp
52

check with selected 'true' (3rd arugument)

mlaurent added inline comments.Jan 4 2018, 6:06 AM
autotests/roommodeltest.cpp
63

if it creates a crash/error we need to fix it in roommodel

86

delete it at the end of method

91

Cache this value as const QString name = QStringLiteral("newName")
so you can verify it easyly QCOMPARE(name, sampleWrapper->name());

98

QVERIFY(samepl->readOnly());

mlaurent requested changes to this revision.Jan 4 2018, 6:06 AM
This revision now requires changes to proceed.Jan 4 2018, 6:06 AM
velurimithun marked 3 inline comments as done.
  • Change updateRoom method in roomModel and add tests for roomModel

previous updateRomm method in roomModel(QJsonObject) was changing with name, now roomId is considered for change.

add tests for updateSubcription

  • clarity on updateRoom(QJsonObject)

can you please tell me exactly what updateRoom should do in roomModel.cpp?
It should update the existing values or It should update the existing values and add new values passed through arguments.

  • diff b/w "updated" case and "changed" in roomModel.cpp??
autotests/roommodeltest.cpp
138

Here it readOnly is true by default!

Although we didn't mention it in QJsonObject.

163

Since, this is a new roomId which is not added -> it should not be removed.

  • Add test cases for user
velurimithun added inline comments.Jan 5 2018, 2:52 AM
autotests/usertest.cpp
44 ↗(On Diff #24730)

unable to define user class on stack -> User *u;

Error

  • Add more tests to user and roomModel
velurimithun added inline comments.Jan 5 2018, 5:10 AM
autotests/usertest.cpp
137 ↗(On Diff #24748)

Here I think there is no need to check nameChanged and statusChagned signals since all those were checked earlier!

mlaurent requested changes to this revision.Jan 5 2018, 6:08 AM
mlaurent added inline comments.
autotests/rocketchataccountsettingstest.cpp
69

Same

autotests/rocketchataccountsettingstest.h
50

why you add theses changes in this review §?

autotests/roommodeltest.cpp
63

So ? do you still have error ?

100

Same for name as you use it all the time create a variable for it

108

it's better to compare "variable" to value

> QCompare(spy.count(), 1)

128

Fails ? which is the problem ?

129

same QCompare(value, 1); fix all others QCOMPARE if necessary

it's value compare with expected

when it failed you can see correct debug

163

you still use input.append(QJsonValue(QLatin1String("removed"))); so it's correct no.
If it found "removed" it will remove it will not added no ?

otherwise you need to need to have QStringLiteral("inserted")

211

readOnly true...
it's wierd.... we need to know why it's readonly

254

yep todo

autotests/usertest.cpp
44 ↗(On Diff #24730)

? what is the error?

137 ↗(On Diff #24748)

We need to do it because for the moment yep we use this code:
" const QJsonObject fields = object.value(QLatin1String("fields")).toObject();

setName(fields.value(QLatin1String("name")).toString());
setUserId(object.value(QLatin1String("id")).toString());
setStatus(fields.value(QLatin1String("status")).toString());"

so we know that we use setName/setStatus etc.
but perhaps in the future we will change and assign directly as value

> signal will not emit and it will be an error

> test signal too.

159 ↗(On Diff #24748)

!= please :)

src/roommodel.cpp
233

qCDebug(...)

This revision now requires changes to proceed.Jan 5 2018, 6:08 AM
velurimithun marked 5 inline comments as done.
  • Modify the code

clarity on updateRoom(QJsonObject)

  • can you please tell me exactly what updateRoom should do in roomModel.cpp?
  • It should update the existing values or It should update the existing values and add new values passed through arguments.

diff b/w "updated" case and "changed" in roomModel.cpp??

autotests/roommodeltest.cpp
211

Sry, I actually raised this issue in L138 only !! in the previous update, same problem here also

autotests/usertest.cpp
44 ↗(On Diff #24730)

Sry, NO ERROR

159 ↗(On Diff #24748)

we don't have != for User class, thats why I used ! ( == )

velurimithun added inline comments.Jan 5 2018, 8:24 AM
autotests/rocketchataccountsettingstest.h
50

I'll remove this in next update

mlaurent added inline comments.Jan 5 2018, 8:53 AM
autotests/usertest.cpp
159 ↗(On Diff #24748)

Add the missing operator in class.

  • Fix parseUpdateRoom method in room.cpp

oom(QJsonObject) used the above method for updating name, satus, announcements but that method in room.cpp doesn't update name of the room from QJsonObject.

Now it if fixed, name also will be updated.
velurimithun marked 3 inline comments as done.Jan 5 2018, 4:30 PM
velurimithun added inline comments.
autotests/roommodeltest.cpp
63

changed the code for findRoom in roomModel.cpp NO ERROR it returns new roomWrapper with no room initialized in it

but, when u try to access the name of the room then we'll get null pointer access error!

that is in commented line.

128

It is fixed now:)

problem was in praseUpdate method in room.cpp class, it was not updating name.

pl. have a look at changes in room.cpp file

forgot to remove comment "here it fails!", it will be removed in next update.

186

shouldUpdateSubcriptionActionChanged is not tested, since changed case in updateSubscription method in roomModel doesn't do anything new other than updating

pl. have a look at updateSubcription method in roomModel.cpp

velurimithun marked an inline comment as done.
  • Add test for data in roomModel
mlaurent requested changes to this revision.Jan 7 2018, 10:40 AM
mlaurent added inline comments.
autotests/roommodeltest.cpp
68

So you need to test that pointer is null here.
Otherwise it's not necessary to use findRoom if you don't test value.

But I prefere that we check this value

255

Good for testing default value but please add a test when it's not default value too thanks.

autotests/usertest.cpp
50 ↗(On Diff #24810)

QCOMPARE(current value, expected) same for other QCOMPARE

src/roommodel.cpp
77

If we don't find roomId we mustn't create a new RoomWrapper.
We need to check nullptr in return value otherwise we will create a not existing room.

233

qCDebug(debug categori") and uncomment it please.

src/user.cpp
78 ↗(On Diff #24810)

heu... return !User::operator(User) it doesn't work ?
We don't need to add duplicate code.

This revision now requires changes to proceed.Jan 7 2018, 10:40 AM
velurimithun marked 5 inline comments as done.
  • write non-default test cases for data method in roomModel

rewrite QCOMPARE() properly in userTest.cpp
log the print statments in roomModel to RUQOLA_LIB through qCDebug
change the findRoom method to return nullptr if it doesn't find room!

velurimithun added inline comments.Jan 7 2018, 4:22 PM
autotests/usertest.cpp
50 ↗(On Diff #24810)

Done it in roomModelTest but forgot in userTest

now, it is corrected everywhere!:)

velurimithun retitled this revision from << Add autotest for roommodel >> to Add autotest for roommodel and user classes.Jan 7 2018, 4:23 PM
mlaurent requested changes to this revision.Jan 9 2018, 6:57 AM
mlaurent added inline comments.
autotests/roommodeltest.cpp
343

compare with selected value no ?

363

QCOMPARE(..., favorite)

autotests/usertest.cpp
50 ↗(On Diff #24887)

QCOMPARE(value, expected)

74 ↗(On Diff #24887)

QCOMPARE(value, expected) please verify each QCOMPARe

src/roommodel.cpp
233

RUQOLA_LOG without () I know that it compiles but we use by default without () same for others code

This revision now requires changes to proceed.Jan 9 2018, 6:57 AM
velurimithun marked 5 inline comments as done.
  • Fix minor errors
mlaurent added inline comments.Jan 10 2018, 5:52 AM
src/roommodel.cpp
233

RUQOLA_LOG without () ...

Use () for qCDebug(RUQOLA_LOG) in roomModel.cpp

velurimithun marked an inline comment as done.Jan 11 2018, 6:23 PM
mlaurent added inline comments.Jan 11 2018, 9:56 PM
src/roommodel.cpp
233

nope "RUQOLA_LOG without () I know that it compiles but we use by default without () same for others code"

> qDebug(RUQOLA_LOG) << ...

  • Remove () after RUQOLA_LOG in qCDebug()
velurimithun marked an inline comment as done.Jan 12 2018, 3:08 AM
mlaurent requested changes to this revision.Jan 12 2018, 5:59 AM
mlaurent added inline comments.
tests/CMakeLists.txt
63 ↗(On Diff #25195)

Remove all this code....

Please create several branch where you put specific code as autotests and and other one for qmlFileTestResources

git checkout -b add_autotest_room_model for this one

and git checkout -b add_qmltest for other one.

Please rebase from master I changed a lot of thing.

This revision now requires changes to proceed.Jan 12 2018, 5:59 AM
  • Undo the changes for qmlTestApp
mlaurent accepted this revision.Jan 12 2018, 6:39 PM

Seems ok now.
Thanks

This revision is now accepted and ready to land.Jan 12 2018, 6:39 PM
This revision was automatically updated to reflect the committed changes.