diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-01-17 13:39:59 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-01-17 13:39:59 +0200 |
commit | 4c73f86fc6cbdaaee90f9f8e40af36c1ab84c374 (patch) | |
tree | 63b42986ffccb3c0fdb3b978f3c78b56ca5a03a8 /test | |
parent | Create default profile when the one set doesn't exist (diff) | |
parent | Parse Tags and Descriptions in FFJson (diff) | |
download | smolbote-4c73f86fc6cbdaaee90f9f8e40af36c1ab84c374.tar.xz |
Merge branch 'firefox-bookmarks-json-importer'
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() +) |