diff --git a/plugins/backend/CMakeLists.txt b/plugins/backend/CMakeLists.txt
index 2ef306c49..fd0a3e759 100644
--- a/plugins/backend/CMakeLists.txt
+++ b/plugins/backend/CMakeLists.txt
@@ -20,6 +20,7 @@ MESSAGE(STATUS "Backend FEEDBIN: " ${FEEDBIN})
MESSAGE(STATUS "Backend FEEDHQ: " ${FEEDHQ})
MESSAGE(STATUS "Backend BAZQUX: " ${FEEDHQ})
+add_subdirectory(test)
if(TTRSS)
add_subdirectory(ttrss)
diff --git a/plugins/backend/bazqux/bazquxInterface.vala b/plugins/backend/bazqux/bazquxInterface.vala
index 6837e0af1..426e564d1 100644
--- a/plugins/backend/bazqux/bazquxInterface.vala
+++ b/plugins/backend/bazqux/bazquxInterface.vala
@@ -22,7 +22,7 @@ public class FeedReader.bazquxInterface : Peas.ExtensionBase, FeedServerInterfac
private DataBaseReadOnly m_db;
private DataBase m_db_write;
- public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write)
+ public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write, string? host = null)
{
m_db = db;
m_db_write = db_write;
diff --git a/plugins/backend/demo/demoInterface.vala b/plugins/backend/demo/demoInterface.vala
index 6efe3dc44..a53370131 100644
--- a/plugins/backend/demo/demoInterface.vala
+++ b/plugins/backend/demo/demoInterface.vala
@@ -10,7 +10,7 @@ public class FeedReader.demoInterface : Peas.ExtensionBase, FeedServerInterface
// This method gets executed right after the plugin is loaded. Do everything
// you need to set up the plugin here.
//--------------------------------------------------------------------------------------
- public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write)
+ public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write, string? host = null)
{
}
diff --git a/plugins/backend/feedbin/CMakeLists.txt b/plugins/backend/feedbin/CMakeLists.txt
index b21430b61..f94fc82cf 100644
--- a/plugins/backend/feedbin/CMakeLists.txt
+++ b/plugins/backend/feedbin/CMakeLists.txt
@@ -1,43 +1,20 @@
set (PLUGNAME feedbin)
set (PLUGTARGET ${PLUGNAME}_target)
-set (API_NAME ${PLUGNAME}API)
-set (API_TARGET ${API_NAME}_target)
-
set (TEST_NAME ${PLUGNAME}_test)
set (TEST_TARGET ${TEST_NAME}_target)
-# ----------------------------------------------------------
-# Feedbin API Library
-# ----------------------------------------------------------
-
-vala_precompile(VALA_C ${API_TARGET}
- feedbinAPI.vala
-
-GENERATE_VAPI
- feedbinAPI
-
-PACKAGES
- json-glib-1.0
- libsoup-2.4
- gee-0.8
-
-OPTIONS
- --target-glib=2.32
- --library ${API_NAME}
-)
-
-add_library(${API_NAME} STATIC ${VALA_C})
-set_property(TARGET ${API_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
-
# ----------------------------------------------------------
# Feedbin Plugin
# ----------------------------------------------------------
vala_precompile(VALA_C ${PLUGTARGET}
+ feedbinAPI.vala
feedbinInterface.vala
feedbinUtils.vala
+GENERATE_VAPI FeedbinPlugin
+
PACKAGES
libpeas-1.0
gtk+-3.0
@@ -54,7 +31,6 @@ OPTIONS
CUSTOM_VAPIS
${CMAKE_BINARY_DIR}/FeedReader.vapi
- ${CMAKE_BINARY_DIR}/plugins/backend/feedbin/feedbinAPI.vapi
${CMAKE_SOURCE_DIR}/vapi/gd-1.0.vapi
${CMAKE_SOURCE_DIR}/vapi/webkit2gtk-4.0.vapi
)
@@ -62,36 +38,46 @@ CUSTOM_VAPIS
GLIB_COMPILE_RESOURCES(GRESOURCES SOURCE ${PLUGNAME}.gresource.xml)
add_library(${PLUGNAME} SHARED ${VALA_C} ${GRESOURCES})
-target_link_libraries(${PLUGNAME} ${API_NAME})
# ----------------------------------------------------------
-add_dependencies(${PLUGNAME} ${UI_NAME} ${FEEDREADER_NAME})
+add_dependencies(${PLUGNAME} ${FEEDREADER_NAME})
add_schema("org.gnome.feedreader.${PLUGNAME}.gschema.xml")
+install(TARGETS ${PLUGNAME} DESTINATION ${PKGLIBDIR}/plugins)
+install(FILES ${PLUGNAME}.plugin DESTINATION ${PKGLIBDIR}/plugins)
+
# ----------------------------------------------------------
# Tests
# ----------------------------------------------------------
-install(TARGETS ${PLUGNAME} DESTINATION ${PKGLIBDIR}/plugins)
-install(FILES ${PLUGNAME}.plugin DESTINATION ${PKGLIBDIR}/plugins)
vala_precompile(VALA_C ${TEST_TARGET}
TestFeedbin.vala
PACKAGES
+ libpeas-1.0
+ gtk+-3.0
json-glib-1.0
libsoup-2.4
gee-0.8
+ libxml-2.0
+ sqlite3
+ libsecret-1
OPTIONS
+ --includedir=${CMAKE_BINARY_DIR}/plugins/backend/test/
--target-glib=2.32
--disable-warnings # since we frequently want to not catch errors
CUSTOM_VAPIS
- ${CMAKE_BINARY_DIR}/plugins/backend/feedbin/feedbinAPI.vapi
+ ${CMAKE_BINARY_DIR}/FeedReader.vapi
+ ${CMAKE_BINARY_DIR}/plugins/backend/feedbin/FeedbinPlugin.vapi
+ ${CMAKE_BINARY_DIR}/plugins/backend/test/TestPlugin.vapi
+ ${CMAKE_SOURCE_DIR}/vapi/gd-1.0.vapi
+ ${CMAKE_SOURCE_DIR}/vapi/webkit2gtk-4.0.vapi
)
add_executable(${TEST_NAME} ${VALA_C})
-target_link_libraries(${TEST_NAME} ${API_NAME})
+target_link_libraries(${TEST_NAME} ${PLUGNAME} TestPlugin)
add_test(${PLUGNAME} gtester -k -o ${CMAKE_BINARY_DIR}/${PLUGNAME}.gtester.log ${TEST_NAME})
diff --git a/plugins/backend/feedbin/TestFeedbin.vala b/plugins/backend/feedbin/TestFeedbin.vala
index 4ca004523..e26a88945 100644
--- a/plugins/backend/feedbin/TestFeedbin.vala
+++ b/plugins/backend/feedbin/TestFeedbin.vala
@@ -1,262 +1,283 @@
-const string host_env = "FEEDBIN_TEST_HOST";
-const string user_env = "FEEDBIN_TEST_USER";
-const string password_env = "FEEDBIN_TEST_PASSWORD";
-
-void delete_subscription(FeedbinAPI api, string url)
+// This file is part of FeedReader.
+//
+// FeedReader is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// FeedReader is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with FeedReader. If not, see .
+
+namespace FeedReader.Tests
{
- var subscriptions = api.get_subscriptions();
- foreach(var subscription in subscriptions)
- {
- if(subscription.feed_url != url)
- continue;
- api.delete_subscription(subscription.id);
- break;
- }
-}
+ const string host_env = "FEEDBIN_TEST_HOST";
+ const string user_env = "FEEDBIN_TEST_USER";
+ const string password_env = "FEEDBIN_TEST_PASSWORD";
+
+ void delete_subscription(FeedbinAPI api, string url)
+ {
+ var subscriptions = api.get_subscriptions();
+ foreach(var subscription in subscriptions)
+ {
+ if(subscription.feed_url != url)
+ continue;
+ api.delete_subscription(subscription.id);
+ break;
+ }
+ }
-void add_login_tests(string host)
-{
- string? username = Environment.get_variable(user_env);
- string? password = Environment.get_variable(password_env);
- if(username == null || password == null)
- return;
+ void add_login_tests(string host)
+ {
+ string? username = Environment.get_variable(user_env);
+ string? password = Environment.get_variable(password_env);
+ if(username == null || password == null)
+ return;
- // Stick a random number at the end of Feed URL's to ensure that they're
- // unique, even if we run two tests against the same account
- uint nonce = Random.next_int();
+ var plugin = new FeedReader.FeedbinInterface();
+ add_plugin_tests(plugin, host, username, password);
- Test.add_data_func ("/feedbinapi/login", () => {
+ // Stick a random number at the end of Feed URL's to ensure that they're
+ // unique, even if we run two tests against the same account
+ uint nonce = Random.next_int();
- var api = new FeedbinAPI(username, password, null, host);
- assert(api.login());
+ Test.add_data_func ("/feedbinapi/login", () => {
- api = new FeedbinAPI("wrong", "password", null, host);
- assert(!api.login());
+ var api = new FeedbinAPI(username, password, null, host);
+ assert(api.login());
- api.username = username;
- assert(!api.login());
+ api = new FeedbinAPI("wrong", "password", null, host);
+ assert(!api.login());
- api.password = password;
- assert(api.login());
- });
+ api.username = username;
+ assert(!api.login());
- Test.add_data_func ("/feedbinapi/subscription", () => {
- if(username == null || password == null)
- {
- Test.skip(@"Need $user_env and $password_env set to run Feedbin tests");
- return;
- }
+ api.password = password;
+ assert(api.login());
+ });
- var api = new FeedbinAPI(username, password, null, host);
+ Test.add_data_func ("/feedbinapi/subscription", () => {
+ if(username == null || password == null)
+ {
+ Test.skip(@"Need $user_env and $password_env set to run Feedbin tests");
+ return;
+ }
- var url = "https://www.brendanlong.com/feeds/all.atom.xml?feedreader-test-subscribe-$nonce";
- delete_subscription(api, url);
+ var api = new FeedbinAPI(username, password, null, host);
- var subscription = api.add_subscription(url);
- assert(subscription.id != 0);
+ var url = "https://www.brendanlong.com/feeds/all.atom.xml?feedreader-test-subscribe-$nonce";
+ delete_subscription(api, url);
- {
- var got_subscription = api.get_subscription(subscription.id);
- assert(got_subscription.id == subscription.id);
- }
+ var subscription = api.add_subscription(url);
+ assert(subscription.id != 0);
- bool found_subscription = false;
- foreach(var got_subscription in api.get_subscriptions())
- {
- if(got_subscription.id == subscription.id)
- {
- assert(got_subscription.feed_id == subscription.feed_id);
- assert(got_subscription.feed_url == subscription.feed_url);
- assert(got_subscription.site_url == subscription.site_url);
- assert(got_subscription.title == subscription.title);
- found_subscription = true;
- }
- }
- assert(found_subscription);
-
- string title = "Rename test";
- api.rename_subscription(subscription.id, title);
- var renamed_subscription = api.get_subscription(subscription.id);
- assert(renamed_subscription.title == title);
-
- api.delete_subscription(subscription.id);
- foreach(var got_subscription in api.get_subscriptions())
- {
- assert(got_subscription.id != subscription.id);
- assert(got_subscription.feed_url != url);
- }
- });
-
- Test.add_data_func ("/feedbinapi/taggings", () => {
- if(username == null || password == null)
- {
- Test.skip(@"Need $user_env and $password_env set to run Feedbin tests");
- return;
- }
-
- var api = new FeedbinAPI(username, password, null, host);
-
- var url = @"https://www.brendanlong.com/feeds/all.atom.xml?feedreader-test-taggings-$nonce";
- delete_subscription(api, url);
-
- var subscription = api.add_subscription(url);
-
- // The subscription is new so it shouldn't have any taggings
- var taggings = api.get_taggings();
- foreach(var tagging in taggings)
- {
- assert(tagging.feed_id != subscription.feed_id);
- }
-
- string category = "Taggings Test";
- api.add_tagging(subscription.feed_id, category);
-
- // Check taggings
- int64? tagging_id = null;
- foreach(var tagging in api.get_taggings())
- {
- if(tagging.feed_id == subscription.feed_id)
- {
- assert(tagging.name == category);
- tagging_id = tagging.id;
- break;
- }
- }
- assert(tagging_id != null);
-
- // Delete the tag and verify that it's gone
- api.delete_tagging(tagging_id);
- foreach(var tagging in api.get_taggings())
- {
- assert(tagging.feed_id != subscription.feed_id);
- }
+ {
+ var got_subscription = api.get_subscription(subscription.id);
+ assert(got_subscription.id == subscription.id);
+ }
- // cleanup
- api.delete_subscription(subscription.id);
- });
-
- Test.add_data_func ("/feedbinapi/entries", () => {
- if(username == null || password == null)
- {
- Test.skip(@"Need $user_env and $password_env set to run Feedbin tests");
- return;
- }
-
- var api = new FeedbinAPI(username, password, null, host);
-
- // Note: This one shouldn't be deleted or recreated, since we want the entries to be available
- var url = "https://www.brendanlong.com/feeds/all.atom.xml?feed-reader-test-entries";
-
- var subscription = api.add_subscription(url);
-
- /* FIXME: Figure out why this next line is failing
- var entries = api.get_entries(1, false, null, subscription.feed_id);
- foreach(var entry in entries)
- {
- assert(entry.feed_id == subscription.feed_id);
- }
-
- assert(entries.size > 0);
- int i = Random.int_range(0, entries.size);
- var entry = entries.to_array()[i];
- var entry_ids = new Gee.ArrayList();
- entry_ids.add(entry.id);
-
- // read status
- api.set_entries_read(entry_ids, true);
- var unread_entries = api.get_unread_entries();
- assert(!unread_entries.contains(entry.id));
-
- api.set_entries_read(entry_ids, false);
- unread_entries = api.get_unread_entries();
- assert(unread_entries.contains(entry.id));
-
- api.set_entries_read(entry_ids, true);
- unread_entries = api.get_unread_entries();
- assert(!unread_entries.contains(entry.id));
-
- // starred status
- api.set_entries_starred(entry_ids, true);
- var starred_entries = api.get_starred_entries();
- assert(starred_entries.contains(entry.id));
-
- api.set_entries_starred(entry_ids, false);
- starred_entries = api.get_starred_entries();
- assert(!starred_entries.contains(entry.id));
-
- api.set_entries_starred(entry_ids, true);
- starred_entries = api.get_starred_entries();
- assert(starred_entries.contains(entry.id));
- */
- });
-
- Test.add_data_func ("/feedbinapi/favicons", () => {
- if(username == null || password == null)
- {
- Test.skip(@"Need $user_env and $password_env set to run Feedbin tests");
- return;
- }
+ bool found_subscription = false;
+ foreach(var got_subscription in api.get_subscriptions())
+ {
+ if(got_subscription.id == subscription.id)
+ {
+ assert(got_subscription.feed_id == subscription.feed_id);
+ assert(got_subscription.feed_url == subscription.feed_url);
+ assert(got_subscription.site_url == subscription.site_url);
+ assert(got_subscription.title == subscription.title);
+ found_subscription = true;
+ }
+ }
+ assert(found_subscription);
- Bytes? expected_favicon;
- {
- var session = new Soup.Session();
- var message = new Soup.Message("GET", "https://www.brendanlong.com/theme/favicon.ico");
- var inputstream = session.send(message);
- var bytearray = new ByteArray();
- uint8[] buffer = new uint8[4096];
- size_t bytes_read = 0;
- do
+ string title = "Rename test";
+ api.rename_subscription(subscription.id, title);
+ var renamed_subscription = api.get_subscription(subscription.id);
+ assert(renamed_subscription.title == title);
+
+ api.delete_subscription(subscription.id);
+ foreach(var got_subscription in api.get_subscriptions())
{
- inputstream.read_all(buffer, out bytes_read);
- bytearray.append(buffer[0:bytes_read]);
+ assert(got_subscription.id != subscription.id);
+ assert(got_subscription.feed_url != url);
}
- while(bytes_read == 4096);
- expected_favicon = ByteArray.free_to_bytes(bytearray);
- }
+ });
- var api = new FeedbinAPI(username, password, null, host);
+ Test.add_data_func ("/feedbinapi/taggings", () => {
+ if(username == null || password == null)
+ {
+ Test.skip(@"Need $user_env and $password_env set to run Feedbin tests");
+ return;
+ }
- // Note: This one shouldn't be deleted or recreated, since we want the entries to be available
- var url = "https://www.brendanlong.com/feeds/all.atom.xml?feed-reader-test-favicons";
+ var api = new FeedbinAPI(username, password, null, host);
- var subscription = api.add_subscription(url);
- var favicons = api.get_favicons();
- bool found_favicon = false;
- foreach(var i in favicons.entries)
- {
- if(i.key != "www.brendanlong.com")
- continue;
- assert(i.value == expected_favicon);
- found_favicon = true;
- break;
- }
- // FIXME: We don't download icons on the test server because favicon downloading
- // is handled by a different service
- //assert(found_favicon);
- });
-}
+ var url = @"https://www.brendanlong.com/feeds/all.atom.xml?feedreader-test-taggings-$nonce";
+ delete_subscription(api, url);
-void main(string[] args)
-{
- Test.init(ref args);
+ var subscription = api.add_subscription(url);
+
+ // The subscription is new so it shouldn't have any taggings
+ var taggings = api.get_taggings();
+ foreach(var tagging in taggings)
+ {
+ assert(tagging.feed_id != subscription.feed_id);
+ }
+
+ string category = "Taggings Test";
+ api.add_tagging(subscription.feed_id, category);
+
+ // Check taggings
+ int64? tagging_id = null;
+ foreach(var tagging in api.get_taggings())
+ {
+ if(tagging.feed_id == subscription.feed_id)
+ {
+ assert(tagging.name == category);
+ tagging_id = tagging.id;
+ break;
+ }
+ }
+ assert(tagging_id != null);
+
+ // Delete the tag and verify that it's gone
+ api.delete_tagging(tagging_id);
+ foreach(var tagging in api.get_taggings())
+ {
+ assert(tagging.feed_id != subscription.feed_id);
+ }
+
+ // cleanup
+ api.delete_subscription(subscription.id);
+ });
+
+ Test.add_data_func ("/feedbinapi/entries", () => {
+ if(username == null || password == null)
+ {
+ Test.skip(@"Need $user_env and $password_env set to run Feedbin tests");
+ return;
+ }
+
+ var api = new FeedbinAPI(username, password, null, host);
+
+ // Note: This one shouldn't be deleted or recreated, since we want the entries to be available
+ var url = "https://www.brendanlong.com/feeds/all.atom.xml?feed-reader-test-entries";
+
+ var subscription = api.add_subscription(url);
+
+ /* FIXME: Figure out why this next line is failing
+ var entries = api.get_entries(1, false, null, subscription.feed_id);
+ foreach(var entry in entries)
+ {
+ assert(entry.feed_id == subscription.feed_id);
+ }
+
+ assert(entries.size > 0);
+ int i = Random.int_range(0, entries.size);
+ var entry = entries.to_array()[i];
+ var entry_ids = new Gee.ArrayList();
+ entry_ids.add(entry.id);
+
+ // read status
+ api.set_entries_read(entry_ids, true);
+ var unread_entries = api.get_unread_entries();
+ assert(!unread_entries.contains(entry.id));
+
+ api.set_entries_read(entry_ids, false);
+ unread_entries = api.get_unread_entries();
+ assert(unread_entries.contains(entry.id));
+
+ api.set_entries_read(entry_ids, true);
+ unread_entries = api.get_unread_entries();
+ assert(!unread_entries.contains(entry.id));
+
+ // starred status
+ api.set_entries_starred(entry_ids, true);
+ var starred_entries = api.get_starred_entries();
+ assert(starred_entries.contains(entry.id));
+
+ api.set_entries_starred(entry_ids, false);
+ starred_entries = api.get_starred_entries();
+ assert(!starred_entries.contains(entry.id));
+
+ api.set_entries_starred(entry_ids, true);
+ starred_entries = api.get_starred_entries();
+ assert(starred_entries.contains(entry.id));
+ */
+ });
+
+ Test.add_data_func ("/feedbinapi/favicons", () => {
+ if(username == null || password == null)
+ {
+ Test.skip(@"Need $user_env and $password_env set to run Feedbin tests");
+ return;
+ }
+
+ Bytes? expected_favicon;
+ {
+ var session = new Soup.Session();
+ var message = new Soup.Message("GET", "https://www.brendanlong.com/theme/favicon.ico");
+ var inputstream = session.send(message);
+ var bytearray = new ByteArray();
+ uint8[] buffer = new uint8[4096];
+ size_t bytes_read = 0;
+ do
+ {
+ inputstream.read_all(buffer, out bytes_read);
+ bytearray.append(buffer[0:bytes_read]);
+ }
+ while(bytes_read == 4096);
+ expected_favicon = ByteArray.free_to_bytes(bytearray);
+ }
+
+ var api = new FeedbinAPI(username, password, null, host);
+
+ // Note: This one shouldn't be deleted or recreated, since we want the entries to be available
+ var url = "https://www.brendanlong.com/feeds/all.atom.xml?feed-reader-test-favicons";
+
+ var subscription = api.add_subscription(url);
+ var favicons = api.get_favicons();
+ bool found_favicon = false;
+ foreach(var i in favicons.entries)
+ {
+ if(i.key != "www.brendanlong.com")
+ continue;
+ assert(i.value == expected_favicon);
+ found_favicon = true;
+ break;
+ }
+ // FIXME: We don't download icons on the test server because favicon downloading
+ // is handled by a different service
+ //assert(found_favicon);
+ });
+ }
+
+ void main(string[] args)
+ {
+ Test.init(ref args);
- string? host = Environment.get_variable(host_env);
- if(host == null)
- host = "https://api.feedbin.com";
+ string? host = Environment.get_variable(host_env);
+ if(host == null)
+ host = "https://api.feedbin.com";
- // Tests that don't need a login
- Test.add_data_func ("/feedbinapi/construct", () => {
- var api = new FeedbinAPI("user", "password", null, host);
- assert(api != null);
- });
+ // Tests that don't need a login
+ Test.add_data_func ("/feedbinapi/construct", () => {
+ var api = new FeedbinAPI("user", "password", null, host);
+ assert(api != null);
+ });
- Test.add_data_func ("/feedbinapi/bad login", () => {
- var api = new FeedbinAPI("user", "password", null, host);
+ Test.add_data_func ("/feedbinapi/bad login", () => {
+ var api = new FeedbinAPI("user", "password", null, host);
- assert(!api.login());
- });
+ assert(!api.login());
+ });
- add_login_tests(host);
+ add_login_tests(host);
- Test.run ();
+ Test.run ();
+ }
}
diff --git a/plugins/backend/feedbin/feedbinInterface.vala b/plugins/backend/feedbin/feedbinInterface.vala
index e901e1263..63fc606fd 100644
--- a/plugins/backend/feedbin/feedbinInterface.vala
+++ b/plugins/backend/feedbin/feedbinInterface.vala
@@ -22,12 +22,12 @@ public class FeedReader.FeedbinInterface : Peas.ExtensionBase, FeedServerInterfa
private DataBaseReadOnly m_db;
private DataBase m_db_write;
- public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write)
+ public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write, string? api_host = "https://api.feedbin.com")
{
m_db = db;
m_db_write = db_write;
m_utils = new FeedbinUtils(settings_backend, secrets);
- m_api = new FeedbinAPI(m_utils.getUser(), m_utils.getPassword(), Constants.USER_AGENT);
+ m_api = new FeedbinAPI(m_utils.getUser(), m_utils.getPassword(), Constants.USER_AGENT, api_host);
}
public string getWebsite()
diff --git a/plugins/backend/feedhq/feedhqInterface.vala b/plugins/backend/feedhq/feedhqInterface.vala
index 309f0d1c3..9104e111d 100644
--- a/plugins/backend/feedhq/feedhqInterface.vala
+++ b/plugins/backend/feedhq/feedhqInterface.vala
@@ -22,7 +22,7 @@ public class FeedReader.FeedHQInterface : Peas.ExtensionBase, FeedServerInterfac
private DataBaseReadOnly m_db;
private DataBase m_db_write;
- public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write)
+ public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write, string? host = null)
{
m_db = db;
m_db_write = db_write;
diff --git a/plugins/backend/feedly/feedlyInterface.vala b/plugins/backend/feedly/feedlyInterface.vala
index f62499eef..1bbaaadec 100644
--- a/plugins/backend/feedly/feedlyInterface.vala
+++ b/plugins/backend/feedly/feedlyInterface.vala
@@ -20,7 +20,7 @@ public class FeedReader.feedlyInterface : Peas.ExtensionBase, FeedServerInterfac
private DataBaseReadOnly m_db;
private DataBase m_db_write;
- public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write)
+ public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write, string? host = null)
{
m_db = db;
m_db_write = db_write;
diff --git a/plugins/backend/fresh/freshInterface.vala b/plugins/backend/fresh/freshInterface.vala
index 8ce9f234e..80fe2f701 100644
--- a/plugins/backend/fresh/freshInterface.vala
+++ b/plugins/backend/fresh/freshInterface.vala
@@ -27,7 +27,7 @@ public class FeedReader.freshInterface : Peas.ExtensionBase, FeedServerInterface
private DataBaseReadOnly m_db;
private DataBase m_db_write;
- public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write)
+ public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write, string? host = null)
{
m_db = db;
m_db_write = db_write;
diff --git a/plugins/backend/inoreader/InoReaderInterface.vala b/plugins/backend/inoreader/InoReaderInterface.vala
index 93ae495fd..ece1fd621 100644
--- a/plugins/backend/inoreader/InoReaderInterface.vala
+++ b/plugins/backend/inoreader/InoReaderInterface.vala
@@ -20,7 +20,7 @@ public class FeedReader.InoReaderInterface : Peas.ExtensionBase, FeedServerInter
private DataBaseReadOnly m_db;
private DataBase m_db_write;
- public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write)
+ public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write, string? host = null)
{
m_db = db;
m_db_write = db_write;
diff --git a/plugins/backend/local/localInterface.vala b/plugins/backend/local/localInterface.vala
index 1f959e9f0..4e597e1f0 100644
--- a/plugins/backend/local/localInterface.vala
+++ b/plugins/backend/local/localInterface.vala
@@ -21,7 +21,7 @@ public class FeedReader.localInterface : Peas.ExtensionBase, FeedServerInterface
private DataBaseReadOnly m_db;
private DataBase m_db_write;
- public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write)
+ public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write, string? host = null)
{
m_db = db;
m_db_write = db_write;
diff --git a/plugins/backend/oldreader/oldreaderInterface.vala b/plugins/backend/oldreader/oldreaderInterface.vala
index b6eff19a4..7bf1e96a5 100644
--- a/plugins/backend/oldreader/oldreaderInterface.vala
+++ b/plugins/backend/oldreader/oldreaderInterface.vala
@@ -22,7 +22,7 @@ public class FeedReader.OldReaderInterface : Peas.ExtensionBase, FeedServerInter
private DataBaseReadOnly m_db;
private DataBase m_db_write;
- public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write)
+ public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write, string? host = null)
{
m_db = db;
m_db_write = db_write;
diff --git a/plugins/backend/owncloud/OwncloudNewsInterface.vala b/plugins/backend/owncloud/OwncloudNewsInterface.vala
index efeea0337..114577401 100644
--- a/plugins/backend/owncloud/OwncloudNewsInterface.vala
+++ b/plugins/backend/owncloud/OwncloudNewsInterface.vala
@@ -27,7 +27,7 @@ public class FeedReader.OwncloudNewsInterface : Peas.ExtensionBase, FeedServerIn
private DataBaseReadOnly m_db;
private DataBase m_db_write;
- public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write)
+ public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write, string? host = null)
{
m_db = db;
m_db_write = db_write;
diff --git a/plugins/backend/test/CMakeLists.txt b/plugins/backend/test/CMakeLists.txt
new file mode 100644
index 000000000..b65bc42ad
--- /dev/null
+++ b/plugins/backend/test/CMakeLists.txt
@@ -0,0 +1,34 @@
+set (NAME TestPlugin)
+set (TARGET ${NAME}_target)
+
+vala_precompile(VALA_C ${TARGET}
+ TestPlugin.vala
+
+PACKAGES
+ libpeas-1.0
+ gtk+-3.0
+ json-glib-1.0
+ libsoup-2.4
+ gee-0.8
+ libxml-2.0
+ sqlite3
+ libsecret-1
+
+GENERATE_VAPI ${NAME}
+
+OPTIONS
+ --target-glib=2.32
+ --library ${NAME}
+
+CUSTOM_VAPIS
+ ${CMAKE_BINARY_DIR}/FeedReader.vapi
+ ${CMAKE_SOURCE_DIR}/vapi/gd-1.0.vapi
+ ${CMAKE_SOURCE_DIR}/vapi/webkit2gtk-4.0.vapi
+)
+
+add_library(${NAME} STATIC ${VALA_C})
+set_property(TARGET ${NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
+
+# ----------------------------------------------------------
+
+add_dependencies(${NAME} ${FEEDREADER_NAME})
diff --git a/plugins/backend/test/TestPlugin.vala b/plugins/backend/test/TestPlugin.vala
new file mode 100644
index 000000000..9b6804b2a
--- /dev/null
+++ b/plugins/backend/test/TestPlugin.vala
@@ -0,0 +1,27 @@
+// This file is part of FeedReader.
+//
+// FeedReader is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// FeedReader is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with FeedReader. If not, see .
+
+namespace FeedReader.Tests {
+ public void add_plugin_tests(FeedServerInterface plugin, string host, string username, string password) throws Error
+ {
+ var settings_backend = GLib.SettingsBackend.memory_settings_backend_new();
+ var secret_service = Secret.Service.get_sync(Secret.ServiceFlags.NONE);
+ var secrets = Secret.Collection.create_sync(secret_service, "feedreader_tests", null, Secret.CollectionCreateFlags.COLLECTION_CREATE_NONE);
+
+ DataBase db_write = new DataBase.in_memory();
+ DataBaseReadOnly db = new DataBaseReadOnly.in_memory();
+ plugin.init(settings_backend, secrets, db, db_write);
+ }
+}
diff --git a/plugins/backend/ttrss/ttrssInterface.vala b/plugins/backend/ttrss/ttrssInterface.vala
index b5313a160..c74a29d12 100644
--- a/plugins/backend/ttrss/ttrssInterface.vala
+++ b/plugins/backend/ttrss/ttrssInterface.vala
@@ -27,7 +27,7 @@ public class FeedReader.ttrssInterface : Peas.ExtensionBase, FeedServerInterface
private DataBaseReadOnly m_db;
private DataBase m_db_write;
- public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write)
+ public void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write, string? host = null)
{
m_db = db;
m_db_write = db_write;
diff --git a/src/Backend/FeedServerInterface.vala b/src/Backend/FeedServerInterface.vala
index 5962b2098..81bcadb56 100644
--- a/src/Backend/FeedServerInterface.vala
+++ b/src/Backend/FeedServerInterface.vala
@@ -21,7 +21,7 @@ public interface FeedReader.FeedServerInterface : GLib.Object {
public signal void showArticleListOverlay();
public signal void writeArticles(Gee.List articles);
- public abstract void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write);
+ public abstract void init(GLib.SettingsBackend settings_backend, Secret.Collection secrets, DataBaseReadOnly db, DataBase db_write, string? host = null);
public abstract bool supportTags();
diff --git a/src/DataBaseReadOnly.vala b/src/DataBaseReadOnly.vala
index 00a0030dd..d3c52d60a 100644
--- a/src/DataBaseReadOnly.vala
+++ b/src/DataBaseReadOnly.vala
@@ -26,6 +26,11 @@ public class FeedReader.DataBaseReadOnly : GLib.Object {
m_db = new SQLite(db_path);
}
+ public DataBaseReadOnly.in_memory()
+ {
+ m_db = new SQLite("file::memory:?cache=shared");
+ }
+
private void errorLogCallback(int code, string msg)
{
Logger.error(@"dbErrorLog: $code: $msg");
diff --git a/src/DataBaseWriteAccess.vala b/src/DataBaseWriteAccess.vala
index ac2b69aae..26947e4f2 100644
--- a/src/DataBaseWriteAccess.vala
+++ b/src/DataBaseWriteAccess.vala
@@ -39,6 +39,11 @@ public class FeedReader.DataBase : DataBaseReadOnly {
base(dbFile);
}
+ public DataBase.in_memory()
+ {
+ base.in_memory();
+ }
+
public void checkpoint()
{
m_db.checkpoint();
diff --git a/src/SQLite.vala b/src/SQLite.vala
index fbb05a7e5..9ddcd21c9 100644
--- a/src/SQLite.vala
+++ b/src/SQLite.vala
@@ -24,20 +24,23 @@ public class FeedReader.SQLite : GLib.Object {
public SQLite(string db_path, int busy_timeout = 1000)
{
- var path = GLib.File.new_for_path(db_path);
- var parent = path.get_parent();
- if(!parent.query_exists())
+ if(!db_path.contains(":memory:"))
{
- try
+ var path = GLib.File.new_for_path(db_path);
+ var parent = path.get_parent();
+ if(!parent.query_exists())
{
- parent.make_directory_with_parents();
- }
- catch(IOError.EXISTS e)
- {
- }
- catch(GLib.Error e)
- {
- Logger.error("SQLite: " + e.message);
+ try
+ {
+ parent.make_directory_with_parents();
+ }
+ catch(IOError.EXISTS e)
+ {
+ }
+ catch(GLib.Error e)
+ {
+ Logger.error("SQLite: " + e.message);
+ }
}
}