Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nemo-qml-plugin-time] Stabilize the unit test. JB#57887 #2

Merged
merged 1 commit into from Apr 1, 2022

Conversation

pvuorela
Copy link
Contributor

@pvuorela pvuorela commented Apr 1, 2022

Comparing exact seconds between WallClock and QDateTime::currentDateTime()
is just waiting for failures as occasionally the second will change
on wrong place. Giving it now some leeway.

Also we don't need to test javascript datetime field getter api here.

@spiiroin @Tomin1

Comparing exact seconds between WallClock and QDateTime::currentDateTime()
is just waiting for failures as occasionally the second will change
on wrong place. Giving it now some leeway.

Also we don't need to test javascript datetime field getter api here.
QVERIFY(time.isValid());
int timeSecs = time.toMSecsSinceEpoch() / 1000;
// giving some leeway
QVERIFY(currentSecs == timeSecs || currentSecs == timeSecs + 1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no reason why this would not work, but ...

There is toSecsSinceEpoch() method that could be used instead of dividing millsecs by 1000.

Or, depending on is jitter expected only in one or both directions, one could perhaps use some form of QVERIFY(abs(deltaInMs) <= 1000) type thing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This function was introduced in Qt 5.8." 🤔

But I like the idea of using abs() there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One slight problem with abs(), even if small, is that it wouldn't guarantee the ordering of the timestamps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is approved, I'll just merge :)

@pvuorela pvuorela merged commit 5761e08 into master Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants