mirror of
https://github.com/status-im/snorenotify.git
synced 2025-01-09 16:15:45 +00:00
add a test that creates 100 notifications
This commit is contained in:
parent
d1aef594d8
commit
b161530394
@ -1,4 +1,5 @@
|
||||
#include <libsnore/snore.h>
|
||||
#include <libsnore/snore_p.h>
|
||||
#include <libsnore/utils.h>
|
||||
|
||||
#include <QTextDocument>
|
||||
@ -13,9 +14,14 @@ class SnoreBenchmark : public QObject
|
||||
public:
|
||||
SnoreBenchmark()
|
||||
{
|
||||
SnoreCore::instance();
|
||||
SnoreLog::setDebugLvl(3);
|
||||
SnoreCore &instance = SnoreCore::instance();
|
||||
instance.loadPlugins(SnorePlugin::BACKEND);
|
||||
instance.setSettingsValue(QLatin1String("Timeout"), 1, LOCAL_SETTING);
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString htmlTestString = QLatin1String("<i>Italic A</i><br>"
|
||||
"<i>Italic B</i><br>"
|
||||
"<b>Bold</b><br>"
|
||||
@ -23,10 +29,13 @@ public:
|
||||
"<font color=\"blue\">Font</font><br>"
|
||||
"<&><br>"
|
||||
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a><br>");
|
||||
QTemporaryFile tempSettings;
|
||||
|
||||
private Q_SLOTS:
|
||||
void benchmarkUtilsToHtml();
|
||||
void benchmarkUtilsToHtmlAllMarkup();
|
||||
void benchmarkUtilsToPlain();
|
||||
void benchmarkNotifications();
|
||||
|
||||
};
|
||||
|
||||
@ -34,19 +43,19 @@ void SnoreBenchmark::benchmarkUtilsToHtml()
|
||||
{
|
||||
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP), QLatin1String("Italic A\n"
|
||||
"Italic B\n"
|
||||
"Bold\n"
|
||||
"Underline\n"
|
||||
"Font\n"
|
||||
"<&>\n"
|
||||
"Website\n"));
|
||||
"Italic B\n"
|
||||
"Bold\n"
|
||||
"Underline\n"
|
||||
"Font\n"
|
||||
"<&>\n"
|
||||
"Website\n"));
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF), QLatin1String("Italic A\n"
|
||||
"Italic B\n"
|
||||
"Bold\n"
|
||||
"Underline\n"
|
||||
"Font\n"
|
||||
"<&>\n"
|
||||
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a>\n"));
|
||||
"Italic B\n"
|
||||
"Bold\n"
|
||||
"Underline\n"
|
||||
"Font\n"
|
||||
"<&>\n"
|
||||
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a>\n"));
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF | Utils::BOLD | Utils::BREAK |
|
||||
Utils::UNDERLINE | Utils::FONT | Utils::ITALIC), htmlTestString);
|
||||
QBENCHMARK{
|
||||
@ -69,6 +78,31 @@ void SnoreBenchmark::benchmarkUtilsToPlain()
|
||||
Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP);
|
||||
}
|
||||
}
|
||||
|
||||
void SnoreBenchmark::benchmarkNotifications()
|
||||
{
|
||||
SnoreCore &instance = SnoreCore::instance();
|
||||
int closed = 0;
|
||||
connect(&instance, SnoreCore::notificationClosed, [&closed](Notification)
|
||||
{
|
||||
closed++;
|
||||
});
|
||||
|
||||
Application app = SnoreCorePrivate::instance()->defaultApplication();
|
||||
// QBENCHMARK_ONCE{
|
||||
for( int i=0; i<100; ++i)
|
||||
{
|
||||
QString number = QString::number(i);
|
||||
Notification n(app, app.defaultAlert(), QLatin1String("Test ") + number, QLatin1String("Message ") + number, app.icon() );
|
||||
instance.broadcastNotification(n);
|
||||
}
|
||||
// }
|
||||
while(closed < 100){
|
||||
QTest::qWait(100);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QTEST_MAIN(SnoreBenchmark)
|
||||
|
||||
#include "snorebenchmark.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user