QTestFixture.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef _QTESTFIXTURE_HH_
19 #define _QTESTFIXTURE_HH_
20 
21 #include <string>
22 
23 #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829
24 # include <boost/thread.hpp>
25 # include "gazebo/Server.hh"
26 # include "gazebo/physics/physics.hh"
27 # include "gazebo/rendering/rendering.hh"
28 #endif
29 
30 #include "gazebo/gui/qt.h"
31 #include "gazebo/gui/qt_test.h"
32 
33 #include "gazebo/gazebo_config.h"
34 #include "test_config.h"
35 
37 class QTestFixture : public QObject
38 {
39  Q_OBJECT
40 
41  public: QTestFixture();
42 
48  protected: void Load(const std::string &_worldFilename, bool _paused = false,
49  bool _serverScene = true, bool _clientScene = false);
50 
53  protected: void SetPause(bool _pause);
54 
60  protected: void ProcessEventsAndDraw(QMainWindow *_mainWindow = NULL,
61  const unsigned int _repeat = 10, const unsigned int _ms = 30);
62 
66  protected: void GetMemInfo(double &_resident, double &_share);
67 
70  private slots: void initTestCase();
71 
73  private slots: void init();
74 
76  private slots: void cleanup();
77 
79  private slots: void cleanupTestCase();
80 
85  private: void RunServer(const std::string &_worldFilename, bool _paused,
86  bool _createScene);
87 
89  protected: gazebo::Server *server;
90 
92  protected: boost::thread *serverThread;
93 
95  protected: double resMaxPercentChange;
96 
98  protected: double shareMaxPercentChange;
99 
101  private: double residentStart;
102 
104  private: double shareStart;
105 };
106 #endif
void Load(const std::string &_worldFilename, bool _paused=false, bool _serverScene=true, bool _clientScene=false)
Load a world.
void SetPause(bool _pause)
Pause or unpause the world.
Base class for all Gazebo GUI unit tests.
Definition: QTestFixture.hh:37
double shareMaxPercentChange
Maximum allowed percent change in shared memory usage.
Definition: QTestFixture.hh:98
void GetMemInfo(double &_resident, double &_share)
Get memory information about the current process.
void ProcessEventsAndDraw(QMainWindow *_mainWindow=NULL, const unsigned int _repeat=10, const unsigned int _ms=30)
Give the GUI time to process events and trigger main window repaint.
#define NULL
Definition: CommonTypes.hh:31
Definition: Server.hh:41
gazebo::Server * server
The Gazebo server, which is run in a thread.
Definition: QTestFixture.hh:89
boost::thread * serverThread
Thread to run the Gazebo server.
Definition: QTestFixture.hh:92
double resMaxPercentChange
Maximum allowed percent change in resident memory usage.
Definition: QTestFixture.hh:95