From 674a5b7f89512a43a38ac3133399894513acad5c Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 29 Aug 2015 11:18:50 -0700 Subject: [PATCH] Update unit tests to new MultiVehicleManager signaling --- src/FactSystem/FactSystemTestBase.cc | 15 ++++----------- src/VehicleSetup/SetupViewTest.cc | 13 ++++--------- src/qgcunittest/PX4RCCalibrationTest.cc | 13 ++++++------- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/FactSystem/FactSystemTestBase.cc b/src/FactSystem/FactSystemTestBase.cc index a6e2d6262..01168f0a9 100644 --- a/src/FactSystem/FactSystemTestBase.cc +++ b/src/FactSystem/FactSystemTestBase.cc @@ -51,20 +51,13 @@ void FactSystemTestBase::_init(MAV_AUTOPILOT autopilot) LinkManager::instance()->connectLink(link); // Wait for the Vehicle to get created - QSignalSpy spyUas(MultiVehicleManager::instance(), SIGNAL(activeVehicleAvailableChanged(bool))); - QCOMPARE(spyUas.wait(5000), true); - QVERIFY(MultiVehicleManager::instance()->activeVehicleAvailable()); + QSignalSpy spyVehicle(MultiVehicleManager::instance(), SIGNAL(parameterReadyVehicleAvailableChanged(bool))); + QCOMPARE(spyVehicle.wait(5000), true); + QVERIFY(MultiVehicleManager::instance()->parameterReadyVehicleAvailable()); + QVERIFY(MultiVehicleManager::instance()->activeVehicle()); _plugin = MultiVehicleManager::instance()->activeVehicle()->autopilotPlugin(); Q_ASSERT(_plugin); - - // Wait for the plugin to be ready - - QSignalSpy spyPlugin(_plugin, SIGNAL(pluginReadyChanged(bool))); - if (!_plugin->pluginReady()) { - QCOMPARE(spyPlugin.wait(60000), true); - } - Q_ASSERT(_plugin->pluginReady()); } void FactSystemTestBase::_cleanup(void) diff --git a/src/VehicleSetup/SetupViewTest.cc b/src/VehicleSetup/SetupViewTest.cc index 9c264889e..c7f05e60f 100644 --- a/src/VehicleSetup/SetupViewTest.cc +++ b/src/VehicleSetup/SetupViewTest.cc @@ -71,19 +71,14 @@ void SetupViewTest::_clickThrough_test(void) linkMgr->connectLink(link); // Wait for the Vehicle to get created - QSignalSpy spyUas(MultiVehicleManager::instance(), SIGNAL(activeVehicleAvailableChanged(bool))); - QCOMPARE(spyUas.wait(5000), true); - QVERIFY(MultiVehicleManager::instance()->activeVehicleAvailable()); + QSignalSpy spyVehicle(MultiVehicleManager::instance(), SIGNAL(parameterReadyVehicleAvailableChanged(bool))); + QCOMPARE(spyVehicle.wait(5000), true); + QVERIFY(MultiVehicleManager::instance()->parameterReadyVehicleAvailable()); + QVERIFY(MultiVehicleManager::instance()->activeVehicle()); AutoPilotPlugin* autopilot = MultiVehicleManager::instance()->activeVehicle()->autopilotPlugin(); Q_ASSERT(autopilot); - QSignalSpy spyPlugin(autopilot, SIGNAL(pluginReadyChanged(bool))); - if (!autopilot->pluginReady()) { - QCOMPARE(spyPlugin.wait(60000), true); - } - Q_ASSERT(autopilot->pluginReady()); - // Switch to the Setup view _mainToolBar->onSetupView(); QTest::qWait(1000); diff --git a/src/qgcunittest/PX4RCCalibrationTest.cc b/src/qgcunittest/PX4RCCalibrationTest.cc index 9357a9594..e5f516029 100644 --- a/src/qgcunittest/PX4RCCalibrationTest.cc +++ b/src/qgcunittest/PX4RCCalibrationTest.cc @@ -153,17 +153,16 @@ void RadioConfigTest::init(void) Q_CHECK_PTR(_mockLink); LinkManager::instance()->_addLink(_mockLink); LinkManager::instance()->connectLink(_mockLink); - QTest::qWait(5000); // Give enough time for UI to settle and heartbeats to go through + + // Wait for the Vehicle to get created + QSignalSpy spyVehicle(MultiVehicleManager::instance(), SIGNAL(parameterReadyVehicleAvailableChanged(bool))); + QCOMPARE(spyVehicle.wait(5000), true); + QVERIFY(MultiVehicleManager::instance()->parameterReadyVehicleAvailable()); + QVERIFY(MultiVehicleManager::instance()->activeVehicle()); _autopilot = MultiVehicleManager::instance()->activeVehicle()->autopilotPlugin(); Q_ASSERT(_autopilot); - QSignalSpy spyPlugin(_autopilot, SIGNAL(pluginReadyChanged(bool))); - if (!_autopilot->pluginReady()) { - QCOMPARE(spyPlugin.wait(60000), true); - } - Q_ASSERT(_autopilot->pluginReady()); - // This will instatiate the widget with an active uas with ready parameters _calWidget = new QGCQmlWidgetHolder(); _calWidget->resize(600, 600); -- 2.22.0