aboutsummaryrefslogtreecommitdiff
path: root/test/firefox-bookmarks-json-parser
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-01-16 21:40:15 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2020-01-16 21:55:45 +0200
commit198be208d49990c3535ac765735768ad1ae79c1b (patch)
tree98b3ef03f55e0f08893cdd6713effbf54f10f11f /test/firefox-bookmarks-json-parser
parentMove BookmarksWidget out of libbookmarks (diff)
downloadsmolbote-198be208d49990c3535ac765735768ad1ae79c1b.tar.xz
Add Firefox bookmarks.json format to libbookmarks
- can only read folders and bookmarks, their title and uri fields Not supported by Bookmark Model: - Separator items - Date added and Date modified fields
Diffstat (limited to 'test/firefox-bookmarks-json-parser')
-rw-r--r--test/firefox-bookmarks-json-parser/main.cpp28
-rw-r--r--test/firefox-bookmarks-json-parser/meson.build13
2 files changed, 41 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..48093ec
--- /dev/null
+++ b/test/firefox-bookmarks-json-parser/main.cpp
@@ -0,0 +1,28 @@
+#include <QFile>
+#include "bookmarkformat.h"
+#include <QTreeView>
+#include <QApplication>
+
+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;
+
+ 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()
+)