diff options
author | Jens Georg <mail@jensge.org> | 2020-04-19 19:33:56 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2020-07-05 15:31:52 +0200 |
commit | 1c06777690fdf5eba3e9494dc8d450e29d0de539 (patch) | |
tree | 8cd601b7ad75b9f01c1af452b6cff82faca805bc /tests | |
parent | c83fff7eceb6ab54d00ed9aec27de63abe7ca486 (diff) | |
download | rygel-1c06777690fdf5eba3e9494dc8d450e29d0de539.tar.gz |
test: Use a custom test class for plugin loaders
Instead of abusing UserConfig. That way we can also toggle the
enable/disale flag
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/plugin-loader/conflicts/test.conf | 11 | ||||
-rw-r--r-- | tests/plugin-loader/rygel-plugin-loader-test.vala | 31 |
2 files changed, 22 insertions, 20 deletions
diff --git a/tests/data/plugin-loader/conflicts/test.conf b/tests/data/plugin-loader/conflicts/test.conf deleted file mode 100644 index 85c6c8a4..00000000 --- a/tests/data/plugin-loader/conflicts/test.conf +++ /dev/null @@ -1,11 +0,0 @@ -[general] -log-level = *:5 - -[Tracker3] -enabled = true - -[SomePlugin] -enabled = true - -[Tracker] -enabled = true diff --git a/tests/plugin-loader/rygel-plugin-loader-test.vala b/tests/plugin-loader/rygel-plugin-loader-test.vala index 3f8db60d..816ac490 100644 --- a/tests/plugin-loader/rygel-plugin-loader-test.vala +++ b/tests/plugin-loader/rygel-plugin-loader-test.vala @@ -1,3 +1,20 @@ +class TestConfig : Rygel.BaseConfiguration { + public HashTable<string, bool> enable = new HashTable<string, bool> (str_hash, str_equal); + + public void toggl_enable (string module) { + enable[module] = !enable[module]; + this.section_changed (module, Rygel.SectionEntry.ENABLED); + } + + public override bool get_enabled(string module) throws Error { + if (module in this.enable) { + return this.enable[module]; + } + + throw new Rygel.ConfigurationError.NO_VALUE_SET ("Should not happen"); + } +} + class TestPluginLoader : Rygel.PluginLoader { private string[] expected_plugins; private string[] forbidden_plugins; @@ -24,15 +41,11 @@ class TestPluginLoader : Rygel.PluginLoader { } void test_plugin_loader_conflict () { - try { - var config = new Rygel.UserConfig.with_paths ( - "data/plugin-loader/conflicts/test.conf", - "data/plugin-loader/conflicts/test.conf"); - Rygel.MetaConfig.register_configuration (config); - } catch (Error error) { - critical("%s", error.message); - assert_not_reached (); - } + var config = new TestConfig (); + config.enable["Tracker"] = true; + config.enable["Tracker3"] = true; + config.enable["SomePlugin"] = true; + Rygel.MetaConfig.register_configuration (config); var loader = new TestPluginLoader("conflicts", {"librygel-tracker.so", "librygel-no-conflict.so"}, |