[grilo-plugins] Revert "tests: port lua-factory fake sources to new API"
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] Revert "tests: port lua-factory fake sources to new API"
- Date: Mon, 21 Mar 2016 22:56:51 +0000 (UTC)
commit 2fd5ceeca739fa4aa00bc8a80b23b72e00ccdf67
Author: Victor Toso <me victortoso com>
Date: Tue Mar 8 23:27:55 2016 +0100
Revert "tests: port lua-factory fake sources to new API"
This reverts commit d322e89e6e78ac7810b7eaf314421659b77d5ca7.
But keeps grl.fetch callback as function instead of string
https://bugzilla.gnome.org/show_bug.cgi?id=763046
tests/lua-factory/data/test-source-grl-media.lua | 18 +++++++++---------
tests/lua-factory/data/test-source-xml-parser.lua | 21 +++++++++++----------
2 files changed, 20 insertions(+), 19 deletions(-)
---
diff --git a/tests/lua-factory/data/test-source-grl-media.lua
b/tests/lua-factory/data/test-source-grl-media.lua
index f0272af..644387a 100644
--- a/tests/lua-factory/data/test-source-grl-media.lua
+++ b/tests/lua-factory/data/test-source-grl-media.lua
@@ -41,30 +41,30 @@ source = {
-- Handlers of Grilo functions --
---------------------------------
-function grl_source_resolve(media, options, callback)
+function grl_source_resolve()
-- This source expects an url which will be fetched and converted
-- to a GrlMedia with grl.lua.json.string_to_table().
- if not media or not media.url or #media.url == 0 then
+ local req = grl.get_media_keys()
+ if not req or not req.url or #req.url == 0 then
grl.warning("resolve was called without metadata-key url")
- callback()
+ grl.callback()
return
end
- local userdata = {callback = callback, media = media}
- grl.fetch(media.url, fetch_url_cb, userdata)
+ grl.fetch(req.url, fetch_url_cb)
end
-function fetch_url_cb(feed, userdata)
+function fetch_url_cb(feed)
if not feed or #feed == 0 then
grl.warning("failed to load json")
- userdata.callback()
+ grl.callback()
return
end
local media = grl.lua.json.string_to_table(feed)
if not media then
grl.warning ("fail to make media from json")
- userdata.callback()
+ grl.callback()
return
end
- userdata.callback(media, 0)
+ grl.callback(media, 0)
end
diff --git a/tests/lua-factory/data/test-source-xml-parser.lua
b/tests/lua-factory/data/test-source-xml-parser.lua
index e78c347..a6af731 100644
--- a/tests/lua-factory/data/test-source-xml-parser.lua
+++ b/tests/lua-factory/data/test-source-xml-parser.lua
@@ -41,24 +41,25 @@ source = {
-- Handlers of Grilo functions --
---------------------------------
-function grl_source_resolve(media, options, callback)
+function grl_source_resolve()
-- This source expects an url which will be fetched and converted
-- to a table using grl.lua.xml.string_to_table().
- if not media or not media.url or #media.url ~= 2 then
+ local req = grl.get_media_keys()
+ if not req or not req.url or #req.url ~= 2 then
grl.warning("resolve was called without metadata-key url")
- callback()
+ grl.callback()
return
end
- local userdata = {callback = callback, media = media}
- grl.fetch(media.url, fetch_url_cb, userdata)
+
+ grl.fetch(req.url, fetch_url_cb)
end
-- feeds[1] is the xml to test
-- feeds[2] is a lua table with this xml, to compare
-function fetch_url_cb(feeds, userdata)
+function fetch_url_cb(feeds)
if not feeds or #feeds ~= 2 then
grl.warning("failed to load xml")
- userdata.callback()
+ grl.callback()
return
end
@@ -66,7 +67,7 @@ function fetch_url_cb(feeds, userdata)
local ref = load(feeds[2])()
if not xml or not ref then
grl.warning ("xml parser failed")
- userdata.callback()
+ grl.callback()
return
end
@@ -75,12 +76,12 @@ function fetch_url_cb(feeds, userdata)
grl.warning("xml parser failed, results are not the same\n" ..
"reference table of test:\n" .. grl.lua.inspect(ref) .. "\n" ..
"table from xml parser:\n" .. grl.lua.inspect(xml))
- userdata.callback()
+ grl.callback()
return
end
local media = { id = "success" }
- userdata.callback(media, 0)
+ grl.callback(media, 0)
end
function test_table_contains(t, e)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]