-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for MouseDrag GUI plugin #2085
Draft
Henrique-BO
wants to merge
43
commits into
gazebosim:gz-sim7
Choose a base branch
from
Henrique-BO:plugin_tests
base: gz-sim7
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 41 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
142d5a1
Create MouseDrag GUI plugin
Henrique-BO 9449842
Track mouse position and the clicked link
Henrique-BO 508a0ef
Implement calculation of plane of wrench application and translation …
Henrique-BO 28919d6
Implement translation drag by arbitrary point in object
Henrique-BO 603e949
Implement rotation dragging
Henrique-BO eeade69
Merge branch 'gazebosim:gz-sim7' into mouse_drag
Henrique-BO 1383635
Improve rotation calculation and implement velocity damping
Henrique-BO 0f68570
Use PID for wrench calculation and implement visualization
Henrique-BO f1179e8
Merge branch 'gazebosim:gz-sim7' into mouse_drag
Henrique-BO 009cdb2
Merge branch 'mouse_drag' of github.com:Henrique-BO/gz-sim into mouse…
Henrique-BO a4dcdff
Merge branch 'gazebosim:gz-sim7' into mouse_drag
Henrique-BO 2b36d85
Improve visualization for rotation
Henrique-BO 8086225
Merge branch 'gazebosim:gz-sim7' into mouse_drag
Henrique-BO 54a64c0
Fix rotation mode
Henrique-BO 316f054
Make arrows always visible and minor changes
Henrique-BO e7f2ef2
Automatically load ApplyLinkWrench system and improve calculations
Henrique-BO c31bec6
Merge branch 'gazebosim:gz-sim7' into mouse_drag
Henrique-BO a639f5c
Merge branch 'gazebosim:gz-sim7' into mouse_drag
Henrique-BO 91b1f1a
Configurable stiffnesses in MouseDrag
Henrique-BO 60f788f
Minor fixes
Henrique-BO 965a9e0
Change wrench calculation
Henrique-BO 5d53a17
Merge branch 'mouse_drag' into mouse_drag_config
Henrique-BO 7c81964
Visualizing plane and optimize calculations
Henrique-BO 49de688
Merge branch 'gazebosim:gz-sim7' into mouse_drag
Henrique-BO 896bed1
Merge branch 'gazebosim:gz-sim7' into mouse_drag_config
Henrique-BO 21fcc93
Merge branch 'gazebosim:gz-sim7' into mouse_drag_config
Henrique-BO 9bc7356
Merge branch 'gazebosim:gz-sim7' into mouse_drag
Henrique-BO 06d5a3c
Merge branch 'gazebosim:gz-sim7' into mouse_drag_config
Henrique-BO e6af6c7
Merge branch 'gazebosim:gz-sim7' into mouse_drag
Henrique-BO f6920d3
Add mutex
Henrique-BO d37c517
Merge branch 'mouse_drag' into mouse_drag_config
Henrique-BO ba95572
Started MouseDrag unit and integration tests
Henrique-BO ee833a2
Use events to test translation mode in MouseDrag
Henrique-BO 3fbb38f
Merge branch 'gazebosim:gz-sim7' into mouse_drag
Henrique-BO 78f86a5
Refactoring and minor changes
Henrique-BO b2f1c51
Merge branch 'mouse_drag' into mouse_drag_config
Henrique-BO 9f7bf50
Merge branch 'mouse_drag_config' into plugin_tests
Henrique-BO 61b1c82
Merge branch 'gz-sim7' into mouse_drag_config
Henrique-BO 8c77ba8
Merge branch 'mouse_drag_config' into plugin_tests
Henrique-BO 5caea15
Merge branch 'gz-sim7' into plugin_tests
Henrique-BO 335e1f2
Merge branch 'gazebosim:gz-sim7' into plugin_tests
Henrique-BO eb1e792
Merge branch 'gazebosim:gz-sim7' into plugin_tests
Henrique-BO 85f4d15
Refactor GuiRelay
Henrique-BO File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
gz_add_gui_plugin(MouseDrag | ||
SOURCES MouseDrag.cc | ||
QT_HEADERS MouseDrag.hh | ||
TEST_SOURCES MouseDrag_TEST.cc | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright (C) 2023 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
#ifdef _MSC_VER | ||
#pragma warning(push, 0) | ||
#endif | ||
#include <gz/msgs/double.pb.h> | ||
#ifdef _MSC_VER | ||
#pragma warning(pop) | ||
#endif | ||
#include <gz/gui/Application.hh> | ||
#include <gz/gui/MainWindow.hh> | ||
#include <gz/gui/Plugin.hh> | ||
#include <gz/transport/Node.hh> | ||
#include <gz/utils/ExtraTestMacros.hh> | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
#include "test_config.hh" | ||
#include "../../../../test/helpers/EnvTestFixture.hh" | ||
|
||
#include "../../GuiRunner.hh" | ||
|
||
#include "MouseDrag.hh" | ||
|
||
int g_argc = 1; | ||
char **g_argv; | ||
|
||
using namespace gz; | ||
|
||
/// \brief Tests for the mouse drag GU I plugin | ||
class MouseDragGui : public InternalFixture<::testing::Test> | ||
{ | ||
}; | ||
|
||
///////////////////////////////////////////////// | ||
TEST_F(MouseDragGui, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Load)) | ||
{ | ||
// Create app | ||
auto app = std::make_unique<gui::Application>(g_argc, g_argv); | ||
ASSERT_NE(nullptr, app); | ||
app->AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); | ||
|
||
// Create GUI runner to handle sim::gui plugins | ||
auto runner = new sim::GuiRunner("default"); | ||
runner->setParent(gui::App()); | ||
|
||
// Add plugin | ||
EXPECT_TRUE(app->LoadPlugin("MouseDrag")); | ||
|
||
// Get main window | ||
auto win = app->findChild<gui::MainWindow *>(); | ||
ASSERT_NE(nullptr, win); | ||
|
||
// Get plugin | ||
auto plugins = win->findChildren< | ||
sim::MouseDrag *>(); | ||
EXPECT_EQ(plugins.size(), 1); | ||
|
||
auto plugin = plugins[0]; | ||
|
||
EXPECT_EQ(plugin->Title(), "Mouse drag"); | ||
|
||
transport::Node node; | ||
auto topic = transport::TopicUtils::AsValidTopic("/world/default/wrench"); | ||
EXPECT_FALSE(topic.empty()); | ||
|
||
std::vector<std::string> topics; | ||
node.TopicList(topics); | ||
EXPECT_NE(std::find(topics.begin(), topics.end(), topic), topics.end()); | ||
|
||
// Cleanup | ||
plugins.clear(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (C) 2021 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#ifndef GZ_GUI_TESTHELPER_HH_ | ||
#define GZ_GUI_TESTHELPER_HH_ | ||
|
||
#include <gz/gui/Application.hh> | ||
#include <gz/gui/Export.hh> | ||
#include <gz/gui/MainWindow.hh> | ||
|
||
#ifndef _WIN32 | ||
# define TestHelper_EXPORTS_API | ||
#else | ||
# if (defined(TestHelper_EXPORTS)) | ||
# define TestHelper_EXPORTS_API __declspec(dllexport) | ||
# else | ||
# define TestHelper_EXPORTS_API __declspec(dllimport) | ||
# endif | ||
#endif | ||
|
||
namespace gz | ||
{ | ||
namespace sim | ||
{ | ||
/// \brief | ||
class TestHelper_EXPORTS_API TestHelper : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
/// \brief Constructor | ||
public: inline TestHelper() | ||
{ | ||
gz::gui::App()->findChild<gz::gui::MainWindow *>()-> | ||
installEventFilter(this); | ||
} | ||
|
||
/// \brief Destructor | ||
public: ~TestHelper() = default; | ||
|
||
/// \brief Documentation inherited | ||
public: inline bool eventFilter(QObject *_obj, QEvent *_event) override | ||
{ | ||
if (this->forwardEvent) | ||
this->forwardEvent(_event); | ||
|
||
// Standard event processing | ||
return QObject::eventFilter(_obj, _event); | ||
} | ||
|
||
public: std::function<void (QEvent *)> forwardEvent; | ||
}; | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gz::common::joinPath