aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortamland <thomas.amland@gmail.com>2016-07-17 14:41:04 +0200
committerGitHub <noreply@github.com>2016-07-17 14:41:04 +0200
commitd1700a79888ac8ffaed6fd2fc8d914f7973067f6 (patch)
treec236bc4afffae5bdc05e34157cc706e9e8dd6b73
parent2ab7fb1ca2eb72611842c48276b15e4ed0bd225b (diff)
parent96953b1959b9a0e1bd79e61eefbf5ece75b4024a (diff)
Merge pull request #10128 from tamland/fix_addon_tests
[addons] fix bad refactoring in fb51bbd26e0
-rw-r--r--xbmc/addons/AddonManager.cpp29
-rw-r--r--xbmc/addons/test/TestAddonFactory.cpp35
2 files changed, 51 insertions, 13 deletions
diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp
index 67d845f20f..4bad98d466 100644
--- a/xbmc/addons/AddonManager.cpp
+++ b/xbmc/addons/AddonManager.cpp
@@ -142,6 +142,9 @@ void CAddonMgr::FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder
if (plugin->provider_name)
builder.SetAuthor(plugin->provider_name);
+ if (plugin->plugin_path && strcmp(plugin->plugin_path, "") != 0)
+ builder.SetPath(plugin->plugin_path);
+
{
ADDONDEPS dependencies;
for (unsigned int i = 0; i < plugin->num_imports; ++i)
@@ -159,6 +162,18 @@ void CAddonMgr::FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder
auto metadata = CAddonMgr::GetInstance().GetExtension(plugin, "xbmc.addon.metadata");
if (!metadata)
metadata = CAddonMgr::GetInstance().GetExtension(plugin, "kodi.addon.metadata");
+
+ if (plugin->plugin_path && strcmp(plugin->plugin_path, "") != 0)
+ {
+ //backwards compatibility
+ std::string icon = metadata && CAddonMgr::GetInstance().GetExtValue(metadata->configuration, "noicon") == "true" ? "" : "icon.png";
+ std::string fanart = metadata && CAddonMgr::GetInstance().GetExtValue(metadata->configuration, "nofanart") == "true" ? "" : "fanart.jpg";
+ if (!icon.empty())
+ builder.SetIcon(URIUtils::AddFileToFolder(plugin->plugin_path, icon));
+ if (!fanart.empty())
+ builder.SetFanart(URIUtils::AddFileToFolder(plugin->plugin_path, fanart));
+ }
+
if (metadata)
{
builder.SetSummary(CAddonMgr::GetInstance().GetTranslatedString(metadata->configuration, "summary"));
@@ -180,11 +195,11 @@ void CAddonMgr::FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder
if (plugin->plugin_path && strcmp(plugin->plugin_path, "") != 0)
{
- builder.SetPath(plugin->plugin_path);
-
auto assets = CAddonMgr::GetInstance().GetExtElement(metadata->configuration, "assets");
if (assets)
{
+ builder.SetIcon("");
+ builder.SetFanart("");
std::string icon = CAddonMgr::GetInstance().GetExtValue(assets, "icon");
std::string fanart = CAddonMgr::GetInstance().GetExtValue(assets, "fanart");
@@ -205,16 +220,6 @@ void CAddonMgr::FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder
}
builder.SetScreenshots(std::move(screenshots));
}
- else
- {
- //backwards compatibility
- std::string icon = CAddonMgr::GetInstance().GetExtValue(metadata->configuration, "noicon") == "true" ? "" : "icon.png";
- std::string fanart = CAddonMgr::GetInstance().GetExtValue(metadata->configuration, "nofanart") == "true" ? "" : "fanart.jpg";
- if (!icon.empty())
- builder.SetIcon(URIUtils::AddFileToFolder(plugin->plugin_path, icon));
- if (!fanart.empty())
- builder.SetFanart(URIUtils::AddFileToFolder(plugin->plugin_path, fanart));
- }
}
}
}
diff --git a/xbmc/addons/test/TestAddonFactory.cpp b/xbmc/addons/test/TestAddonFactory.cpp
index a97d1bff33..c58539522c 100644
--- a/xbmc/addons/test/TestAddonFactory.cpp
+++ b/xbmc/addons/test/TestAddonFactory.cpp
@@ -116,9 +116,42 @@ TEST_F(TestAddonFactory, ShouldAcceptUnversionedDependencies)
TEST_F(TestAddonFactory, IconPathShouldBeBuiltFromPluginPath)
{
- plugin.plugin_path = strdup("a/b");;
+ plugin.plugin_path = strdup("a/b");
auto addon = CAddonMgr::Factory(&plugin, ADDON_UNKNOWN);
EXPECT_EQ("a/b", addon->Path());
EXPECT_EQ("a/b/icon.png", addon->Icon());
free(plugin.plugin_path);
}
+
+
+TEST_F(TestAddonFactory, AssetsElementShouldOverrideImplicitArt)
+{
+ cp_cfg_element_t icon{0};
+ icon.name = (char*)"icon";
+ icon.value = (char*)"foo/bar.jpg";
+
+ cp_cfg_element_t assets{0};
+ assets.name = (char*)"assets";
+ assets.num_children = 1;
+ assets.children = &icon;
+
+ cp_cfg_element_t root{0};
+ root.name = (char*)"kodi.addon.metadata";
+ root.num_children = 1;
+ root.children = &assets;
+ assets.parent = &root;
+ icon.parent = &assets;
+
+ cp_extension_t metadata = {&plugin, (char*)"kodi.addon.metadata", nullptr, nullptr, nullptr, &root};
+
+ cp_extension_t extensions[1] = {metadata};
+ plugin.extensions = extensions;
+ plugin.num_extensions = 1;
+ plugin.plugin_path = strdup("a/b");
+
+ auto addon = CAddonMgr::Factory(&plugin, ADDON_UNKNOWN);
+ EXPECT_EQ("a/b", addon->Path());
+ EXPECT_EQ("a/b/foo/bar.jpg", addon->Icon());
+ EXPECT_EQ("", addon->FanArt());
+ free(plugin.plugin_path);
+}