diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/firefox-bookmarks-json-parser/main.cpp | 35 | ||||
| -rw-r--r-- | test/firefox-bookmarks-json-parser/meson.build | 13 | 
2 files changed, 48 insertions, 0 deletions
| diff --git a/test/firefox-bookmarks-json-parser/main.cpp b/test/firefox-bookmarks-json-parser/main.cpp new file mode 100644 index 0000000..54819a2 --- /dev/null +++ b/test/firefox-bookmarks-json-parser/main.cpp @@ -0,0 +1,35 @@ +#include <QFile> +#include "bookmarkformat.h" +#include <QTreeView> +#include <QApplication> +#include <QDebug> + +int main(int argc, char** argv) +{ +    QApplication app(argc, argv); + +    QFile f(qgetenv("FILE")); + +    auto *model = new BookmarkModel; +     +    if(f.open(QIODevice::ReadOnly)) { +        BookmarkFormat<FirefoxJsonFormat>(&f) >> model; +        f.close(); +    } else +        return -1; + +    auto *view = new QTreeView; +    view->setModel(model); + +    if(qgetenv("NOGUI") == "1") +        return 0; + +    QObject::connect(view, &QTreeView::activated, [model](const QModelIndex &index) { +        const auto tags = model->data(index, BookmarkItem::Tags, Qt::DisplayRole).toStringList(); +        qDebug() << tags.join(" || "); +    }); + + +    view->show(); +    return app.exec(); +} diff --git a/test/firefox-bookmarks-json-parser/meson.build b/test/firefox-bookmarks-json-parser/meson.build new file mode 100644 index 0000000..1432e68 --- /dev/null +++ b/test/firefox-bookmarks-json-parser/meson.build @@ -0,0 +1,13 @@ +e = executable('bookmarks-json-parser', +  sources: [ 'main.cpp' ], +  dependencies: [ dep_qt5, dep_bookmarks ] +) + +env = environment({ +  'NOGUI' : '1', +  'FILE' : 'bookmarks.json' +}) +test('Firefox bookmarks.json parser', e, +  env: env, +  workdir: meson.build_root() +) | 
