Skip to content

Commit

Permalink
#2174 Added tests for bike power functions
Browse files Browse the repository at this point in the history
  • Loading branch information
drmason789 committed Mar 1, 2024
1 parent 9f9ab5c commit 678facc
Show file tree
Hide file tree
Showing 48 changed files with 634 additions and 45 deletions.
7 changes: 5 additions & 2 deletions tst/Devices/ApexBike/apexbiketestdata.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#pragma once

#include "Devices/Bike/biketestdata.h".h"
#include "Devices/Bike/biketestdata.h"
#include "devices/apexbike/apexbike.h"

class ApexBikeTestData : public BikeTestData {
protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new apexbike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}
public:
ApexBikeTestData() : BikeTestData("Apex Bike") {
this->addDeviceName("WLT8266BM", comparison::StartsWithIgnoreCase);
Expand Down
27 changes: 27 additions & 0 deletions tst/Devices/Bike/biketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,21 @@
#include "Devices/bluetoothdevicetestdata.h"
#include "devices/bike.h"

class BikeOptions {
public:
double resistanceGain=1.0, resistanceOffset=0.0;
bool noResistance=false, noHeartService = false, noVirtualDevice = false;

};

class BikeTestData : public BluetoothDeviceTestData {
protected:
/**
* @brief Template function called from createInstance to create an instance of the device class.
* @param options
* @return
*/
virtual bike* doCreateInstance(const BikeOptions& options) =0;

public:
BikeTestData(std::string deviceName) : BluetoothDeviceTestData(deviceName) {}
Expand All @@ -15,5 +29,18 @@ class BikeTestData : public BluetoothDeviceTestData {
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<bike*>(detectedDevice)!=nullptr;
}

/**
* @brief (Potentially amongst other things) Calls a protected function to create an instance of the device class.
* @param options
* @return
*/
bike* createInstance(const BikeOptions& options) {
// potentially validate or alter the options
auto result = this->doCreateInstance(options);

// potentially adjust the device object (e.g. connect signals and slots)
return result;
}
};

11 changes: 7 additions & 4 deletions tst/Devices/BkoolBike/bkoolbiketestdata.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#pragma once

#include "Devices/bluetoothdevicetestdata.h"
#include "Devices/Bike/biketestdata.h"
#include "devices/bkoolbike/bkoolbike.h"

class BkoolBikeTestData : public BluetoothDeviceTestData {

class BkoolBikeTestData : public BikeTestData {
protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new bkoolbike(options.noResistance, options.noHeartService);
}
public:
BkoolBikeTestData() : BluetoothDeviceTestData("Bkool Bike") {
BkoolBikeTestData() : BikeTestData("Bkool Bike") {
this->addDeviceName("BKOOLSMARTPRO", comparison::StartsWithIgnoreCase);
}

Expand Down
5 changes: 5 additions & 0 deletions tst/Devices/CSCBike/cscbiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
class CSCBikeTestData : public BikeTestData {
protected:
QString cscBikeName;


bike* doCreateInstance(const BikeOptions& options) override {
return new cscbike(options.noResistance, options.noHeartService, options.noVirtualDevice);
}
public:
CSCBikeTestData(std::string testName) : BikeTestData(testName) {
this->cscBikeName = "CyclingSpeedCadenceBike-";
Expand Down
5 changes: 4 additions & 1 deletion tst/Devices/Chronobike/chronobiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
#include "devices/chronobike/chronobike.h"

class ChronobikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new chronobike(options.noResistance, options.noHeartService);
}
public:
ChronobikeTestData() : BikeTestData("Chronobike") {
this->addDeviceName("CHRONO ", comparison::StartsWithIgnoreCase);
Expand Down
4 changes: 4 additions & 0 deletions tst/Devices/CompuTrainer/computrainertestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

class CompuTrainerTestData : public BikeTestData {
protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new computrainerbike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}

bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.computrainer_serial_port = enable ? "X":QString();
return true;
Expand Down
5 changes: 4 additions & 1 deletion tst/Devices/DomyosBike/domyosbiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
#include "devices/domyosbike/domyosbike.h"

class DomyosBikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new domyosbike(options.noResistance, options.noHeartService, false, options.resistanceOffset, options.resistanceGain);
}
public:
DomyosBikeTestData() : BikeTestData("Domyos Bike") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
#include "devices/echelonconnectsport/echelonconnectsport.h"

class EchelonConnectSportBikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new echelonconnectsport(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}
public:
EchelonConnectSportBikeTestData() : BikeTestData("Echelon Connect Sport Bike") {
this->addDeviceName("ECH", comparison::StartsWith);
Expand Down
4 changes: 4 additions & 0 deletions tst/Devices/FTMSBike/ftmsbiketestdata.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "ftmsbiketestdata.h"

#include "Devices/SnodeBike/snodebiketestdata.h"
#include "Devices/FitPlusBike/fitplusbiketestdata.h"
#include "Devices/StagesBike/stagesbiketestdata.h"

void FTMSBikeTestData::configureExclusions() {
this->exclude(new SnodeBike1TestData());
this->exclude(new SnodeBike2TestData());
Expand Down
6 changes: 3 additions & 3 deletions tst/Devices/FTMSBike/ftmsbiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

#include "devices/ftmsbike/ftmsbike.h"

#include "Devices/SnodeBike/snodebiketestdata.h"
#include "Devices/FitPlusBike/fitplusbiketestdata.h"
#include "Devices/StagesBike/stagesbiketestdata.h"

class FTMSBikeTestData : public BikeTestData {
protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new ftmsbike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}
void configureExclusions() override;

FTMSBikeTestData(std::string testName) : BikeTestData(testName) {
Expand Down
4 changes: 4 additions & 0 deletions tst/Devices/FakeBike/fakebiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

class FakeBikeTestData : public BikeTestData {
protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new fakebike(options.noResistance, options.noHeartService, options.noVirtualDevice);
}

bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.fake_bike = enable;
return true;
Expand Down
9 changes: 8 additions & 1 deletion tst/Devices/FitPlusBike/fitplusbiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

class FitPlusBikeFSTestData : public BikeTestData {
protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new fitplusbike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}

bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.fitplus_bike = enable;
return true;
Expand All @@ -27,7 +31,10 @@ class FitPlusBikeFSTestData : public BikeTestData {
};

class FitPlusBikeMRKTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new fitplusbike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}
public:
FitPlusBikeMRKTestData() : BikeTestData("FitPlus Bike (MRK, no settings)"){

Expand Down
3 changes: 3 additions & 0 deletions tst/Devices/FlywheelBike/flywheelbiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
class FlywheelBikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new flywheelbike(options.noResistance, options.noHeartService);
}
FlywheelBikeTestData(std::string testName) : BikeTestData(testName) {
}
public:
Expand Down
5 changes: 4 additions & 1 deletion tst/Devices/HorizonGR7Bike/horizongr7biketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@


class HorizonGR7BikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new horizongr7bike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}
public:
HorizonGR7BikeTestData() : BikeTestData("Horizon GR7 Bike") {
this->addDeviceName("JFIC", comparison::StartsWithIgnoreCase);
Expand Down
5 changes: 4 additions & 1 deletion tst/Devices/InspireBike/inspirebiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@


class InspireBikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new inspirebike(options.noResistance, options.noHeartService);
}
public:
InspireBikeTestData() : BikeTestData("Inspire Bike") {
this->addDeviceName("IC", comparison::StartsWithIgnoreCase, 8);
Expand Down
5 changes: 4 additions & 1 deletion tst/Devices/KeepBike/keepbiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@


class KeepBikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new keepbike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}
public:
KeepBikeTestData() : BikeTestData("Keep Bike") {
this->addDeviceName("KEEP_BIKE_", comparison::StartsWithIgnoreCase);
Expand Down
3 changes: 3 additions & 0 deletions tst/Devices/M3IBike/m3ibiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class M3IBikeTestData : public BikeTestData {
protected:
void configureBluetoothDeviceInfos(const QBluetoothDeviceInfo& info, bool enable, std::vector<QBluetoothDeviceInfo>& bluetoothDeviceInfos) const override;

bike* doCreateInstance(const BikeOptions& options) override {
return new m3ibike(options.noResistance, options.noHeartService);
}
public:
M3IBikeTestData() : BikeTestData("M3I Bike") {
this->addDeviceName("M3", comparison::StartsWith);
Expand Down
5 changes: 4 additions & 1 deletion tst/Devices/MCFBike/mcfbiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@


class MCFBikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new mcfbike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}
public:
MCFBikeTestData() : BikeTestData("MCF Bike") {
this->addDeviceName("MCF-", comparison::StartsWithIgnoreCase);
Expand Down
5 changes: 4 additions & 1 deletion tst/Devices/MepanelBike/mepanelbiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@


class MepanelBikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new mepanelbike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}
public:
MepanelBikeTestData() : BikeTestData("Mepanel Bike") {
this->addDeviceName("MEPANEL", comparison::StartsWithIgnoreCase);
Expand Down
3 changes: 3 additions & 0 deletions tst/Devices/NPECableBike/npecablebiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

class NPECableBikeTestData : public BikeTestData {
protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new npecablebike(options.noResistance, options.noHeartService);
}
NPECableBikeTestData(std::string testName) : BikeTestData(testName) {}
public:
deviceType get_expectedDeviceType() const override { return deviceType::NPECableBike; }
Expand Down
5 changes: 4 additions & 1 deletion tst/Devices/NautilusBike/nautilusbiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@


class NautilusBikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new nautilusbike(options.noResistance, options.noHeartService, false, options.resistanceOffset, options.resistanceGain);
}
public:
NautilusBikeTestData(): BikeTestData("Nautilus Bike") {
this->addDeviceName("NAUTILUS B", comparison::StartsWithIgnoreCase);
Expand Down
3 changes: 3 additions & 0 deletions tst/Devices/PafersBike/pafersbiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

class PafersBikeTestData : public BikeTestData {
protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new pafersbike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
// the treadmill is given priority
info.pafers_treadmill = !enable;
Expand Down
5 changes: 4 additions & 1 deletion tst/Devices/ProFormBike/proformbiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@


class ProFormBikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new proformbike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}
public:
ProFormBikeTestData() : BikeTestData("ProForm Bike") {
this->addDeviceName("I_EB", comparison::StartsWith);
Expand Down
4 changes: 4 additions & 0 deletions tst/Devices/ProFormWiFiBike/proformwifibiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

class ProFormWiFiBikeTestData : public BikeTestData {
protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new proformwifibike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}

bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.proformtdf4ip = enable ? this->get_testIP():QString();
return true;
Expand Down
2 changes: 2 additions & 0 deletions tst/Devices/RenphoBike/renphobiketestdata.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "renphobiketestdata.h"
#include "Devices/FitPlusBike/fitplusbiketestdata.h"
#include "Devices/SnodeBike/snodebiketestdata.h"

void RenphoBikeTestData::configureExclusions() {
this->exclude(new FitPlusBikeFSTestData());
Expand Down
7 changes: 4 additions & 3 deletions tst/Devices/RenphoBike/renphobiketestdata.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#pragma once

#include "Devices/Bike/biketestdata.h"
#include "Devices/FitPlusBike/fitplusbiketestdata.h"
#include "Devices/SnodeBike/snodebiketestdata.h"

#include "devices/renphobike/renphobike.h"

class RenphoBikeTestData : public BikeTestData {
protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new renphobike(options.noResistance, options.noHeartService);
}

RenphoBikeTestData(std::string testName) : BikeTestData(testName) {
}

Expand Down
5 changes: 4 additions & 1 deletion tst/Devices/Schwinn170Bike/schwinn170biketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@


class Schwinn170BikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new schwinn170bike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}
public:
Schwinn170BikeTestData() : BikeTestData("Schwinn 170 Bike") {

Expand Down
5 changes: 4 additions & 1 deletion tst/Devices/SchwinnIC4Bike/schwinnic4biketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@


class SchwinnIC4BikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new schwinnic4bike(options.noResistance, options.noHeartService);
}
public:
SchwinnIC4BikeTestData() : BikeTestData("Schwinn IC4 Bike") {

Expand Down
5 changes: 4 additions & 1 deletion tst/Devices/SkandikaWiryBike/skandikawirybiketestdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@


class SkandikaWiryBikeTestData : public BikeTestData {

protected:
bike* doCreateInstance(const BikeOptions& options) override {
return new skandikawiribike(options.noResistance, options.noHeartService, options.resistanceOffset, options.resistanceGain);
}
public:
SkandikaWiryBikeTestData() : BikeTestData("Skandika Wiry Bike") {
this->addDeviceName("BFCP", comparison::StartsWithIgnoreCase);
Expand Down
Loading

0 comments on commit 678facc

Please sign in to comment.