Skip to content

Commit

Permalink
Support <gz-gui> tag in plugin config (#607)
Browse files Browse the repository at this point in the history
This allows users to specify `<gz-gui>` instead of `<ignition-gui>` in their GUI plugins so that SDF files can work on Fortress and Garden/Harmonic without modification.

Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey authored Feb 2, 2024
1 parent 5674c03 commit ab5af59
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,12 @@ void Plugin::Load(const tinyxml2::XMLElement *_pluginElem)
}

// Load common configuration
this->LoadCommonConfig(_pluginElem->FirstChildElement("ignition-gui"));
auto guiElem = _pluginElem->FirstChildElement("ignition-gui");
if (!guiElem)
{
guiElem = _pluginElem->FirstChildElement("gz-gui");
}
this->LoadCommonConfig(guiElem);

// Load custom configuration
this->LoadConfig(_pluginElem);
Expand Down
30 changes: 30 additions & 0 deletions src/Plugin_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,33 @@ TEST(PluginTest, IGN_UTILS_TEST_DISABLED_ON_WIN32(ConfigStrInputNoPlugin))
}
}

/////////////////////////////////////////////////
TEST(PluginTest, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(GzSimCompatibility))
{
common::Console::SetVerbosity(4);

Application app(g_argc, g_argv);
app.AddPluginPath(
common::joinPaths(std::string(PROJECT_BINARY_PATH), "lib"));

// Load plugin config that returns null GetText
const char *pluginStr = R"(
<plugin filename="TestPlugin">
<gz-gui>
<title>GzSimCompatibility</title>
</gz-gui>
</plugin>)";

tinyxml2::XMLDocument pluginDoc;
pluginDoc.Parse(pluginStr);
EXPECT_TRUE(app.LoadPlugin("TestPlugin",
pluginDoc.FirstChildElement("plugin")));

auto win = app.findChild<MainWindow *>();
ASSERT_NE(nullptr, win);

// Check plugin was loaded and `gz-gui` was processed.
auto plugins = win->findChildren<Plugin *>();
ASSERT_EQ(1, plugins.size());
EXPECT_EQ(plugins[0]->Title(), "GzSimCompatibility");
}

0 comments on commit ab5af59

Please sign in to comment.