Manufacturer update of test project (#2654)

* #2653 refactored test project

* #2653 doc file update

* #2653 added documentation on class members
Changed some variable names.
Deleted member object in destructor
This commit is contained in:
David Mason
2024-10-15 08:30:48 +01:00
committed by GitHub
parent 60e990a6c4
commit cb8939849b
119 changed files with 3049 additions and 4201 deletions

View File

@@ -8,23 +8,21 @@ The testing project tst/qdomyos-zwift-tests.pro contains test code that uses the
New devices are added to the main QZ application by creating or modifying a subclass of the bluetoothdevice class.
At minimum, each device has a corresponding BluetoothDeviceTestData subclass in the test project, which is coded to provide information to the test framework to generate tests for device detection and potentially other things.
At minimum, each device has a corresponding BluetoothDeviceTestData object constructed in the DeviceTestDataIndex class in the test project, which is coded to provide information to the test framework to generate tests for device detection and potentially other things.
In the test project
* create a new folder for the device under tst/Devices. This is for anything you define for testing this device.
* add a new class with header file and optionally .cpp file to the project in that folder. Name the class DeviceNameTestData, substituting an appropriate name in place of "DeviceName".
* edit the header file to inherit the class from the BluetoothDeviceTestData abstract subclass appropriate to the device type, i.e. BikeTestData, RowerTestData, EllipticalTestData, TreadmillTestData.
* have this new subclass' constructor pass a unique test name to its superclass.
* add a new device name constant to the DeviceIndex class.
* locate the implementation of DeviceTestDataindex::Initialize and build the test data from a call to DeviceTestDataIndex::RegisterNewDeviceTestData(...)
* pass the device name constant defined in the DeviceIndex class to the call to DeviceTestDataIndex::RegisterNewDeviceTestData(...).
The tests are not organised around real devices that are handled, but the bluetoothdevice subclass that handles them - the "driver" of sorts.
You need to provide the following:
- patterns for valid names (e.g. equals a value, starts with a value, case sensitivity, specific length)
- invalid names to ensure the device is not identified when the name is invalid
- configuration settings that are required for the device to be detected
- configuration settings that are required for the device to be detected, including bluetooth device information configuration
- invalid configurations to test that the device is not detected, e.g. when it's disabled in the settings, but the name is correct
- exclusion devices: if a device with the same name but of a higher priority type is detected, this device should not be detected
- valid and invalid QBluetoothDeviceInfo configurations, e.g. to check the device is only detected when the manufacturer data is set correctly, or certain services are available or not.
- exclusion devices: for example if a device with the same name but of a higher priority type is detected, this device should not be detected
## Tools in the Test Framework
@@ -39,16 +37,18 @@ i.e. a test will
### DeviceDiscoveryInfo
This class contains a set of fields that store strongly typed QSettings values.
It also provides methods to read and write the values it knows about from and to a QSettings object.
This class:
* stores values for a specific subset of the QZSettings keys.
* provides methods to read and write the values it knows about from and to a QSettings object.
* provides a QBluetoothDeviceInfo object configured with the device name currently being tested.
It is used in conjunction with a TestSettings object to write a configuration during a test.
## Writing a device detection test
Because of the way the TestData classes currently work, it may be necessary to define multiple test data classes to cover the various cases.
For example, if any of a list of names is enough to identify a device, or another group of names but with a certain service in the bluetooth device info, that will require multiple classes.
Because of the way the BluetoothDeviceTestDataBuilder currently works, it may be necessary to define multiple test data objects to cover the various cases.
For example, if any of a list of names is enough to identify a device, or another group of names but with a certain service in the bluetooth device info, that will require multiple test data objects.
### Recognition by Name
@@ -68,133 +68,83 @@ Reading this, to identify this device:
In this case, we are not testing the last two, but can test the first two.
In deviceindex.h:
```
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/domyosbike/domyosbike.h"
class DomyosBikeTestData : public BikeTestData {
public:
DomyosBikeTestData() : BikeTestData("Domyos Bike") {
this->addDeviceName("Domyos-Bike", comparison::StartsWith);
this->addInvalidDeviceName("DomyosBridge", comparison::StartsWith);
}
// not used yet
deviceType get_expectedDeviceType() const override { return deviceType::DomyosBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<domyosbike*>(detectedDevice)!=nullptr;
}
};
static const QString DomyosBike;
```
The constructor adds a valid device name, and an invalid one. Various overloads of these methods and other members of the comparison enumeration provide other capabilities for specifying test data. If you add a valid device name that says the name should start with a value, additional names will be added automatically to the valid list with additional characters to test that it is in fact a "starts with" relationship. Also, valid and invalid names will be generated base on whether the comparison is case sensitive or not.
In deviceindex.cpp:
The get_expectedDeviceType() function is not actually used and is part of an unfinished refactoring of the device detection code, whereby the bluetoothdevice object doesn't actually get created intially. You could add a new value to the deviceType enum and return that, but it's not used yet. There's always deviceType::None.
```
DEFINE_DEVICE(DomyosBike, "Domyos Bike");
```
The get_isExpectedDevice(bluetoothdevice *) function must be overridden to indicate if the specified object is of the type expected for this test data.
This pair adds the "friendly name" for the device as a constant, and also adds the key/value pair to an index.
In DeviceTestDataIndex::Initialize():
```
// Domyos bike
RegisterNewDeviceTestData(DeviceIndex::DomyosBike)
->expectDevice<domyosbike>()
->acceptDeviceName("Domyos-Bike", DeviceNameComparison::StartsWith)
->rejectDeviceName("DomyosBridge", DeviceNameComparison::StartsWith);
```
This set of instructions adds a valid device name, and an invalid one. Various overloads of these methods, other methods, and other members of the comparison enumeration provide other capabilities for specifying test data. If you add a valid device name that says the name should start with a value, additional names will be added automatically to the valid list with additional characters to test that it is in fact a "starts with" relationship. Also, valid and invalid names will be generated based on whether the comparison is case sensitive or not.
### Configuration Settings
Consider the CompuTrainerTestData. This device is not detected by name, but only by whether or not it is enabled in the settings.
To specify this in the test data, we override one of the configureSettings methods, the one for the simple case where there is a single valid and a single invalid configuration.
Consider the CompuTrainer bike. This device is not detected by name, but only by whether or not it is enabled in the settings.
To specify this in the test data, we use one of the BluetoothDeviceTestData::configureSettingsWith(...) methods, the one for the simple case where there is a single QZSetting with a specific enabling and disabling value.
Settings from QSettings that contribute to tests should be put into the DeviceDiscoveryInfo class.
For example, for the Computrainer Bike, the "computrainer_serial_port" value from the QSettings determines if the bike should be detected or not.
For example, for the Computrainer Bike, the "computrainer_serialport" value from the QSettings determines if the bike should be detected or not.
The computrainer_serialport QZSettings key should be registered in devicediscoveryinfo.cpp
In devicediscoveryinfo.cpp:
```
class DeviceDiscoveryInfo {
public :
...
QString computrainer_serial_port = nullptr;
...
}
```
void InitializeTrackedSettings() {
The getValues and setValues methods should be updated to include the addition(s):
```
void DeviceDiscoveryInfo::setValues(QSettings &settings, bool clear) const {
if(clear) settings.clear();
...
settings.setValue(QZSettings::computrainer_serialport, this->computrainer_serial_port);
...
}
void DeviceDiscoveryInfo::getValues(QSettings &settings){
...
this->computrainer_serial_port = settings.value(QZSettings::computrainer_serialport, QZSettings::default_computrainer_serialport).toString();
trackedSettings.insert(QZSettings::computrainer_serialport, QZSettings::default_computrainer_serialport);
...
}
```
In the following example, the DeviceDiscoveryInfo class has been updated to contain the device's configuration setting (computrainer_serial_port).
- if an enabling configuration is requested (enable==true) a string that is known to be accepted is supplied
- if a disabling configuration is requested (enable==false) an empty string is supplied.
For this test data,
* if enabling configurations are requested, the computrainer_serialport setting will be populated with "COMX"
* if disabling configurations are requested, the computrainer_serialport setting will be populated with ""
This example uses the simpler of 2 configureSettings methods returns true/false to indicate if the configuration should be used for the test.
DeviceTestDataIndex::Initialize():
```
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/computrainerbike/computrainerbike.h"
class CompuTrainerTestData : public BikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.computrainer_serial_port = enable ? "X":QString();
return true;
}
public:
CompuTrainerTestData() : BikeTestData("CompuTrainer Bike") {
// any name
this->addDeviceName("", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::CompuTrainerBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<computrainerbike*>(detectedDevice)!=nullptr;
}
};
// Computrainer Bike
RegisterNewDeviceTestData(DeviceIndex::ComputrainerBike)
->expectDevice<computrainerbike>()
->acceptDeviceName("", DeviceNameComparison::StartsWithIgnoreCase)
->configureSettingsWith(QZSettings::computrainer_serialport, "COMX", "");
```
Similarly, the Pafers Bike has a simple configuration setting:
```
#include "Devices/Bike/biketestdata.h"
#include "devices/pafersbike/pafersbike.h"
class PafersBikeTestData : public BikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
// the treadmill is given priority
info.pafers_treadmill = !enable;
return true;
}
public:
PafersBikeTestData() : BikeTestData("Pafers Bike") {
this->addDeviceName("PAFERS_", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::PafersBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<pafersbike*>(detectedDevice)!=nullptr;
}
};
// Pafers Bike
RegisterNewDeviceTestData(DeviceIndex::PafersBike)
->expectDevice<pafersbike>()
->acceptDeviceName("PAFERS_", DeviceNameComparison::StartsWithIgnoreCase)
->configureSettingsWith(QZSettings::pafers_treadmill,false);
```
In that case, ```configureSettingsWith(QZSettings::pafers_treadmill,false)``` indicates that the pafers_treadmill setting will be false for enabling configurations and true for disabling ones.
A more complicated example is the Pafers Treadmill. It involves a name match, but also some configuration settings obtained earlier...
```
@@ -212,76 +162,60 @@ bool pafers_treadmill_bh_iboxster_plus =
```
Here the device could be activated due to a name match and various combinations of settings.
For this, the configureSettings function that takes a vector of DeviceDiscoveryInfo objects which is populated with configurations that lead to the specified result (enable = detected, !enable=not detected). Instead of returning a boolean to indicate if a configuration has been supplied, it populates a vector of DeviceDiscoveryInfo objects.
For this, the configureSettingsWith(...) function that takes a lambda function which consumes a vector of DeviceDiscoveryInfo objects which is populated with configurations that lead to the specified result (enable = detected, !enable=not detected).
```
#pragma once
// Pafers Treadmill
RegisterNewDeviceTestData(DeviceIndex::PafersTreadmill)
->expectDevice<paferstreadmill>()
->acceptDeviceName("PAFERS_", DeviceNameComparison::StartsWithIgnoreCase)
->configureSettingsWith( [](const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations)->void {
DeviceDiscoveryInfo config(info);
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/paferstreadmill/paferstreadmill.h"
class PafersTreadmillTestData : public TreadmillTestData {
protected:
void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const override {
DeviceDiscoveryInfo config(info);
if (enable) {
for(int x = 1; x<=3; x++) {
config.pafers_treadmill = x & 1;
config.pafers_treadmill_bh_iboxster_plus = x & 2;
configurations.push_back(config);
}
} else {
config.pafers_treadmill = false;
config.pafers_treadmill_bh_iboxster_plus = false;
configurations.push_back(config);
}
}
public:
PafersTreadmillTestData() : TreadmillTestData("Pafers Treadmill") {
this->addDeviceName("PAFERS_", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::PafersTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<paferstreadmill*>(detectedDevice)!=nullptr;
}
};
if (enable) {
for(int x = 1; x<=3; x++) {
config.setValue(QZSettings::pafers_treadmill, x & 1);
config.setValue(QZSettings::pafers_treadmill_bh_iboxster_plus, x & 2);
configurations.push_back(config);
}
} else {
config.setValue(QZSettings::pafers_treadmill, false);
config.setValue(QZSettings::pafers_treadmill_bh_iboxster_plus, false);
configurations.push_back(config);
}
});
```
### Considering Extra QBluetoothDeviceInfo Content
Detection of some devices requires some specific bluetooth device information.
Supplying enabling and disabling QBluetoothDeviceInfo objects is done using a similar pattern to the multiple configurations scenario.
For example, the M3iBike requires specific manufacturer information.
Supplying enabling and disabling QBluetoothDeviceInfo objects is done by accessing the QBluetoothDeviceInfo member of the DeviceDiscoveryInfo object.
For example, the M3iBike requires specific manufacturer information, using the simpler of the lambda functions accepted by the configureSettingsWith function.
```
void M3IBikeTestData::configureBluetoothDeviceInfos(const QBluetoothDeviceInfo& info, bool enable, std::vector<QBluetoothDeviceInfo>& bluetoothDeviceInfos) const {
// The M3I bike detector looks into the manufacturer data.
// M3I Bike
RegisterNewDeviceTestData(DeviceIndex::M3IBike)
->expectDevice<m3ibike>()
->acceptDeviceName("M3", DeviceNameComparison::StartsWith)
->configureSettingsWith(
[](DeviceDiscoveryInfo& info, bool enable)->void
{
// The M3I bike detector looks into the manufacturer data.
if(!enable) {
info.DeviceInfo()->setManufacturerData(1, QByteArray("Invalid manufacturer data."));
return;
}
QBluetoothDeviceInfo result = info;
if(!enable) {
result.setManufacturerData(1, QByteArray("Invalid manufacturer data."));
bluetoothDeviceInfos.push_back(result);
return;
}
int key=0;
result.setManufacturerData(key++, hex2bytes("02010639009F00000000000000000014008001"));
bluetoothDeviceInfos.push_back(result);
}
int key=0;
info.DeviceInfo()->setManufacturerData(key++, hex2bytes("02010639009F00000000000000000014008001"));
});
```
The test framework populates the incoming QBluetoothDeviceInfo object with a name and a UUID. This is expected to have nothing else defined.
Another example is one of the test data classes for detecting a device that uses the statesbike class:
The test framework populates the incoming QBluetoothDeviceInfo object with a UUID and the name (generated from the acceptDeviceName and rejectDeviceName calls) currently being tested.
This is expected to have nothing else defined.
Another example is one of the test data definitions for detecting a device that uses the stagesbike class:
Detection code from bluetooth.cpp:
@@ -289,37 +223,49 @@ Detection code from bluetooth.cpp:
((b.name().toUpper().startsWith("KICKR CORE")) && !deviceHasService(b, QBluetoothUuid((quint16)0x1826)) && deviceHasService(b, QBluetoothUuid((quint16)0x1818)))
```
This condition is actually extracted from a more complicated example where the current test data classes can't cover all the detection criteria in one implementation. This is why this class inherits from StagesBikeTestData rather than BikeTestData directly.
This condition is actually extracted from a more complicated example where the BluetoothDeviceTestData class can't cover all the detection criteria with one instance.
```
class StagesBike3TestData : public StagesBikeTestData {
protected:
void configureBluetoothDeviceInfos(const QBluetoothDeviceInfo& info, bool enable, std::vector<QBluetoothDeviceInfo>& bluetoothDeviceInfos) const override {
// The condition, if the name is acceptable, is:
// !deviceHasService(b, QBluetoothUuid((quint16)0x1826)) && deviceHasService(b, QBluetoothUuid((quint16)0x1818)))
// Stages Bike General
auto stagesBikeExclusions = { GetTypeId<ftmsbike>() };
if(enable) {
QBluetoothDeviceInfo result = info;
result.setServiceUuids(QVector<QBluetoothUuid>({QBluetoothUuid((quint16)0x1818)}));
bluetoothDeviceInfos.push_back(result);
} else {
QBluetoothDeviceInfo hasInvalid = info;
hasInvalid.setServiceUuids(QVector<QBluetoothUuid>({QBluetoothUuid((quint16)0x1826)}));
QBluetoothDeviceInfo hasBoth = hasInvalid;
hasBoth.setServiceUuids(QVector<QBluetoothUuid>({QBluetoothUuid((quint16)0x1818),QBluetoothUuid((quint16)0x1826)}));
//
// ... other stages bike variants
//
bluetoothDeviceInfos.push_back(info); // has neither
bluetoothDeviceInfos.push_back(hasInvalid);
bluetoothDeviceInfos.push_back(hasBoth);
}
}
// Stages Bike (KICKR CORE)
RegisterNewDeviceTestData(DeviceIndex::StagesBike_KICKRCORE)
->expectDevice<stagesbike>()
->acceptDeviceName("KICKR CORE", DeviceNameComparison::StartsWithIgnoreCase)
->excluding(stagesBikeExclusions)
->configureSettingsWith(
[](const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations)->void
{
// The condition, if the name is acceptable, is:
// !deviceHasService(b, QBluetoothUuid((quint16)0x1826)) && deviceHasService(b, QBluetoothUuid((quint16)0x1818)))
public:
StagesBike3TestData() : StagesBikeTestData("Stages Bike (KICKR CORE)") {
if(enable) {
DeviceDiscoveryInfo result = info;
result.addBluetoothService(QBluetoothUuid((quint16)0x1818));
result.removeBluetoothService(QBluetoothUuid((quint16)0x1826));
configurations.push_back(result);
} else {
DeviceDiscoveryInfo hasNeither = info;
hasNeither.removeBluetoothService(QBluetoothUuid((quint16)0x1818));
hasNeither.removeBluetoothService(QBluetoothUuid((quint16)0x1826));
DeviceDiscoveryInfo hasInvalid = info;
hasInvalid.addBluetoothService(QBluetoothUuid((quint16)0x1826));
DeviceDiscoveryInfo hasBoth = hasInvalid;
hasBoth.addBluetoothService(QBluetoothUuid((quint16)0x1818));
hasBoth.addBluetoothService(QBluetoothUuid((quint16)0x1826));
configurations.push_back(info); // has neither
configurations.push_back(hasInvalid);
configurations.push_back(hasBoth);
}
});
this->addDeviceName("KICKR CORE", comparison::StartsWithIgnoreCase);
}
};
```
In this case, it populates the vector with the single enabling configuration if that's what's been requested, otherwise 3 disabling ones.
@@ -328,7 +274,7 @@ In this case, it populates the vector with the single enabling configuration if
Sometimes there might be ambiguity when multiple devices are available, and the detection code may specify that if the other conditions match, but certain specific kinds of devices (the exclusion devices) have already been detected, the newly matched device should be ignored.
The TestData class can be made to cover this by overriding the configureExclusions() method to add instances of the TestData classes for the exclusion devices to the object's internal list of exclusions.
The test data object can be made to cover this by calling the excluding(...) functions to add type identifiers for the bluetoothdevice classes for the exclusion devices to the object's internal list of exclusions.
Detection code:
@@ -336,39 +282,19 @@ Detection code:
} else if (b.name().startsWith(QStringLiteral("ECH")) && !echelonRower && !echelonStride &&
!echelonConnectSport && filter) {
```
The configureExclusions code is overridden to specify the exclusion test data objects. Note that the test for a previously detected device of the same type is not included.
The excluding<T>() template function is called to specify the exclusion device type. Note that the test for a previously detected device of the same type is not included.
```
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "Devices/EchelonRower/echelonrowertestdata.h"
#include "Devices/EchelonStrideTreadmill/echelonstridetreadmilltestdata.h"
#include "devices/echelonconnectsport/echelonconnectsport.h"
class EchelonConnectSportBikeTestData : public BikeTestData {
public:
EchelonConnectSportBikeTestData() : BikeTestData("Echelon Connect Sport Bike") {
this->addDeviceName("ECH", comparison::StartsWith);
}
void configureExclusions() override {
this->exclude(new EchelonRowerTestData());
this->exclude(new EchelonStrideTreadmillTestData());
}
deviceType get_expectedDeviceType() const override { return deviceType::EchelonConnectSport; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<echelonconnectsport*>(detectedDevice)!=nullptr;
}
};
// Echelon Connect Sport Bike
RegisterNewDeviceTestData(DeviceIndex::EchelonConnectSportBike)
->expectDevice<echelonconnectsport>()
->acceptDeviceName("ECH", DeviceNameComparison::StartsWith)
->excluding<echelonrower>()
->excluding<echelonstride>();
```
### When a single TestData Class Can't Cover all the Conditions
### When a single test data object can't cover all the conditions
Detection code:
@@ -390,116 +316,81 @@ This presents 3 scenarios for the current test framework.
2. Match the name "KICKR CORE", presence and absence of specific service ids
3. Match the name "ASSIOMA" and the power sensor name setting starts with "Disabled"
The framework is not currently capable of specifying all these scenarios in a single class.
The generated test data is approximately the combinations of these lists: names * settings * bluetoothdeviceInfo * exclusions.
If a combination should not exist, a separate class should be used.
The framework is not currently capable of specifying all these scenarios in a single test data object, without checking the name of the supplied QBluetoothDeviceInfo object against name conditions specified and constructing extra configurations based on that.
The generated test data is approximately the combinations of these lists: names * settings * exclusions.
If a combination should not exist, separate test data objects should be used.
In the example of the StagesBikeTestData classes, the exclusions, which apply to all situations, are implemented in the superclass StagesBikeTestData,
In the example of the Stages Bike test data, the exclusions, which apply to all situations, are implemented in an array of type ids:
```
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/stagesbike/stagesbike.h"
#include "Devices/FTMSBike/ftmsbiketestdata.h"
class StagesBikeTestData : public BikeTestData {
protected:
StagesBikeTestData(std::string testName): BikeTestData(testName) {
}
void configureExclusions() override {
this->exclude(new FTMSBike1TestData());
this->exclude(new FTMSBike2TestData());
}
public:
deviceType get_expectedDeviceType() const override { return deviceType::StagesBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<stagesbike*>(detectedDevice)!=nullptr;
}
};
// Stages Bike General
auto stagesBikeExclusions = { GetTypeId<ftmsbike>() };
```
The name-match only in one subclass:
The name-match only in one test data instance:
```
class StagesBike1TestData : public StagesBikeTestData {
public:
StagesBike1TestData() : StagesBikeTestData("Stages Bike") {
this->addDeviceName("STAGES ", comparison::StartsWithIgnoreCase);
this->addDeviceName("TACX SATORI", comparison::StartsWithIgnoreCase);
}
};
// Stages Bike
RegisterNewDeviceTestData(DeviceIndex::StagesBike)
->expectDevice<stagesbike>()
->acceptDeviceNames({"STAGES ", "TACX SATORI"}, DeviceNameComparison::StartsWithIgnoreCase)
->acceptDeviceName("QD", DeviceNameComparison::IgnoreCase)
->excluding(stagesBikeExclusions);
```
The name and setting match in another subclass:
The name and setting match in another instance:
```
class StagesBike2TestData : public StagesBikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.powerSensorName = enable ? "Disabled":"Roberto";
return true;
}
public:
StagesBike2TestData() : StagesBikeTestData("Stages Bike (Assioma / Power Sensor disabled") {
this->addDeviceName("ASSIOMA", comparison::StartsWithIgnoreCase);
}
};
// Stages Bike Stages Bike (Assioma / Power Sensor disabled
RegisterNewDeviceTestData(DeviceIndex::StagesBike_Assioma_PowerSensorDisabled)
->expectDevice<stagesbike>()
->acceptDeviceName("ASSIOMA", DeviceNameComparison::StartsWithIgnoreCase)
->configureSettingsWith(QZSettings::power_sensor_name, "DisabledX", "XDisabled")
->excluding( stagesBikeExclusions);
```
The name and bluetooth device info configurations in another:
```
// Stages Bike (KICKR CORE)
RegisterNewDeviceTestData(DeviceIndex::StagesBike_KICKRCORE)
->expectDevice<stagesbike>()
->acceptDeviceName("KICKR CORE", DeviceNameComparison::StartsWithIgnoreCase)
->excluding(stagesBikeExclusions)
->configureSettingsWith(
[](const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations)->void
{
// The condition, if the name is acceptable, is:
// !deviceHasService(b, QBluetoothUuid((quint16)0x1826)) && deviceHasService(b, QBluetoothUuid((quint16)0x1818)))
class StagesBike3TestData : public StagesBikeTestData {
protected:
void configureBluetoothDeviceInfos(const QBluetoothDeviceInfo& info, bool enable, std::vector<QBluetoothDeviceInfo>& bluetoothDeviceInfos) const override {
// The condition, if the name is acceptable, is:
// !deviceHasService(b, QBluetoothUuid((quint16)0x1826)) && deviceHasService(b, QBluetoothUuid((quint16)0x1818)))
if(enable) {
DeviceDiscoveryInfo result = info;
result.addBluetoothService(QBluetoothUuid((quint16)0x1818));
result.removeBluetoothService(QBluetoothUuid((quint16)0x1826));
configurations.push_back(result);
} else {
DeviceDiscoveryInfo hasNeither = info;
hasNeither.removeBluetoothService(QBluetoothUuid((quint16)0x1818));
hasNeither.removeBluetoothService(QBluetoothUuid((quint16)0x1826));
if(enable) {
QBluetoothDeviceInfo result = info;
result.setServiceUuids(QVector<QBluetoothUuid>({QBluetoothUuid((quint16)0x1818)}));
bluetoothDeviceInfos.push_back(result);
} else {
QBluetoothDeviceInfo hasInvalid = info;
hasInvalid.setServiceUuids(QVector<QBluetoothUuid>({QBluetoothUuid((quint16)0x1826)}));
QBluetoothDeviceInfo hasBoth = hasInvalid;
hasBoth.setServiceUuids(QVector<QBluetoothUuid>({QBluetoothUuid((quint16)0x1818),QBluetoothUuid((quint16)0x1826)}));
DeviceDiscoveryInfo hasInvalid = info;
hasInvalid.addBluetoothService(QBluetoothUuid((quint16)0x1826));
DeviceDiscoveryInfo hasBoth = hasInvalid;
hasBoth.addBluetoothService(QBluetoothUuid((quint16)0x1818));
hasBoth.addBluetoothService(QBluetoothUuid((quint16)0x1826));
bluetoothDeviceInfos.push_back(info); // has neither
bluetoothDeviceInfos.push_back(hasInvalid);
bluetoothDeviceInfos.push_back(hasBoth);
}
}
public:
StagesBike3TestData() : StagesBikeTestData("Stages Bike (KICKR CORE)") {
this->addDeviceName("KICKR CORE", comparison::StartsWithIgnoreCase);
}
};
configurations.push_back(info); // has neither
configurations.push_back(hasInvalid);
configurations.push_back(hasBoth);
}
});
```
## Telling Google Test Where to Look
To register your test data class(es) with Google Test:
- open tst/Devices/devices.h
- add a #include for your new header file(s)
- add your new classes to the BluetoothDeviceTestDataTypes list.
This will add tests for your new device class to test runs of the tests in the BluetoothDeviceTestSuite class, which are about detecting, and not detecting devices in circumstances generated from the TestData classes.
The BluetoothDeviceTestSuite configuration specifies that the test data will be obtained from the DeviceTestDataIndex class, so there's nothing more to do.

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/activiotreadmill/activiotreadmill.h"
class ActivioTreadmillTestData : public TreadmillTestData {
public:
ActivioTreadmillTestData() : TreadmillTestData("Activio Treadmill") {
this->addDeviceName("RUNNERT", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::ActivioTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<activiotreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h".h"
#include "devices/apexbike/apexbike.h"
class ApexBikeTestData : public BikeTestData {
public:
ApexBikeTestData() : BikeTestData("Apex Bike") {
this->addDeviceName("WLT8266BM", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::ApexBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<apexbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,18 +0,0 @@
#pragma once
#include "Devices/Elliptical/ellipticaltestdata.h"
#include "devices/bhfitnesselliptical/bhfitnesselliptical.h"
class BHFitnessEllipticalTestData : public EllipticalTestData {
public:
BHFitnessEllipticalTestData() : EllipticalTestData("BH Fitness Elliptical") {
this->addDeviceName("B01_", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::BHFitnessElliptical; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<bhfitnesselliptical*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/bluetoothdevicetestdata.h"
#include "devices/bike.h"
class BikeTestData : public BluetoothDeviceTestData {
public:
BikeTestData(std::string deviceName) : BluetoothDeviceTestData(deviceName) {}
deviceType get_expectedDeviceType() const override {
return deviceType::None; // abstract
}
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<bike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/bluetoothdevicetestdata.h"
#include "devices/bkoolbike/bkoolbike.h"
class BkoolBikeTestData : public BluetoothDeviceTestData {
public:
BkoolBikeTestData() : BluetoothDeviceTestData("Bkool Bike") {
this->addDeviceName("BKOOLSMARTPRO", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::BkoolBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<bkoolbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/bowflext216treadmill/bowflext216treadmill.h"
class BowflexT216TreadmillTestData : public TreadmillTestData {
public:
BowflexT216TreadmillTestData() : TreadmillTestData("Bowflex T216 Treadmill") {
this->addDeviceName("BOWFLEX T", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::BowflexT216Treadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<bowflext216treadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,26 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/bowflextreadmill/bowflextreadmill.h"
class BowflexTreadmillTestData : public TreadmillTestData {
public:
BowflexTreadmillTestData() : TreadmillTestData("Bowflex Treadmill"){}
QStringList get_deviceNames() const override {
QStringList result;
return result;
}
deviceType get_expectedDeviceType() const override {
// device not supported
return deviceType::None;
}
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<bowflextreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,79 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/cscbike/cscbike.h"
class CSCBikeTestData : public BikeTestData {
protected:
QString cscBikeName;
public:
CSCBikeTestData(std::string testName) : BikeTestData(testName) {
this->cscBikeName = "CyclingSpeedCadenceBike-";
}
deviceType get_expectedDeviceType() const override { return deviceType::CSCBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<cscbike*>(detectedDevice)!=nullptr;
}
};
class CSCBike1TestData : public CSCBikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.cscName = enable ? this->cscBikeName : "Disabled";
info.csc_as_bike = enable;
return true;
}
public:
CSCBike1TestData() : CSCBikeTestData("CSC Bike (Named)") {
// Test for cases where success means the csc_as_bike setting has to be enabled.
this->addDeviceName(this->cscBikeName, comparison::StartsWith);
this->addInvalidDeviceName("X"+this->cscBikeName, comparison::Exact);
}
};
class CSCBike2TestData : public CSCBikeTestData {
protected:
void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const override {
DeviceDiscoveryInfo config(info);
if(enable) {
// If the Bluetooth name doesn't match the one being tested, but if csc_as_bike is enabled in the settings,
// and the bluetooth name does match the cscName in the settings, the device will be detected anyway,
// so prevent this by not including that specific configuration
//
// In order for the search to actually happen, the cscName has to be "Disabled" or csc_as_bike must be true.
/*
config.csc_as_bike = true;
config.cscName = this->cscBikeName;
configurations.push_back(config);
*/
config.cscName = "Disabled";
config.csc_as_bike = true;
configurations.push_back(config);
config.cscName = "Disabled";
config.csc_as_bike = false;
configurations.push_back(config);
config.csc_as_bike = true;
config.cscName = "NOT "+this->cscBikeName;
configurations.push_back(config);
}
else {
// prevent the search
config.csc_as_bike = false;
config.cscName = "NOT "+this->cscBikeName;
configurations.push_back(config);
}
}
public:
CSCBike2TestData() : CSCBikeTestData("CSC Bike (Unnamed)") {
this->addDeviceName(QStringLiteral("JOROTO-BK-"), comparison::StartsWithIgnoreCase);
}
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/chronobike/chronobike.h"
class ChronobikeTestData : public BikeTestData {
public:
ChronobikeTestData() : BikeTestData("Chronobike") {
this->addDeviceName("CHRONO ", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::ChronoBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<chronobike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,24 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/computrainerbike/computrainerbike.h"
class CompuTrainerTestData : public BikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.computrainer_serial_port = enable ? "X":QString();
return true;
}
public:
CompuTrainerTestData() : BikeTestData("CompuTrainer Bike") {
// any name
this->addDeviceName("", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::CompuTrainerBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<computrainerbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/Rower/rowertestdata.h"
#include "devices/concept2skierg/concept2skierg.h"
class Concept2SkiErgTestData : public RowerTestData {
public:
Concept2SkiErgTestData() : RowerTestData("Concept2 Ski Erg") {
this->addDeviceName("PM5", "SKI", comparison::IgnoreCase);
this->addDeviceName("PM5", comparison::IgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::Concept2SkiErg; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<concept2skierg*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,23 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/domyosbike/domyosbike.h"
class DomyosBikeTestData : public BikeTestData {
public:
DomyosBikeTestData() : BikeTestData("Domyos Bike") {
this->addDeviceName("Domyos-Bike", comparison::StartsWith);
this->addInvalidDeviceName("DomyosBridge", comparison::StartsWith);
}
deviceType get_expectedDeviceType() const override { return deviceType::DomyosBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<domyosbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,20 +0,0 @@
#pragma once
#include "Devices/Elliptical/ellipticaltestdata.h"
#include "devices/domyoselliptical/domyoselliptical.h"
class DomyosEllipticalTestData : public EllipticalTestData {
public:
DomyosEllipticalTestData() : EllipticalTestData("Domyos Elliptical") {
this->addDeviceName("Domyos-EL", comparison::StartsWith);
this->addInvalidDeviceName("DomyosBridge",comparison::StartsWith);
}
deviceType get_expectedDeviceType() const override { return deviceType::DomyosElliptical; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<domyoselliptical*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,22 +0,0 @@
#pragma once
#include "Devices/Rower/rowertestdata.h"
#include "devices/domyosrower/domyosrower.h"
class DomyosRowerTestData : public RowerTestData {
public:
DomyosRowerTestData() : RowerTestData("Domyos Rower") {
this->addDeviceName("DOMYOS-ROW", comparison::StartsWithIgnoreCase);
this->addInvalidDeviceName("DomyosBridge", comparison::StartsWith);
}
deviceType get_expectedDeviceType() const override { return deviceType::DomyosRower; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<domyosrower*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,49 +0,0 @@
#include "domyostreadmilltestdata.h"
#include "devices/domyostreadmill/domyostreadmill.h"
#include "Devices/DomyosElliptical/domyosellipticaltestdata.h"
#include "Devices/DomyosRower/domyosrowertestdata.h"
#include "Devices/DomyosBike/domyosbiketestdata.h"
#include "Devices/HorizonTreadmill/horizontreadmilltestdata.h"
#include "Devices/FTMSBike/ftmsbiketestdata.h"
DomyosTreadmillTestData::DomyosTreadmillTestData() : TreadmillTestData("Domyos Treadmill") {
this->addDeviceName("Domyos", comparison::StartsWith);
this->addInvalidDeviceName("DomyosBr", comparison::StartsWith);
}
void DomyosTreadmillTestData::configureExclusions() {
this->exclude(new DomyosEllipticalTestData());
this->exclude(new DomyosBikeTestData());
this->exclude(new DomyosRowerTestData());
this->exclude(new HorizonTreadmillTestData());
this->exclude(new HorizonTreadmillToorxTestData());
this->exclude(new HorizonTreadmillBodyToneTestData());
this->exclude(new HorizonTreadmillDomyosTCTestData());
this->exclude(new FTMSBike1TestData());
this->exclude(new FTMSBike2TestData());
this->exclude(new FTMSBike3TestData());
this->exclude(new FTMSBike4TestData());
}
deviceType DomyosTreadmillTestData::get_expectedDeviceType() const { return deviceType::DomyosTreadmill; }
bool DomyosTreadmillTestData::get_isExpectedDevice(bluetoothdevice *detectedDevice) const {
return dynamic_cast<domyostreadmill*>(detectedDevice)!=nullptr;
}
void DomyosTreadmillTestData::configureBluetoothDeviceInfos(const QBluetoothDeviceInfo &info, bool enable, std::vector<QBluetoothDeviceInfo> &bluetoothDeviceInfos) const {
if(enable) return;
// Should not be identified if it has 0x1826
auto result = info;
result.setServiceUuids(QVector<QBluetoothUuid>({QBluetoothUuid((quint16)0x1826)}));
bluetoothDeviceInfos.push_back(result);
}

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
class DomyosTreadmillTestData : public TreadmillTestData {
protected:
void configureBluetoothDeviceInfos(const QBluetoothDeviceInfo& info, bool enable, std::vector<QBluetoothDeviceInfo>& bluetoothDeviceInfos) const override;
public:
DomyosTreadmillTestData();
void configureExclusions() override;
deviceType get_expectedDeviceType() const override;
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override;
};

View File

@@ -1,22 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/eslinkertreadmill/eslinkertreadmill.h"
class ESLinkerTreadmillTestData : public TreadmillTestData {
public:
ESLinkerTreadmillTestData(): TreadmillTestData("ES Linker Treadmill") {
this->addDeviceName("ESLINKER", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::ESLinkerTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<eslinkertreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,26 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "Devices/EchelonRower/echelonrowertestdata.h"
#include "Devices/EchelonStrideTreadmill/echelonstridetreadmilltestdata.h"
#include "devices/echelonconnectsport/echelonconnectsport.h"
class EchelonConnectSportBikeTestData : public BikeTestData {
public:
EchelonConnectSportBikeTestData() : BikeTestData("Echelon Connect Sport Bike") {
this->addDeviceName("ECH", comparison::StartsWith);
}
void configureExclusions() override {
this->exclude(new EchelonRowerTestData());
this->exclude(new EchelonStrideTreadmillTestData());
}
deviceType get_expectedDeviceType() const override { return deviceType::EchelonConnectSport; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<echelonconnectsport*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,24 +0,0 @@
#pragma once
#include "Devices/Rower/rowertestdata.h"
#include "devices/echelonrower/echelonrower.h"
class EchelonRowerTestData : public RowerTestData {
public:
EchelonRowerTestData() : RowerTestData("Echelon Rower") {
this->addDeviceName("ECH-ROW", comparison::StartsWith);
this->addDeviceName("ROWSPORT-", comparison::StartsWithIgnoreCase);
this->addDeviceName("ROW-S", comparison::StartsWith);
}
deviceType get_expectedDeviceType() const override { return deviceType::EchelonRower; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<echelonrower*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,22 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/echelonstride/echelonstride.h"
class EchelonStrideTreadmillTestData : public TreadmillTestData {
public:
EchelonStrideTreadmillTestData() : TreadmillTestData("Echelon Stride Treadmill") {
this->addDeviceName("ECH-STRIDE", comparison::StartsWithIgnoreCase);
this->addDeviceName("ECH-UK-", comparison::StartsWithIgnoreCase);
this->addDeviceName("ECH-SD-SPT", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::EchelonStride; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<echelonstride*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,23 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/elitesterzosmart/elitesterzosmart.h"
class EliteSterzoSmartTestData : public BikeTestData {
public:
EliteSterzoSmartTestData() : BikeTestData("Elite Sterzo Smart") {}
QStringList get_deviceNames() const override {
QStringList result;
return result;
}
deviceType get_expectedDeviceType() const override { return deviceType::EliteSterzoSmart; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<elitesterzosmart*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,17 +0,0 @@
#pragma once
#include "Devices/bluetoothdevicetestdata.h"
#include "devices/elliptical.h"
class EllipticalTestData : public BluetoothDeviceTestData {
public:
EllipticalTestData(std::string deviceName) : BluetoothDeviceTestData(deviceName) {}
deviceType get_expectedDeviceType() const override { return deviceType::None; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<elliptical*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,10 +0,0 @@
#include "ftmsbiketestdata.h"
void FTMSBikeTestData::configureExclusions() {
this->exclude(new SnodeBike1TestData());
this->exclude(new SnodeBike2TestData());
this->exclude(new FitPlusBikeFSTestData());
this->exclude(new FitPlusBikeMRKTestData());
this->exclude(new StagesBike1TestData());
this->exclude(new StagesBike2TestData());
}

View File

@@ -1,119 +0,0 @@
#pragma once
#include <QVector>
#include "Devices/Bike/biketestdata.h"
#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:
void configureExclusions() override;
FTMSBikeTestData(std::string testName) : BikeTestData(testName) {
}
public:
deviceType get_expectedDeviceType() const override { return deviceType::FTMSBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<ftmsbike*>(detectedDevice)!=nullptr;
}
};
class FTMSBike1TestData : public FTMSBikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.hammerRacerS = enable;
return true;
}
public:
FTMSBike1TestData() : FTMSBikeTestData("FTMS Bike Hammer Racer S") {
this->addDeviceName("FS-", comparison::StartsWith);
}
};
class FTMSBike2TestData : public FTMSBikeTestData {
public:
FTMSBike2TestData() : FTMSBikeTestData("FTMS Bike") {
this->addDeviceName("DHZ-", comparison::StartsWithIgnoreCase); // JK fitness 577
this->addDeviceName("MKSM", comparison::StartsWithIgnoreCase); // MKSM3600036
this->addDeviceName("YS_C1_", comparison::StartsWithIgnoreCase);// Yesoul C1H
this->addDeviceName("YS_G1_", comparison::StartsWithIgnoreCase);// Yesoul S3
this->addDeviceName("DS25-", comparison::StartsWithIgnoreCase); // Bodytone DS25
this->addDeviceName("SCHWINN 510T", comparison::StartsWithIgnoreCase);
this->addDeviceName("ZWIFT HUB", comparison::StartsWithIgnoreCase);
this->addDeviceName("MAGNUS ", comparison::StartsWithIgnoreCase); // Saris Trainer
this->addDeviceName("FLXCY-", comparison::StartsWithIgnoreCase); // Pro FlexBike
this->addDeviceName("B94", comparison::StartsWithIgnoreCase);
this->addDeviceName("DBF135", comparison::IgnoreCase);
this->addDeviceName("STAGES BIKE", comparison::StartsWithIgnoreCase);
this->addDeviceName("SUITO", comparison::StartsWithIgnoreCase);
this->addDeviceName("D2RIDE", comparison::StartsWithIgnoreCase);
this->addDeviceName("DIRETO XR", comparison::StartsWithIgnoreCase);
this->addDeviceName("SMB1", comparison::StartsWithIgnoreCase);
this->addDeviceName("INRIDE", comparison::StartsWithIgnoreCase);
this->addDeviceName("XBR55", comparison::StartsWithIgnoreCase);
this->addDeviceName("EW-JS-", comparison::StartsWithIgnoreCase);
this->addDeviceName("HAMMER ", comparison::StartsWithIgnoreCase); // HAMMER 64123
this->addDeviceName("QB-WC01", comparison::StartsWithIgnoreCase);
// Starts with DT- and is 14+ characters long.
// TODO: update once addDeviceName can generate valid and invalid names for variable length patterns
this->addDeviceName("DT-0123456789A", comparison::IgnoreCase); // Sole SB700
this->addDeviceName("DT-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", comparison::IgnoreCase); // Sole SB700
this->addInvalidDeviceName("DT-0123456789", comparison::IgnoreCase); // too short for Sole SB700
this->addInvalidDeviceName("DBF13", comparison::IgnoreCase); // too short for DBF135
this->addInvalidDeviceName("DBF1355", comparison::IgnoreCase); // too long for DBF135
}
};
class FTMSBike3TestData : public FTMSBikeTestData {
private:
QString ftmsAccessoryName;
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.ss2k_peloton = enable;
if(enable)
info.ftmsAccessoryName = this->ftmsAccessoryName;
else
info.ftmsAccessoryName = "NOT "+this->ftmsAccessoryName;
return true;
}
public:
FTMSBike3TestData() : FTMSBikeTestData("FTMS Accessory") {
this->ftmsAccessoryName = "accessory";
this->addDeviceName(this->ftmsAccessoryName, comparison::StartsWithIgnoreCase);
}
};
class FTMSBike4TestData : public FTMSBikeTestData {
protected:
void configureBluetoothDeviceInfos(const QBluetoothDeviceInfo& info, bool enable, std::vector<QBluetoothDeviceInfo>& bluetoothDeviceInfos) const override {
auto result = info;
if(enable) {
result.setServiceUuids(QVector<QBluetoothUuid>({QBluetoothUuid((quint16)0x1826)}));
}
bluetoothDeviceInfos.push_back(result);
}
public:
FTMSBike4TestData() : FTMSBikeTestData("FTMS KICKR CORE") {
this->addDeviceName("KICKR CORE", comparison::StartsWithIgnoreCase); // KICKR CORE
}
};

View File

@@ -1,31 +0,0 @@
#pragma once
#include "Devices/Rower/rowertestdata.h"
#include "devices/ftmsrower/ftmsrower.h"
class FTMSRowerTestData : public RowerTestData {
public:
FTMSRowerTestData() : RowerTestData("FTMS Rower") {
this->addDeviceName("CR 00", comparison::StartsWithIgnoreCase);
this->addDeviceName("KAYAKPRO", comparison::StartsWithIgnoreCase);
this->addDeviceName("WHIPR", comparison::StartsWithIgnoreCase);
this->addDeviceName("KS-WLT", comparison::StartsWithIgnoreCase);
this->addDeviceName("I-ROWER", comparison::StartsWithIgnoreCase);
this->addDeviceName("PM5ROW", comparison::IgnoreCase);
this->addDeviceName("PM5XROW", comparison::IgnoreCase);
this->addDeviceName("SF-RW", comparison::IgnoreCase);
this->addDeviceName("S4 COMMS", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::FTMSRower; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<ftmsrower*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,27 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/fakebike/fakebike.h"
class FakeBikeTestData : public BikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.fake_bike = enable;
return true;
}
public:
FakeBikeTestData() : BikeTestData("Fake Bike"){
this->addDeviceName("", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::FakeBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<fakebike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,24 +0,0 @@
#pragma once
#include "Devices/Elliptical/ellipticaltestdata.h"
#include "devices/fakeelliptical/fakeelliptical.h"
class FakeEllipticalTestData : public EllipticalTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.fakedevice_elliptical = enable;
return true;
}
public:
FakeEllipticalTestData() : EllipticalTestData("Fake Elliptical") {
this->addDeviceName("", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::FakeElliptical; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<fakeelliptical*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,26 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/faketreadmill/faketreadmill.h"
class FakeTreadmillTestData : public TreadmillTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.fakedevice_treadmill = enable;
return true;
}
public:
FakeTreadmillTestData(): TreadmillTestData("Fake Treadmill") {
this->addDeviceName("", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::FakeTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<faketreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,12 +0,0 @@
#include "fitplusbiketestdata.h"
#include "Devices/FTMSBike/ftmsbiketestdata.h"
#include "Devices/SnodeBike/snodebiketestdata.h"
void FitPlusBikeMRKTestData::configureExclusions() {
this->exclude(new FTMSBike1TestData());
this->exclude(new FTMSBike2TestData());
this->exclude(new SnodeBike1TestData());
this->exclude(new SnodeBike2TestData());
}

View File

@@ -1,44 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/fitplusbike/fitplusbike.h"
class FitPlusBikeFSTestData : public BikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.fitplus_bike = enable;
return true;
}
public:
FitPlusBikeFSTestData() : BikeTestData("FitPlus Bike"){
this->addDeviceName("FS-", comparison::StartsWith);
}
deviceType get_expectedDeviceType() const override { return deviceType::FitPlusBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<fitplusbike*>(detectedDevice)!=nullptr;
}
};
class FitPlusBikeMRKTestData : public BikeTestData {
public:
FitPlusBikeMRKTestData() : BikeTestData("FitPlus Bike (MRK, no settings)"){
this->addDeviceName("MRK-", comparison::StartsWith);
}
void configureExclusions() override;
deviceType get_expectedDeviceType() const override { return deviceType::FitPlusBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<fitplusbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,79 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/fitshowtreadmill/fitshowtreadmill.h"
#include "Devices/FTMSBike/ftmsbiketestdata.h"
class FitshowTreadmillTestData : public TreadmillTestData {
protected:
FitshowTreadmillTestData(std::string testName) : TreadmillTestData(testName) {
}
public:
deviceType get_expectedDeviceType() const override { return deviceType::FitshowTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<fitshowtreadmill*>(detectedDevice)!=nullptr;
}
};
class FitshowTreadmillFSTestData : public FitshowTreadmillTestData {
protected:
void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const override {
DeviceDiscoveryInfo config(info);
if(enable){
config.snode_bike = false;
config.fitplus_bike = false;
configurations.push_back(config);
} else {
for(int i=1; i<4; i++) {
config.snode_bike = i&1;
config.fitplus_bike = i&2;
configurations.push_back(config);
}
}
}
public:
FitshowTreadmillFSTestData() : FitshowTreadmillTestData("FitShow FS") {
this->addDeviceName("FS-", comparison::StartsWith);
}
void configureExclusions() override {
this->exclude(new FTMSBike1TestData());
this->exclude(new FTMSBike2TestData());
}
};
class FitshowTreadmillSWTestData : public FitshowTreadmillTestData {
public:
FitshowTreadmillSWTestData(): FitshowTreadmillTestData("FitShow SW") {
// SW, 14 characters total
this->addDeviceName("SW345678901234", comparison::Exact);
this->addDeviceName("SWFOURTEENCHAR", comparison::Exact);
this->addDeviceName("WINFITA", comparison::StartsWithIgnoreCase);
this->addDeviceName("NOBLEPRO CONNECT", comparison::StartsWithIgnoreCase);
// too long and too short
this->addInvalidDeviceName("SW3456789012345", comparison::Exact);
this->addInvalidDeviceName("SW34567890123", comparison::Exact);
}
};
class FitshowTreadmillBFTestData : public FitshowTreadmillTestData {
public:
FitshowTreadmillBFTestData() : FitshowTreadmillTestData("FitShow BF"){
this->addDeviceName("BF70", comparison::StartsWith);
}
};

View File

@@ -1,44 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/flywheelbike/flywheelbike.h"
class FlywheelBikeTestData : public BikeTestData {
protected:
FlywheelBikeTestData(std::string testName) : BikeTestData(testName) {
}
public:
deviceType get_expectedDeviceType() const override { return deviceType::FlywheelBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<flywheelbike*>(detectedDevice)!=nullptr;
}
};
class FlywheelBike1TestData : public FlywheelBikeTestData {
public:
FlywheelBike1TestData() : FlywheelBikeTestData("Flywheel Bike") {
this->addDeviceName("Flywheel", comparison::StartsWith);
}
};
class FlywheelBike2TestData : public FlywheelBikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.flywheel_life_fitness_ic8 = enable;
return true;
}
public:
FlywheelBike2TestData() : FlywheelBikeTestData("Flywheel Life Fitness IC8") {
// BIKE 1, BIKE 2, BIKE 3...
this->addDeviceName("BIKE", comparison::StartsWithIgnoreCase, 6);
}
};

View File

@@ -1,27 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/focustreadmill/focustreadmill.h"
class FocusTreadmillTestData : public TreadmillTestData {
protected:
void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const override {
DeviceDiscoveryInfo config(info);
}
public:
FocusTreadmillTestData() : TreadmillTestData("Focus Treadmill") {
this->addDeviceName("EW-TM-", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::FocusTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<focustreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,22 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/horizongr7bike/horizongr7bike.h"
class HorizonGR7BikeTestData : public BikeTestData {
public:
HorizonGR7BikeTestData() : BikeTestData("Horizon GR7 Bike") {
this->addDeviceName("JFIC", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::HorizonGr7Bike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<horizongr7bike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,130 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/horizontreadmill/horizontreadmill.h"
class HorizonTreadmillTestData : public TreadmillTestData {
public:
HorizonTreadmillTestData() : TreadmillTestData("Horizon Treadmill") {
this->addDeviceName("HORIZON", comparison::StartsWithIgnoreCase);
this->addDeviceName("AFG SPORT", comparison::StartsWithIgnoreCase);
this->addDeviceName("WLT2541", comparison::StartsWithIgnoreCase);
// FTMS
this->addDeviceName("T318_", comparison::StartsWithIgnoreCase);
this->addDeviceName("T218_", comparison::StartsWithIgnoreCase);
this->addDeviceName("TRX3500", comparison::StartsWithIgnoreCase);
this->addDeviceName("JFTMPARAGON", comparison::StartsWithIgnoreCase);
this->addDeviceName("PARAGON X", comparison::StartsWithIgnoreCase);
this->addDeviceName("JFTM", comparison::StartsWithIgnoreCase);
this->addDeviceName("CT800", comparison::StartsWithIgnoreCase);
this->addDeviceName("MOBVOI TM", comparison::StartsWithIgnoreCase);
this->addDeviceName("DK202000725", comparison::StartsWithIgnoreCase);
this->addDeviceName("CTM780102C6BB32D62", comparison::StartsWithIgnoreCase);
this->addDeviceName("MX-TM ", comparison::StartsWithIgnoreCase);
this->addDeviceName("MATRIXTF50", comparison::StartsWithIgnoreCase);
this->addDeviceName("MOBVOI TM", comparison::StartsWithIgnoreCase);
this->addDeviceName("KETTLER TREADMILL", comparison::StartsWithIgnoreCase);
this->addDeviceName("ASSAULTRUNNER", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::HorizonTreadmill; }
bool get_isExpectedDevice(bluetoothdevice *detectedDevice) const override {
return dynamic_cast<horizontreadmill *>(detectedDevice) != nullptr;
}
};
class HorizonTreadmillToorxTestData : public TreadmillTestData {
void configureSettings(const DeviceDiscoveryInfo &info, bool enable,
std::vector<DeviceDiscoveryInfo> &configurations) const override {
DeviceDiscoveryInfo config(info);
if (enable) {
config.toorx_ftms_treadmill = true;
config.toorx_ftms = false;
configurations.push_back(config);
} else {
// Basic case where the device is disabled in the settings
config.toorx_ftms_treadmill = false;
config.toorx_ftms = false;
configurations.push_back(config);
// Basic case where the device is disabled in the settings and has an excluding settings
config.toorx_ftms_treadmill = false;
config.toorx_ftms = true;
configurations.push_back(config);
// Enabled in settings, but with excluding setting
config.toorx_ftms_treadmill = true;
config.toorx_ftms = true;
configurations.push_back(config);
}
}
public:
HorizonTreadmillToorxTestData() : TreadmillTestData("Horizon Treadmill (Toorx)") {
this->addDeviceName("TOORX", comparison::StartsWithIgnoreCase);
this->addDeviceName("I-CONSOLE+", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::HorizonTreadmill; }
bool get_isExpectedDevice(bluetoothdevice *detectedDevice) const override {
return dynamic_cast<horizontreadmill *>(detectedDevice) != nullptr;
}
};
class HorizonTreadmillBodyToneTestData : public TreadmillTestData {
void configureSettings(const DeviceDiscoveryInfo &info, bool enable,
std::vector<DeviceDiscoveryInfo> &configurations) const override {
DeviceDiscoveryInfo config(info);
if (enable) {
config.horizon_treadmill_force_ftms = true;
configurations.push_back(config);
} else {
// Basic case where the device is disabled in the settings
config.horizon_treadmill_force_ftms = false;
configurations.push_back(config);
}
}
public:
HorizonTreadmillBodyToneTestData() : TreadmillTestData("Horizon Treadmill (Bodytone)") {
this->addDeviceName("TF-", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::HorizonTreadmill; }
bool get_isExpectedDevice(bluetoothdevice *detectedDevice) const override {
return dynamic_cast<horizontreadmill *>(detectedDevice) != nullptr;
}
};
class HorizonTreadmillDomyosTCTestData : public TreadmillTestData {
protected:
void configureBluetoothDeviceInfos(const QBluetoothDeviceInfo& info, bool enable, std::vector<QBluetoothDeviceInfo>& bluetoothDeviceInfos) const override {
auto result = info;
if(enable) {
result.setServiceUuids(QVector<QBluetoothUuid>({QBluetoothUuid((quint16)0x1826)}));
}
bluetoothDeviceInfos.push_back(result);
}
public:
HorizonTreadmillDomyosTCTestData() : TreadmillTestData("Horizon Treadmill (Domyos TC)") {
this->addDeviceName("DOMYOS-TC", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::HorizonTreadmill; }
bool get_isExpectedDevice(bluetoothdevice *detectedDevice) const override {
return dynamic_cast<horizontreadmill *>(detectedDevice) != nullptr;
}
};

View File

@@ -1,21 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/inspirebike/inspirebike.h"
class InspireBikeTestData : public BikeTestData {
public:
InspireBikeTestData() : BikeTestData("Inspire Bike") {
this->addDeviceName("IC", comparison::StartsWithIgnoreCase, 8);
}
deviceType get_expectedDeviceType() const override { return deviceType::InspireBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<inspirebike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,23 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/keepbike/keepbike.h"
class KeepBikeTestData : public BikeTestData {
public:
KeepBikeTestData() : BikeTestData("Keep Bike") {
this->addDeviceName("KEEP_BIKE_", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::KeepBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<keepbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,30 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "Devices/KingsmithR2Treadmill/kingsmithr2treadmilltestdata.h"
#include "devices/kingsmithr1protreadmill/kingsmithr1protreadmill.h"
class KingsmithR1ProTreadmillTestData : public TreadmillTestData {
protected:
void configureExclusions() override {
this->exclude(new KingsmithR2TreadmillTestData());
}
public:
KingsmithR1ProTreadmillTestData() : TreadmillTestData("Kingsmith R1 Pro Treadmill") {
this->addDeviceName("R1 PRO", comparison::StartsWithIgnoreCase);
this->addDeviceName("RE", comparison::IgnoreCase);
this->addDeviceName("KINGSMITH", comparison::StartsWithIgnoreCase);
this->addDeviceName("KS-H", comparison::StartsWithIgnoreCase);
this->addDeviceName("DYNAMAX", comparison::StartsWithIgnoreCase);
this->addDeviceName("WALKINGPAD", comparison::StartsWithIgnoreCase);
this->addDeviceName("KS-BLR", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::KingsmithR1ProTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<kingsmithr1protreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,41 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/kingsmithr2treadmill/kingsmithr2treadmill.h"
class KingsmithR2TreadmillTestData : public TreadmillTestData {
public:
KingsmithR2TreadmillTestData() : TreadmillTestData("Kingsmith R2 Treadmill") {
this->addDeviceName("KS-ST-K12PRO", comparison::StartsWithIgnoreCase);
// KingSmith Walking Pad R2
this->addDeviceName("KS-R1AC", comparison::StartsWithIgnoreCase);
this->addDeviceName("KS-HC-R1AA", comparison::StartsWithIgnoreCase);
this->addDeviceName("KS-HC-R1AC", comparison::StartsWithIgnoreCase);
// KingSmith Walking Pad X21
this->addDeviceName("KS-X21", comparison::StartsWithIgnoreCase);
this->addDeviceName("KS-HDSC-X21C", comparison::StartsWithIgnoreCase);
this->addDeviceName("KS-HDSY-X21C", comparison::StartsWithIgnoreCase);
this->addDeviceName("KS-NGCH-X21C", comparison::StartsWithIgnoreCase);
this->addDeviceName("KS-NACH-X21C", comparison::StartsWithIgnoreCase);
// KingSmith Walking Pad G1
this->addDeviceName("KS-NGCH-G1C", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::KingsmithR2Treadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<kingsmithr2treadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,23 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/lifefitnesstreadmill/lifefitnesstreadmill.h"
class LifeFitnessTreadmillTestData : public TreadmillTestData {
public:
LifeFitnessTreadmillTestData() : TreadmillTestData("Life Fitness Treadmill") {
this->addDeviceName("LF", comparison::StartsWithIgnoreCase, 18);
}
deviceType get_expectedDeviceType() const override { return deviceType::LifeFitnessTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<lifefitnesstreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,78 +0,0 @@
#include <QByteArray>
#include "m3ibiketestdata.h"
/**
* @brief hex2bytes Converts a hexadecimal string to bytes, 2 characters at a time.
* @param s An hexadecimal string e.g. "023F4A" to { 0x02, 0x3F, 0x4A }
*/
static QByteArray hex2bytes(const std::string& s)
{
QByteArray v;
for (size_t i = 0; i < s.length(); i +=2)
{
std::string slice(s, i, 2);
uint8_t value = std::stoul(slice, 0, 16);
v.append(value);
}
return v;
}
void M3IBikeTestData::configureBluetoothDeviceInfos(const QBluetoothDeviceInfo& info, bool enable, std::vector<QBluetoothDeviceInfo>& bluetoothDeviceInfos) const {
// The M3I bike detector looks into the manufacturer data.
QBluetoothDeviceInfo result = info;
if(!enable) {
result.setManufacturerData(1, QByteArray("Invalid manufacturer data."));
bluetoothDeviceInfos.push_back(result);
return;
}
int key=0;
result.setManufacturerData(key++, hex2bytes("02010639009F00000000000000000014008001"));
/*
// more data that has been supplied
result.setManufacturerData(key++, hex2bytes("02010639009F00000000000000000014008001"));
result.setManufacturerData(key++, hex2bytes("02010639009FBA000000020000000014008001"));
result.setManufacturerData(key++, hex2bytes("02010639009FBA000000020000000013008001"));
result.setManufacturerData(key++, hex2bytes("02010639009FBA000000020000000013008001"));
result.setManufacturerData(key++, hex2bytes("02010639009FBA000000020000000012008001"));
result.setManufacturerData(key++, hex2bytes("02010639009FBA000000020000000012008001"));
result.setManufacturerData(key++, hex2bytes("02010639009FBA000000000000000011008001"));
result.setManufacturerData(key++, hex2bytes("02010639009FBC000000020000000010008001"));
result.setManufacturerData(key++, hex2bytes("02010639009FBC000000020000000010008001"));
result.setManufacturerData(key++, hex2bytes("02010639009FBC00000002000000000F008001"));
result.setManufacturerData(key++, hex2bytes("02010639009FBC00000002000000000F008001"));
result.setManufacturerData(key++, hex2bytes("02010639009FBC00000002000000000E008001"));
result.setManufacturerData(key++, hex2bytes("02010639009FBC00000002000000000E008001"));
result.setManufacturerData(key++, hex2bytes("02010639009F0000000003000000000C000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FDD00000003000000000C000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FDD00000003000000000C000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FDD00000003000000000B000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FDD00000003000000000B000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FDD00000003000000000B000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FDD00000003000000000A000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FDD00000003000000000A000001"));
result.setManufacturerData(key++, hex2bytes("02010639009F0000000000000000000A000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FE8000000030000000009000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FE8000000030000000009000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FE8000000030000000009000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FE8000000030000000008000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FE8000000030000000008000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FE8000000030000000008000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FE8000000030000000007000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FE8000000030000000000000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FD3000000030000000000000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FD3000000030000000000000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FD3000000030000000000000001"));
result.setManufacturerData(key++, hex2bytes("02010639009FD3000000030000000000000001"));
*/
bluetoothDeviceInfos.push_back(result);
}

View File

@@ -1,26 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/m3ibike/m3ibike.h"
class M3IBikeTestData : public BikeTestData {
protected:
void configureBluetoothDeviceInfos(const QBluetoothDeviceInfo& info, bool enable, std::vector<QBluetoothDeviceInfo>& bluetoothDeviceInfos) const override;
public:
M3IBikeTestData() : BikeTestData("M3I Bike") {
this->addDeviceName("M3", comparison::StartsWith);
}
deviceType get_expectedDeviceType() const override { return deviceType::M3IBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<m3ibike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,23 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/mcfbike/mcfbike.h"
class MCFBikeTestData : public BikeTestData {
public:
MCFBikeTestData() : BikeTestData("MCF Bike") {
this->addDeviceName("MCF-", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::MCFBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<mcfbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,24 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/mepanelbike/mepanelbike.h"
class MepanelBikeTestData : public BikeTestData {
public:
MepanelBikeTestData() : BikeTestData("Mepanel Bike") {
this->addDeviceName("MEPANEL", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::MepanelBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<mepanelbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,45 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/npecablebike/npecablebike.h"
class NPECableBikeTestData : public BikeTestData {
protected:
NPECableBikeTestData(std::string testName) : BikeTestData(testName) {}
public:
deviceType get_expectedDeviceType() const override { return deviceType::NPECableBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<npecablebike*>(detectedDevice)!=nullptr;
}
};
class NPECableBike1TestData : public NPECableBikeTestData {
public:
NPECableBike1TestData() : NPECableBikeTestData("NPE Cable Bike") {
this->addDeviceName(">CABLE", comparison::StartsWithIgnoreCase);
this->addDeviceName("MD", comparison::StartsWithIgnoreCase, 7);
}
};
class NPECableBike2TestData : public NPECableBikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
// don't allow this device if the Flywheel bike is enabled.
info.flywheel_life_fitness_ic8 = !enable;
return true;
}
public:
NPECableBike2TestData() : NPECableBikeTestData("NPECable (excluding Flywheel Life Fitness IC8)") {
// BIKE 1, BIKE 2, BIKE 3...
this->addDeviceName("BIKE", comparison::StartsWithIgnoreCase, 6);
// put in a name that's too long.
this->addInvalidDeviceName("BIKE567", comparison::IgnoreCase);
}
};

View File

@@ -1,21 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/nautilusbike/nautilusbike.h"
class NautilusBikeTestData : public BikeTestData {
public:
NautilusBikeTestData(): BikeTestData("Nautilus Bike") {
this->addDeviceName("NAUTILUS B", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::NautilusBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<nautilusbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/Elliptical/ellipticaltestdata.h"
#include "devices/nautiluselliptical/nautiluselliptical.h"
class NautilusEllipticalTestData : public EllipticalTestData {
public:
NautilusEllipticalTestData(): EllipticalTestData("Nautilus Elliptical") {
this->addDeviceName("NAUTILUS E", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::NautilusElliptical; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<nautiluselliptical*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,24 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/nautilustreadmill/nautilustreadmill.h"
class NautilusTreadmillTestData : public TreadmillTestData {
public:
NautilusTreadmillTestData() : TreadmillTestData("Nautilus Treadmill") {
this->addDeviceName("NAUTILUS T", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::NautilusTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<nautilustreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/Elliptical/ellipticaltestdata.h"
#include "devices/nordictrackelliptical/nordictrackelliptical.h"
class NordicTrackEllipticalTestData : public EllipticalTestData {
public:
NordicTrackEllipticalTestData() : EllipticalTestData("Nordictrack Elliptical") {
this->addDeviceName("I_EL", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::NordicTrackElliptical; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<nordictrackelliptical*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,31 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/nordictrackifitadbtreadmill/nordictrackifitadbtreadmill.h"
class NordicTrackIFitADBTreadmillTestData : public TreadmillTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
if(enable)
info.nordictrack_2950_ip = this->get_testIP();
else
info.nordictrack_2950_ip = QString();
return true;
}
public:
NordicTrackIFitADBTreadmillTestData() : TreadmillTestData("Nordictrack IFit ADB Treadmill") {
// Allow any name because it's not a bluetooth device
this->addDeviceName("", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::NordicTrackIFitADBTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<nordictrackifitadbtreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/Elliptical/ellipticaltestdata.h"
#include "devices/octaneelliptical/octaneelliptical.h"
class OctaneEllipticalTestData : public EllipticalTestData {
public:
OctaneEllipticalTestData() : EllipticalTestData("Octane Elliptical") {
this->addDeviceName("Q37", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::OctaneElliptical; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<octaneelliptical*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,24 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/octanetreadmill/octanetreadmill.h"
class OctaneTreadmillTestData : public TreadmillTestData {
public:
OctaneTreadmillTestData() : TreadmillTestData("Octane Treadmill") {
this->addDeviceName("ZR7", comparison::StartsWithIgnoreCase);
this->addDeviceName("ZR8", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::OctaneTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<octanetreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,26 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/pafersbike/pafersbike.h"
class PafersBikeTestData : public BikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
// the treadmill is given priority
info.pafers_treadmill = !enable;
return true;
}
public:
PafersBikeTestData() : BikeTestData("Pafers Bike") {
this->addDeviceName("PAFERS_", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::PafersBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<pafersbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,40 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/paferstreadmill/paferstreadmill.h"
class PafersTreadmillTestData : public TreadmillTestData {
protected:
void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const override {
DeviceDiscoveryInfo config(info);
if (enable) {
for(int x = 1; x<=3; x++) {
config.pafers_treadmill = x & 1;
config.pafers_treadmill_bh_iboxster_plus = x & 2;
configurations.push_back(config);
}
} else {
config.pafers_treadmill = false;
config.pafers_treadmill_bh_iboxster_plus = false;
configurations.push_back(config);
}
}
public:
PafersTreadmillTestData() : TreadmillTestData("Pafers Treadmill") {
this->addDeviceName("PAFERS_", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::PafersTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<paferstreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,23 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/proformbike/proformbike.h"
class ProFormBikeTestData : public BikeTestData {
public:
ProFormBikeTestData() : BikeTestData("ProForm Bike") {
this->addDeviceName("I_EB", comparison::StartsWith);
this->addDeviceName("I_SB", comparison::StartsWith);
}
deviceType get_expectedDeviceType() const override { return deviceType::ProformBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<proformbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,20 +0,0 @@
#pragma once
#include "Devices/Elliptical/ellipticaltestdata.h"
#include "devices/proformelliptical/proformelliptical.h"
class ProFormEllipticalTestData : public EllipticalTestData {
public:
ProFormEllipticalTestData() : EllipticalTestData("ProForm Elliptical") {
this->addDeviceName("I_FS", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::ProformElliptical; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<proformelliptical*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,18 +0,0 @@
#pragma once
#include "Devices/Elliptical/ellipticaltestdata.h"
#include "devices/proformellipticaltrainer/proformellipticaltrainer.h"
class ProFormEllipticalTrainerTestData : public EllipticalTestData {
public:
ProFormEllipticalTrainerTestData(): EllipticalTestData("ProForm Elliptical Trainer") {
this->addDeviceName("I_VE", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::ProformEllipticalTrainer; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<proformellipticaltrainer*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/Rower/rowertestdata.h"
#include "devices/proformrower/proformrower.h"
class ProFormRowerTestData : public RowerTestData {
public:
ProFormRowerTestData() : RowerTestData("ProForm Rower") {
this->addDeviceName("I_RW", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::ProformRower; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<proformrower*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,21 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/proformtreadmill/proformtreadmill.h"
class ProFormTreadmillTestData : public TreadmillTestData {
public:
ProFormTreadmillTestData(): TreadmillTestData("ProForm Treadmill") {
this->addDeviceName("I_TL", comparison::StartsWith);
}
deviceType get_expectedDeviceType() const override { return deviceType::ProformTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<proformtreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,27 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/proformwifibike/proformwifibike.h"
class ProFormWiFiBikeTestData : public BikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.proformtdf4ip = enable ? this->get_testIP():QString();
return true;
}
public:
ProFormWiFiBikeTestData(): BikeTestData("ProForm WiFi Bike") {
// any name
this->addDeviceName("", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::ProformWifiBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<proformwifibike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,27 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/proformwifitreadmill/proformwifitreadmill.h"
class ProFormWiFiTreadmillTestData : public TreadmillTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.proformtreadmillip = enable ? this->get_testIP():QString();
return true;
}
public:
ProFormWiFiTreadmillTestData() : TreadmillTestData("ProForm WiFi Treadmill") {
// any name
this->addDeviceName("", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::ProformWifiTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<proformwifitreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,8 +0,0 @@
#include "renphobiketestdata.h"
void RenphoBikeTestData::configureExclusions() {
this->exclude(new FitPlusBikeFSTestData());
this->exclude(new FitPlusBikeMRKTestData());
this->exclude(new SnodeBike1TestData());
this->exclude(new SnodeBike2TestData());
}

View File

@@ -1,48 +0,0 @@
#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:
RenphoBikeTestData(std::string testName) : BikeTestData(testName) {
}
void configureExclusions() override;
public:
deviceType get_expectedDeviceType() const override { return deviceType::RenphoBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<renphobike*>(detectedDevice)!=nullptr;
}
};
class RenphoBike1TestData : public RenphoBikeTestData {
public:
RenphoBike1TestData() : RenphoBikeTestData("Renpho Bike") {
this->addDeviceName("RQ", comparison::StartsWithIgnoreCase, 5);
this->addDeviceName("SCH130", comparison::StartsWithIgnoreCase);
}
};
class RenphoBike2TestData : public RenphoBikeTestData {
protected:
void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const override {
DeviceDiscoveryInfo config(info);
config.toorx_ftms = enable;
config.toorx_bike = true;
configurations.push_back(config);
config.toorx_ftms = enable;
config.toorx_bike = false;
configurations.push_back(config);
}
public:
RenphoBike2TestData() : RenphoBikeTestData("Renpho Bike (Toorx FTMS)"){
this->addDeviceName("TOORX", comparison::StartsWith);
}
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Devices/bluetoothdevicetestdata.h"
#include "devices/rower.h"
class RowerTestData : public BluetoothDeviceTestData {
public:
RowerTestData(std::string deviceName) : BluetoothDeviceTestData(deviceName) {}
deviceType get_expectedDeviceType() const override {
return deviceType::None; // abstract
}
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<rower*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,22 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/schwinn170bike/schwinn170bike.h"
class Schwinn170BikeTestData : public BikeTestData {
public:
Schwinn170BikeTestData() : BikeTestData("Schwinn 170 Bike") {
this->addDeviceName("SCHWINN 170/270", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::Schwinn170Bike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<schwinn170bike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,28 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/schwinnic4bike/schwinnic4bike.h"
class SchwinnIC4BikeTestData : public BikeTestData {
public:
SchwinnIC4BikeTestData() : BikeTestData("Schwinn IC4 Bike") {
this->addDeviceName("IC BIKE", comparison::StartsWithIgnoreCase);
this->addDeviceName("C7-", comparison::StartsWithIgnoreCase);
this->addDeviceName("C9/C10", comparison::StartsWithIgnoreCase);
// 17 characters, beginning with C7-
this->addInvalidDeviceName("C7-45678901234567", comparison::IgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::SchwinnIC4Bike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<schwinnic4bike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,21 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/shuaa5treadmill/shuaa5treadmill.h"
class Shuaa5TreadmillTestData : public TreadmillTestData {
public:
Shuaa5TreadmillTestData() : TreadmillTestData("Shuaa5 Treadmill") {
this->addDeviceName("ZW-", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::Shuaa5Treadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<shuaa5treadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,22 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/skandikawiribike/skandikawiribike.h"
class SkandikaWiryBikeTestData : public BikeTestData {
public:
SkandikaWiryBikeTestData() : BikeTestData("Skandika Wiry Bike") {
this->addDeviceName("BFCP", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::SkandikawiriBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<skandikawiribike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,25 +0,0 @@
#pragma once
#include "Devices/Rower/rowertestdata.h"
#include "devices/smartrowrower/smartrowrower.h"
class SmartRowRowerTestData : public RowerTestData {
public:
SmartRowRowerTestData() : RowerTestData("Smart Row Rower") {
this->addDeviceName("SMARTROW", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::SmartRowRower; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<smartrowrower*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,10 +0,0 @@
#include "snodebiketestdata.h"
#include "Devices/FitPlusBike/fitplusbiketestdata.h"
#include "Devices/FTMSBike/ftmsbiketestdata.h"
void SnodeBikeTestData::configureExclusions() {
this->exclude(new FitPlusBikeFSTestData());
this->exclude(new FitPlusBikeMRKTestData());
this->exclude(new FTMSBike1TestData());
this->exclude(new FTMSBike2TestData());
}

View File

@@ -1,54 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/snodebike/snodebike.h"
class SnodeBikeTestData : public BikeTestData {
protected:
SnodeBikeTestData(std::string testName) : BikeTestData(testName) { }
void configureExclusions() override;
public:
deviceType get_expectedDeviceType() const override { return deviceType::SnodeBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<snodebike*>(detectedDevice)!=nullptr;
}
};
class SnodeBike1TestData : public SnodeBikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.snode_bike = enable;
return true;
}
public:
SnodeBike1TestData() : SnodeBikeTestData("Snode Bike") {
this->addDeviceName("FS-", comparison::StartsWith);
}
};
class SnodeBike2TestData : public SnodeBikeTestData {
void configureSettings(const DeviceDiscoveryInfo &info, bool enable,
std::vector<DeviceDiscoveryInfo> &configurations) const override {
DeviceDiscoveryInfo config(info);
if (enable) {
config.horizon_treadmill_force_ftms = false;
configurations.push_back(config);
} else {
// Basic case where the device is disabled in the settings
config.horizon_treadmill_force_ftms = true;
configurations.push_back(config);
}
}
public:
SnodeBike2TestData() : SnodeBikeTestData("Snode Bike TF") {
this->addDeviceName("TF-", comparison::StartsWithIgnoreCase);
}
};

View File

@@ -1,23 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/solebike/solebike.h"
class SoleBikeTestData : public BikeTestData {
public:
SoleBikeTestData() : BikeTestData("Sole Bike") {
this->addDeviceName("LCB", comparison::StartsWithIgnoreCase);
this->addDeviceName("R92", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::SoleBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<solebike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,26 +0,0 @@
#pragma once
#include "Devices/Elliptical/ellipticaltestdata.h"
#include "devices/soleelliptical/soleelliptical.h"
class SoleEllipticalTestData : public EllipticalTestData {
public:
SoleEllipticalTestData(): EllipticalTestData("Sole Elliptical") {
this->addDeviceName("E95S", comparison::StartsWithIgnoreCase);
this->addDeviceName("E25", comparison::StartsWithIgnoreCase);
this->addDeviceName("E35", comparison::StartsWithIgnoreCase);
this->addDeviceName("E55", comparison::StartsWithIgnoreCase);
this->addDeviceName("E95", comparison::StartsWithIgnoreCase);
this->addDeviceName("E98", comparison::StartsWithIgnoreCase);
this->addDeviceName("XG400", comparison::StartsWithIgnoreCase);
this->addDeviceName("E98S", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::SoleElliptical; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<soleelliptical*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,53 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/solef80treadmill/solef80treadmill.h"
class SoleF80TreadmillTestData : public TreadmillTestData {
public:
SoleF80TreadmillTestData() : TreadmillTestData("Sole F80") {
this->addDeviceName("F65", comparison::StartsWithIgnoreCase);
this->addDeviceName("S77", comparison::StartsWithIgnoreCase);
this->addDeviceName("TT8", comparison::StartsWithIgnoreCase);
this->addDeviceName("F63", comparison::StartsWithIgnoreCase);
this->addDeviceName("ST90", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::SoleF80Treadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<solef80treadmill*>(detectedDevice)!=nullptr;
}
};
class SoleF85TreadmillTestData : public TreadmillTestData {
void configureSettings(const DeviceDiscoveryInfo &info, bool enable,
std::vector<DeviceDiscoveryInfo> &configurations) const override {
DeviceDiscoveryInfo config(info);
if (enable) {
config.sole_treadmill_inclination = true;
configurations.push_back(config);
} else {
// Basic case where the device is disabled in the settings
config.sole_treadmill_inclination = false;
configurations.push_back(config);
}
}
public:
SoleF85TreadmillTestData() : TreadmillTestData("Sole F85 Treadmill") {
this->addDeviceName("F85", comparison::StartsWithIgnoreCase);
this->addDeviceName("F89", comparison::StartsWithIgnoreCase);
this->addDeviceName("F80", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::SoleF80Treadmill; }
bool get_isExpectedDevice(bluetoothdevice *detectedDevice) const override {
return dynamic_cast<solef80treadmill *>(detectedDevice) != nullptr;
}
};

View File

@@ -1,26 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/spirittreadmill/spirittreadmill.h"
class SpiritTreadmillTestData : public TreadmillTestData {
public:
SpiritTreadmillTestData(): TreadmillTestData("Spirit Treadmill") {
this->addDeviceName("XT385", comparison::StartsWithIgnoreCase);
this->addDeviceName("XT485", comparison::StartsWithIgnoreCase);
this->addDeviceName("XT800", comparison::StartsWithIgnoreCase);
this->addDeviceName("XT900", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::SpiritTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<spirittreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,22 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/sportsplusbike/sportsplusbike.h"
class SportsPlusBikeTestData : public BikeTestData {
public:
SportsPlusBikeTestData() : BikeTestData("Sports Plus Bike") {
this->addDeviceName("CARDIOFIT", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::SportsPlusBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<sportsplusbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,22 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/sportstechbike/sportstechbike.h"
class SportsTechBikeTestData : public BikeTestData {
public:
SportsTechBikeTestData() : BikeTestData("Sport Tech Bike") {
this->addDeviceName("EW-BK", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::SportsTechBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<sportstechbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,8 +0,0 @@
#include "stagesbiketestdata.h"
#include "Devices/FTMSBike/ftmsbiketestdata.h"
void StagesBikeTestData::configureExclusions() {
this->exclude(new FTMSBike1TestData());
this->exclude(new FTMSBike2TestData());
}

View File

@@ -1,72 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/stagesbike/stagesbike.h"
class StagesBikeTestData : public BikeTestData {
protected:
StagesBikeTestData(std::string testName): BikeTestData(testName) {
}
void configureExclusions() override;
public:
deviceType get_expectedDeviceType() const override { return deviceType::StagesBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<stagesbike*>(detectedDevice)!=nullptr;
}
};
class StagesBike1TestData : public StagesBikeTestData {
public:
StagesBike1TestData() : StagesBikeTestData("Stages Bike") {
this->addDeviceName("STAGES ", comparison::StartsWithIgnoreCase);
this->addDeviceName("TACX SATORI", comparison::StartsWithIgnoreCase);
this->addDeviceName("QD", comparison::IgnoreCase);
}
};
class StagesBike2TestData : public StagesBikeTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.powerSensorName = enable ? "Disabled":"Roberto";
return true;
}
public:
StagesBike2TestData() : StagesBikeTestData("Stages Bike (Assioma / Power Sensor disabled") {
this->addDeviceName("ASSIOMA", comparison::StartsWithIgnoreCase);
}
};
class StagesBike3TestData : public StagesBikeTestData {
protected:
void configureBluetoothDeviceInfos(const QBluetoothDeviceInfo& info, bool enable, std::vector<QBluetoothDeviceInfo>& bluetoothDeviceInfos) const override {
// The condition, if the name is acceptable, is:
// !deviceHasService(b, QBluetoothUuid((quint16)0x1826)) && deviceHasService(b, QBluetoothUuid((quint16)0x1818)))
if(enable) {
QBluetoothDeviceInfo result = info;
result.setServiceUuids(QVector<QBluetoothUuid>({QBluetoothUuid((quint16)0x1818)}));
bluetoothDeviceInfos.push_back(result);
} else {
QBluetoothDeviceInfo hasInvalid = info;
hasInvalid.setServiceUuids(QVector<QBluetoothUuid>({QBluetoothUuid((quint16)0x1826)}));
QBluetoothDeviceInfo hasBoth = hasInvalid;
hasBoth.setServiceUuids(QVector<QBluetoothUuid>({QBluetoothUuid((quint16)0x1818),QBluetoothUuid((quint16)0x1826)}));
bluetoothDeviceInfos.push_back(info); // has neither
bluetoothDeviceInfos.push_back(hasInvalid);
bluetoothDeviceInfos.push_back(hasBoth);
}
}
public:
StagesBike3TestData() : StagesBikeTestData("Stages Bike (KICKR CORE)") {
this->addDeviceName("KICKR CORE", comparison::StartsWithIgnoreCase);
}
};

View File

@@ -1,99 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/strydrunpowersensor/strydrunpowersensor.h"
class StrydeRunPowerSensorTestData : public TreadmillTestData {
private:
QString powerSensorName;
protected:
void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const override {
if(enable) {
// power_as_treadmill enabled and powerSensorName in settings matches device name
DeviceDiscoveryInfo config(info);
config.power_as_treadmill = true;
config.powerSensorName = this->powerSensorName;
configurations.push_back(config);
} else {
// enabled but powerSensorName in settings does not match device name
DeviceDiscoveryInfo config(info);
config.power_as_treadmill = true;
config.powerSensorName = "NOT " +this->powerSensorName;
configurations.push_back(config);
// disabled with non-matching name
config.power_as_treadmill = false;
config.powerSensorName = "NOT " +this->powerSensorName;
configurations.push_back(config);
// disabled with matching name
config.power_as_treadmill = false;
config.powerSensorName = this->powerSensorName;
configurations.push_back(config);
}
}
public:
StrydeRunPowerSensorTestData() : TreadmillTestData("Stryderun Treadmill / Power Sensor") {
this->powerSensorName = "WattsItCalled-";
this->addDeviceName(this->powerSensorName, comparison::StartsWith);
}
deviceType get_expectedDeviceType() const override { return deviceType::PowerTreadmill_StrydrunPowerSensor; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<strydrunpowersensor*>(detectedDevice)!=nullptr;
}
};
class ZwiftRunpodTestData : public TreadmillTestData {
private:
QString powerSensorName;
protected:
void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const override {
DeviceDiscoveryInfo config(info);
if(enable) {
/* Avoid the config that enables the StrydeRunPowerSensorTestData device
// power_as_treadmill enabled and powerSensorName in settings matches device name
config.power_as_treadmill = true;
config.powerSensorName = this->powerSensorName;
configurations.push_back(config);
*/
/*
* In order for the search to occur, the power sensor name must start with "Disabled", or
* power_as_bike or power_as_treadmill must be true.
*/
config.power_as_treadmill = true;
config.powerSensorName = "NOT " + this->powerSensorName;
configurations.push_back(config);
config.power_as_treadmill = false;
config.powerSensorName = "Disabled";
configurations.push_back(config);
} else {
// disable the search
config.power_as_treadmill = false;
config.powerSensorName = this->powerSensorName;
config.power_as_bike = false;
configurations.push_back(config);
}
}
public:
ZwiftRunpodTestData() : TreadmillTestData("Zwift Runpod") {
this->powerSensorName = "WattsItCalled-";
this->addDeviceName("ZWIFT RUNPOD", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::PowerTreadmill_StrydrunPowerSensor; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<strydrunpowersensor*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,25 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/tacxneo2/tacxneo2.h"
class TacxNeo2TestData : public BikeTestData {
public:
TacxNeo2TestData() : BikeTestData("Tacx Neo 2 Bike") {
this->addDeviceName("TACX NEO", comparison::StartsWithIgnoreCase);
this->addDeviceName("TACX FLOW", comparison::StartsWithIgnoreCase);
this->addDeviceName("TACX SMART BIKE", comparison::StartsWithIgnoreCase);
this->addDeviceName("THINK X", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::TacxNeo2; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<tacxneo2*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,27 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/technogymmyruntreadmill/technogymmyruntreadmill.h"
class TechnoGymMyRunTreadmillTestData : public TreadmillTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.technogym_myrun_treadmill_experimental = !enable;
return true;
}
public:
TechnoGymMyRunTreadmillTestData() : TreadmillTestData("Technogym MyRun Treadmill") {
this->addDeviceName("MYRUN ", comparison::StartsWithIgnoreCase);
this->addDeviceName("MERACH-U3", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::TechnoGymMyRunTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<technogymmyruntreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,26 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/technogymmyruntreadmillrfcomm/technogymmyruntreadmillrfcomm.h"
class TechnogymMyRunTreadmillRFCommTestData : public TreadmillTestData {
protected:
bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const override {
info.technogym_myrun_treadmill_experimental = enable;
return true;
}
public:
TechnogymMyRunTreadmillRFCommTestData() : TreadmillTestData("Technogym MyRun Treadmill RF Comm") {
this->addDeviceName("MYRUN ", comparison::StartsWithIgnoreCase);
this->addDeviceName("MERACH-U3", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::TechnoGymMyRunTreadmillRfComm; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<technogymmyruntreadmillrfcomm*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,23 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/toorxtreadmill/toorxtreadmill.h"
class ToorxTreadmillTestData : public TreadmillTestData {
public:
ToorxTreadmillTestData() : TreadmillTestData("Toorx Treadmill") {
this->addDeviceName("TRX ROUTE KEY", comparison::StartsWith);
}
deviceType get_expectedDeviceType() const override { return deviceType::ToorxTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<toorxtreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,20 +0,0 @@
#pragma once
#include "Devices/bluetoothdevicetestdata.h"
#include "devices/treadmill.h"
class TreadmillTestData : public BluetoothDeviceTestData {
public:
TreadmillTestData(std::string deviceName): BluetoothDeviceTestData(deviceName) {}
deviceType get_expectedDeviceType() const override {
return deviceType::None; // abstract
}
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<treadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,24 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/truetreadmill/truetreadmill.h"
class TrueTreadmillTestData : public TreadmillTestData {
public:
TrueTreadmillTestData() : TreadmillTestData("True Treadmill") {
this->addDeviceName("TRUE", comparison::StartsWithIgnoreCase);
this->addDeviceName("TREADMILL", comparison::StartsWithIgnoreCase);
this->addDeviceName("ASSAULT TREADMILL ", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::TrueTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<truetreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,77 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "Devices/TrxAppGateUSBTreadmill/trxappgateusbtreadmilltestdata.h"
#include "devices/trxappgateusbbike/trxappgateusbbike.h"
class TrxAppGateUSBBikeTestData : public BikeTestData {
protected:
TrxAppGateUSBBikeTestData(std::string testName) : BikeTestData(testName) {
}
void configureExclusions() override {
this->exclude(new TrxAppGateUSBTreadmillTestData);
}
public:
deviceType get_expectedDeviceType() const override { return deviceType::TrxAppGateUSBBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<trxappgateusbbike*>(detectedDevice)!=nullptr;
}
};
class TrxAppGateUSBBike1TestData : public TrxAppGateUSBBikeTestData {
protected:
void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const override {
// This particular case of TrxAppGateUSBBike is independent of the setting
DeviceDiscoveryInfo config(info);
config.toorx_bike = true;
config.toorx_ftms_treadmill = !enable;
configurations.push_back(config);
config.toorx_bike = false;
config.toorx_ftms_treadmill = !enable;
configurations.push_back(config);
}
public:
TrxAppGateUSBBike1TestData() : TrxAppGateUSBBikeTestData("Toorx AppGate USB Bike") {
this->addDeviceName("TUN ", comparison::StartsWithIgnoreCase);
this->addDeviceName("PASYOU-", comparison::StartsWithIgnoreCase);
}
};
class TrxAppGateUSBBike2TestData : public TrxAppGateUSBBikeTestData {
protected:
void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const override {
DeviceDiscoveryInfo config(info);
if(enable) {
config.toorx_bike = true;
config.toorx_ftms_treadmill = false;
configurations.push_back(config);
} else {
config.toorx_bike = false;
config.toorx_ftms_treadmill = true;
configurations.push_back(config);
config.toorx_bike = false;
config.toorx_ftms_treadmill = false;
configurations.push_back(config);
}
}
public:
TrxAppGateUSBBike2TestData() : TrxAppGateUSBBikeTestData("Toorx AppGate USB Bike (enabled in settings)") {
this->addDeviceName("TOORX", comparison::StartsWith);
this->addDeviceName("I-CONSOIE+", comparison::StartsWithIgnoreCase) ;
this->addDeviceName("I-CONSOLE+", comparison::StartsWithIgnoreCase) ;
this->addDeviceName("IBIKING+", comparison::StartsWithIgnoreCase) ;
this->addDeviceName("ICONSOLE+", comparison::StartsWithIgnoreCase) ;
this->addDeviceName("VIFHTR2.1", comparison::StartsWithIgnoreCase) ;
this->addDeviceName("DKN MOTION", comparison::StartsWithIgnoreCase);
this->addDeviceName("CR011R", comparison::IgnoreCase);
}
};

View File

@@ -1,35 +0,0 @@
#pragma once
#include "Devices/Elliptical/ellipticaltestdata.h"
#include "devices/trxappgateusbelliptical/trxappgateusbelliptical.h"
class TrxAppGateUSBEllipticalTestData : public EllipticalTestData {
/*
TODO
protected:
void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const override {
DeviceDiscoveryInfo config(info);
if(enable) {
config.ftms_bike = "Disabled";
configurations.push_back(config);
} else {
config.ftms_bike = "PLACEHOLDER";
configurations.push_back(config);
}
}
*/
public:
TrxAppGateUSBEllipticalTestData() : EllipticalTestData("TrxAppGateUSB Elliptical") {
this->addDeviceName("FAL-SPORTS", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::TrxAppGateUSBElliptical; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<trxappgateusbelliptical*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,21 +0,0 @@
#include "trxappgateusbtreadmilltestdata.h"
#include "Devices/TrxAppGateUSBBike/trxappgateusbbiketestdata.h"
void TrxAppGateUSBTreadmillTestData::configureExclusions() {
this->exclude(new TrxAppGateUSBBike1TestData());
this->exclude(new TrxAppGateUSBBike2TestData());
}
TrxAppGateUSBTreadmillTestData::TrxAppGateUSBTreadmillTestData() : TreadmillTestData("Toorx AppGate USB Treadmill") {
this->addDeviceName("TOORX", comparison::StartsWith);
this->addDeviceName("V-RUN", comparison::StartsWith);
this->addDeviceName("K80_", comparison::StartsWithIgnoreCase);
this->addDeviceName("I-CONSOLE+", comparison::StartsWithIgnoreCase);
this->addDeviceName("ICONSOLE+", comparison::StartsWithIgnoreCase);
this->addDeviceName("I-RUNNING", comparison::StartsWithIgnoreCase);
this->addDeviceName("DKN RUN", comparison::StartsWithIgnoreCase);
this->addDeviceName("REEBOK", comparison::StartsWithIgnoreCase);
}

View File

@@ -1,36 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/trxappgateusbtreadmill/trxappgateusbtreadmill.h"
class TrxAppGateUSBTreadmillTestData : public TreadmillTestData {
protected:
void configureExclusions() override;
void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const override {
DeviceDiscoveryInfo config(info);
if(enable) {
config.toorx_bike = false;
config.toorx_ftms_treadmill = false;
configurations.push_back(config);
} else {
for(int i=1; i<4; i++) {
config.toorx_bike = i&1;
config.toorx_ftms_treadmill = i&2;
configurations.push_back(config);
}
}
}
public:
TrxAppGateUSBTreadmillTestData();
deviceType get_expectedDeviceType() const override { return deviceType::TrxAppGateUSBTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<trxappgateusbtreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,22 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/ultrasportbike/ultrasportbike.h"
class UltrasportBikeTestData : public BikeTestData {
public:
UltrasportBikeTestData() : BikeTestData("Ultrasport Bike") {
this->addDeviceName("X-BIKE", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::UltraSportBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<ultrasportbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,25 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/wahookickrsnapbike/wahookickrsnapbike.h"
class WahooKickrSnapBikeTestData : public BikeTestData {
public:
WahooKickrSnapBikeTestData() : BikeTestData("Wahoo Kickr Snap Bike") {
this->addDeviceName("KICKR SNAP", comparison::StartsWithIgnoreCase);
this->addDeviceName("KICKR BIKE", comparison::StartsWithIgnoreCase);
this->addDeviceName("KICKR ROLLR", comparison::StartsWithIgnoreCase);
this->addDeviceName("WAHOO KICKR", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::WahooKickrSnapBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<wahookickrsnapbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,22 +0,0 @@
#pragma once
#include "Devices/Bike/biketestdata.h"
#include "devices/yesoulbike/yesoulbike.h"
class YesoulBikeTestData : public BikeTestData {
public:
YesoulBikeTestData() : BikeTestData("Yesoul Bike") {
this->addDeviceName(yesoulbike::bluetoothName, comparison::StartsWith);
}
deviceType get_expectedDeviceType() const override { return deviceType::YesoulBike; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<yesoulbike*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,22 +0,0 @@
#pragma once
#include "Devices/Elliptical/ellipticaltestdata.h"
#include "devices/ypooelliptical/ypooelliptical.h"
class YpooEllipticalTestData : public EllipticalTestData {
public:
YpooEllipticalTestData() : EllipticalTestData("Ypoo Elliptical") {
this->addDeviceName("YPOO-U3-", comparison::StartsWithIgnoreCase);
this->addDeviceName("SCH_590E", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::YpooElliptical; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<ypooelliptical*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,22 +0,0 @@
#pragma once
#include "Devices/Treadmill/treadmilltestdata.h"
#include "devices/ziprotreadmill/ziprotreadmill.h"
class ZiproTreadmillTestData : public TreadmillTestData {
public:
ZiproTreadmillTestData() : TreadmillTestData("Zipro Treadmill") {
this->addDeviceName("RZ_TREADMIL", comparison::StartsWithIgnoreCase);
}
deviceType get_expectedDeviceType() const override { return deviceType::ZiproTreadmill; }
bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const override {
return dynamic_cast<ziprotreadmill*>(detectedDevice)!=nullptr;
}
};

View File

@@ -1,129 +1,81 @@
#include "bluetoothdevicetestdata.h"
#include "devicetestdataindex.h"
QString BluetoothDeviceTestData::Name() const { return this->name; }
void BluetoothDeviceTestData::configureExclusions() {}
void BluetoothDeviceTestData::exclude(BluetoothDeviceTestData *testData) {
if(!this->configuringExclusions)
throw "Exclusions can only be specified from the configureExclusions method.";
this->exclusions.push_back(std::shared_ptr<BluetoothDeviceTestData>(testData));
DeviceTypeId BluetoothDeviceTestData::ExpectedDeviceType() const {
if(this->expectedDeviceType<0)
throw std::domain_error("Expected device not set");
return this->expectedDeviceType;
}
void BluetoothDeviceTestData::addDeviceName(const QString& deviceName, comparison cmp, uint8_t length) {
bool BluetoothDeviceTestData::IsEnabled() const { return this->enabled; }
int expectedLength = length < 0 ? 0:length;
QStringList newNames;
const QString BluetoothDeviceTestData::DisabledReason() const { return this->disabledReason; }
if(expectedLength==0 || expectedLength==deviceName.length())
newNames.append(deviceName);
const QString BluetoothDeviceTestData::SkippedReason() const { return this->skippedReason; }
if(cmp & comparison::StartsWith && (expectedLength==0 || expectedLength>deviceName.length())) {
QString pad = expectedLength==0 ? "X" : QString(expectedLength-deviceName.length(), 'X');
newNames.append(deviceName+pad);
bool BluetoothDeviceTestData::IsExpectedDevice(bluetoothdevice *device) const { return this->isExpectedDevice(device); }
const QStringList BluetoothDeviceTestData::Exclusions() const {
auto testData = DeviceTestDataIndex::WhereExpects(this->exclusions);
QString missing = "";
// first check that all the test data is there
for(const auto key : this->exclusions) {
if(!testData.contains(key))
missing += QString("%1 ").arg(key);
}
this->deviceNames.append(newNames);
if(cmp & comparison::IgnoreCase) {
addDifferentCasings(newNames, this->deviceNames);
} else {
addDifferentCasings(newNames, this->invalidDeviceNames);
if(missing.length()>0) {
QString message = QString("Failed to find test data for excluded ids: ")+missing;
throw std::domain_error(message.toStdString());
}
QStringList result;
for(const auto deviceTestData : testData.values())
result.append(deviceTestData->Name());
return result;
}
void BluetoothDeviceTestData::addDeviceName(const QString& deviceNameStartsWith, const QString& deviceNameEndsWith, comparison cmp) {
comparison modifiedComparison = (comparison)(cmp & ~comparison::StartsWith);
this->addDeviceName(deviceNameStartsWith+deviceNameEndsWith, modifiedComparison);
this->addDeviceName(deviceNameStartsWith+"XXX"+deviceNameEndsWith, modifiedComparison);
const DeviceNamePatternGroup *BluetoothDeviceTestData::NamePatternGroup() const { return this->deviceNamePatternGroup; }
BluetoothDeviceTestData::~BluetoothDeviceTestData(){
delete this->deviceNamePatternGroup;
}
void BluetoothDeviceTestData::addDifferentCasings(const QStringList& names, QStringList& target) {
for(auto name : names) {
QString newName = name.toUpper();
if(newName!=name)
target.append(newName);
BluetoothDeviceTestData::BluetoothDeviceTestData() {}
newName = name.toLower();
if(newName!=name)
target.append(newName);
}
}
void BluetoothDeviceTestData::configureSettings(const DeviceDiscoveryInfo &info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const { }
bool BluetoothDeviceTestData::configureSettings(DeviceDiscoveryInfo &info, bool enable) const { return false;}
BluetoothDeviceTestData::BluetoothDeviceTestData(std::string testName) {
this->testName = testName;
}
BluetoothDeviceTestData::~BluetoothDeviceTestData() {}
std::string BluetoothDeviceTestData::get_testName() const {
return this->testName;
}
bool BluetoothDeviceTestData::get_isAbstract() const { return false; }
void BluetoothDeviceTestData::addInvalidDeviceName(const QString& deviceName, comparison cmp){
QStringList newNames;
newNames.append(deviceName);
if(cmp & comparison::StartsWith)
newNames.append(deviceName+"X");
this->invalidDeviceNames.append(newNames);
if(cmp & comparison::IgnoreCase) {
addDifferentCasings(newNames, this->invalidDeviceNames);
}
}
QStringList BluetoothDeviceTestData::get_deviceNames() const { return this->deviceNames;}
QStringList BluetoothDeviceTestData::get_failingDeviceNames() const { return this->invalidDeviceNames; }
std::vector<std::shared_ptr<BluetoothDeviceTestData> > BluetoothDeviceTestData::get_exclusions() {
if(!this->exclusionsConfigured) {
this->configuringExclusions = true;
this->configureExclusions();
this->exclusionsConfigured = true;
this->configuringExclusions = false;
}
return this->exclusions;
}
std::vector<DeviceDiscoveryInfo> BluetoothDeviceTestData::get_configurations(const DeviceDiscoveryInfo &info, bool enable) {
std::vector<DeviceDiscoveryInfo> BluetoothDeviceTestData::ApplyConfigurations(const DeviceDiscoveryInfo &info, bool enable) const {
std::vector<DeviceDiscoveryInfo> result;
DeviceDiscoveryInfo newInfo(info);
if(this->configureSettings(newInfo, enable))
auto name = info.DeviceName();
if(this->applicatorSingle)
{
DeviceDiscoveryInfo newInfo(info);
this->applicatorSingle(newInfo, enable);
result.push_back(newInfo);
}
this->configureSettings(info, enable, result);
if(this->applicatorMultiple) {
auto count = result.size();
this->applicatorMultiple(info, enable, result);
//if(result.size()<=count)
// throw std::domain_error("No configurations added. Please check the lambda is accepting the vector by address.");
}
for(auto config : result) {
if(config.DeviceName()!=name)
throw std::domain_error("Settings applicator changed the BT name.");
}
return result;
}
QString BluetoothDeviceTestData::get_testIP() const { return "1.2.3.4"; }
std::vector<QBluetoothDeviceInfo> BluetoothDeviceTestData::get_bluetoothDeviceInfo(const QBluetoothUuid &uuid, const QString &name, bool valid) {
std::vector<QBluetoothDeviceInfo> result;
QBluetoothDeviceInfo info(uuid, name, 0);
this->configureBluetoothDeviceInfos(info, valid, result);
// make sure there is always a valid item
if(valid && result.empty())
result.push_back(info);
return result;
}

View File

@@ -1,266 +1,96 @@
#pragma once
#include "devices/bluetoothdevice.h"
#include <QStringList>
#include <vector>
#include <memory>
#include <unordered_set>
#include <QString>
#include <QBluetoothDeviceInfo>
#include "bluetoothdevice.h"
#include "devicenamepatterngroup.h"
#include "devicediscoveryinfo.h"
#include "Tools/devicetypeid.h"
/**
* @brief Device type supported by the application.
* NOTE: Not ultimately used for anything currently. This was originally made as part of a plan to split device discovery
* into two sections, detection, which returns one of these enum values, and creation, which creates the bluetoothdevice object.
* The test data classes still have a function that returns one of these. This has been left here for reuse in a possible future refactoring
* of device detection.
*/
enum deviceType {
None,
ApexBike,
BkoolBike,
M3IBike,
FakeBike,
FakeElliptical,
FakeTreadmill,
ProformWifiBike,
ProformWifiTreadmill,
NordicTrackIFitADBTreadmill,
NordicTrackIFitADBBike,
CSCBike,
PowerBike_Stages,
PowerTreadmill_StrydrunPowerSensor,
DomyosRower,
DomyosBike,
DomyosElliptical,
NautilusElliptical,
NautilusBike,
ProformElliptical,
NordicTrackElliptical,
ProformEllipticalTrainer,
ProformRower,
BHFitnessElliptical,
SoleElliptical,
DomyosTreadmill,
KingsmithR2Treadmill,
KingsmithR1ProTreadmill,
Shuaa5Treadmill,
TrueTreadmill,
SoleF80Treadmill,
HorizonTreadmill,
TechnoGymMyRunTreadmill,
TechnoGymMyRunTreadmillRfComm,
TacxNeo2,
NPECableBike,
FTMSBike,
WahooKickrSnapBike,
HorizonGr7Bike,
StagesBike,
SmartRowRower,
Concept2SkiErg,
FTMSRower,
EchelonStride,
OctaneElliptical,
OctaneTreadmill,
EchelonRower,
EchelonConnectSport,
SchwinnIC4Bike,
Schwinn170Bike,
SportsTechBike,
SportsPlusBike,
YesoulBike,
ProformBike,
ProformTreadmill,
ESLinkerTreadmill,
PafersTreadmill,
BowflexT216Treadmill,
NautilusTreadmill,
FlywheelBike,
MCFBike,
ToorxTreadmill,
IConceptBike,
IConceptElliptical,
SpiritTreadmill,
ActivioTreadmill,
TrxAppGateUSBTreadmill,
TrxAppGateUSBBike,
UltraSportBike,
KeepBike,
SoleBike,
SkandikawiriBike,
RenphoBike,
PafersBike,
SnodeBike,
FitPlusBike,
FitshowTreadmill,
InspireBike,
ChronoBike,
MepanelBike,
LifeFitnessTreadmill,
YpooElliptical,
ZiproTreadmill,
CompuTrainerBike,
FocusTreadmill,
TrxAppGateUSBElliptical,
};
typedef std::function<void(const DeviceDiscoveryInfo &info, bool enable, std::vector<DeviceDiscoveryInfo> &configurations)> ConfigurationApplicatorMultiple;
typedef std::function<void(DeviceDiscoveryInfo &info, bool enable)> ConfigurationApplicatorSingle;
class BluetoothDeviceTestData;
typedef std::shared_ptr<BluetoothDeviceTestData> BluetoothDeviceTestData_ptr;
typedef std::vector<BluetoothDeviceTestData_ptr> BluetoothDeviceTestDataVector;
class BluetoothDeviceTestData {
std::vector<std::shared_ptr<BluetoothDeviceTestData>> exclusions;
QStringList deviceNames;
QStringList invalidDeviceNames;
bool exclusionsConfigured = false;
bool configuringExclusions = false;
std::string testName;
class BluetoothDeviceTestData
{
protected:
bool enabled = true;
bool skipped = false;
QString disabledReason = nullptr;
QString skippedReason = nullptr;
QString name = nullptr;
/**
* @brief Indicates how bluetooth device names should be compared.
*/
enum comparison : int {
Exact = 0,
IgnoreCase = 1,
StartsWith = 2,
StartsWithIgnoreCase = IgnoreCase+StartsWith
};
/**
* @brief Call exclude(...) to populate the exclusions vector. This vector is populated on demand
* to avoid circularities in the constructors.
*/
virtual void configureExclusions();
void exclude(BluetoothDeviceTestData* testData);
/**
* @brief Add a device name that should be identified as this device.
* If the comparison specified contains "starts with", then samples that start with the
* specified device name will be added. If a case sensitive comparison is specified,
* samples with invalid casing will be added to the invalid names list.
* @param deviceName
* @param length The expected length. Use 0 for unrestricted.
*/
void addDeviceName(const QString& deviceName, comparison cmp, uint8_t length=0);
/**
* @brief Add a device name as a prefix and suffix that should be identified as this device.
* If a case sensitive comparison is specified,
* samples with invalid casing will be added to the invalid names list.
* @param deviceName
*/
void addDeviceName(const QString& deviceNameStartsWith, const QString& deviceNameEndsWith, comparison cmp);
/**
* @brief Add a device name that should NOT be identified as this device.
* @param deviceName
*/
void addInvalidDeviceName(const QString& deviceName, comparison cmp);
/**
* @brief Add the specified device names with different casings.
* Used to provide device names to test case sensitivity or insensitivity.
* @param names
* @param target
*/
static void addDifferentCasings(const QStringList &names, QStringList &target);
/**
* @brief Configure multiple devicediscoveryinfo objects to either enable or disable the device in multiple ways.
* @param info
* @param enable
* @param configurations The variations of the provided object to test.
*/
virtual void configureSettings(const DeviceDiscoveryInfo& info, bool enable, std::vector<DeviceDiscoveryInfo>& configurations) const;
/**
* @brief Configure multiple QBluetoothDeviceInfo objects to either enable or disable the device in multiple ways.
* @info An initial object configured aith a name and UUID for copying. This is expceted to have no service UUIDs.
* @param enable Indicates if the request is for enabling (true) or disabling (false) configurations on the bluetooth device info.
* @param bluetoothDeviceInfos The objects to test.
*/
virtual void configureBluetoothDeviceInfos(const QBluetoothDeviceInfo& info, bool enable, std::vector<QBluetoothDeviceInfo>& bluetoothDeviceInfos) const {}
/**
* @brief Configure the devicediscoveryinfo object to either enable or disable the device.
* Used for where there is only 1 scenario.
* @param info
* @param enable
*/
virtual bool configureSettings(DeviceDiscoveryInfo& info, bool enable) const;
/**
* @brief Constructor
* @param testName A user-friendly name for the tested device, e.g. "SupaDupa Treadmill"
*/
BluetoothDeviceTestData(std::string testName);
std::unordered_set<DeviceTypeId> exclusions;
DeviceNamePatternGroup * deviceNamePatternGroup=nullptr;
ConfigurationApplicatorMultiple applicatorMultiple=nullptr;
ConfigurationApplicatorSingle applicatorSingle=nullptr;
std::function<bool(bluetoothdevice*)> isExpectedDevice=nullptr;
DeviceTypeId expectedDeviceType=-1;
BluetoothDeviceTestData();
public:
virtual ~BluetoothDeviceTestData();
/**
* @brief Gets the test name.
* @brief Gets the name of the device, or device variant.
* @return
*/
virtual std::string get_testName() const;
QString Name() const;
/**
* @brief Indicates if the test data is for an abstract class.
* @brief Gets a unique identifier
* @return
*/
virtual bool get_isAbstract() const;
DeviceTypeId ExpectedDeviceType() const;
/**
* @brief A list of bluetooth device names that should be recognised as this device.
*/
virtual QStringList get_deviceNames() const;
/**
* @brief A list of bluetooth device names that should NOT be recognised as this device.
* By default this is generated by modifying the result of get_deviceNames().
*/
virtual QStringList get_failingDeviceNames() const;
/**
* @brief Gets a list of BluetoothDeviceTestData objects for devices whose
* prior detection should prevent the detection of this device when an expected device name is found.
* @brief Indicates if the test data is enabled to be included in the test runs.
* @return
*/
virtual std::vector<std::shared_ptr<BluetoothDeviceTestData>> get_exclusions();
bool IsEnabled() const;
/**
* @brief Indicates if the test data should be included in test runs, but skipped.
* @return
*/
bool IsSkipped() const { return skipped; }
/**
* @brief Indicates the reason the test data is disabled.
* @return
*/
const QString DisabledReason() const;
/**
* @brief Indicates the reason the test data is skipped.
* @return
*/
const QString SkippedReason() const;
/**
* @brief Indicates if the object is of the expected type.
* @param device The device to check.
* @return
*/
bool IsExpectedDevice(bluetoothdevice * device) const;
/**
* @brief Gets a list of test data object names for devices that should prevent this test data object's expected device from being detected.
* @return
*/
const QStringList Exclusions() const;
/**
* @brief Gets the manager for the valid and invalid device names for this test data object.
* @return
*/
const DeviceNamePatternGroup * NamePatternGroup() const;
/**
* @brief Gets combinations of configurations beginning with the specified object.
* @param info
*/
virtual std::vector<DeviceDiscoveryInfo> get_configurations(const DeviceDiscoveryInfo& info, bool enable);
/**
* @brief Gets the expected device type enumeration value to be detected for this device.
*/
virtual deviceType get_expectedDeviceType() const =0;
/**
* @brief Determines if the specified bluetoothdevice* object is of the expected type for this device.
* @param detectedDevice
* @return
*/
virtual bool get_isExpectedDevice(bluetoothdevice * detectedDevice) const =0;
/**
* @brief Specifies a test IP address for wifi devices.
*/
virtual QString get_testIP() const;
/**
* @brief Gets a vector of QBluetoothDeviceInfo objects for the specified name and UUID. Can be used to
* generate valid and invalid objects where device identification relies on more than just the name.
* @param uuid
* @param name
* @param valid
*/
std::vector<QBluetoothDeviceInfo> get_bluetoothDeviceInfo(const QBluetoothUuid& uuid, const QString& name, bool valid=true);
std::vector<DeviceDiscoveryInfo> ApplyConfigurations(const DeviceDiscoveryInfo& info, bool enable) const;
virtual ~BluetoothDeviceTestData();
};

View File

@@ -0,0 +1,88 @@
#include "bluetoothdevicetestdatabuilder.h"
BluetoothDeviceTestDataBuilder::BluetoothDeviceTestDataBuilder(QString name) : BluetoothDeviceTestData() {
this->name = name;
this->deviceNamePatternGroup = new DeviceNamePatternGroup();
}
BluetoothDeviceTestDataBuilder *BluetoothDeviceTestDataBuilder::acceptDeviceNames(const QStringList &deviceNames, DeviceNameComparison cmp)
{
for(QString name : deviceNames)
this->acceptDeviceName(name, cmp);
return this;
}
BluetoothDeviceTestDataBuilder *BluetoothDeviceTestDataBuilder::acceptDeviceName(const QString &deviceName, DeviceNameComparison cmp, uint8_t length) {
this->deviceNamePatternGroup->addDeviceName(deviceName, cmp, length);
return this;
}
BluetoothDeviceTestDataBuilder *BluetoothDeviceTestDataBuilder::acceptDeviceName(const QString &deviceNameStartsWith, const QString &deviceNameEndsWith, DeviceNameComparison cmp) {
this->deviceNamePatternGroup->addDeviceName(deviceNameStartsWith, deviceNameEndsWith, cmp);
return this;
}
BluetoothDeviceTestDataBuilder *BluetoothDeviceTestDataBuilder::rejectDeviceName(const QString &deviceName, const DeviceNameComparison cmp) {
this->deviceNamePatternGroup->addInvalidDeviceName(deviceName, cmp);
return this;
}
BluetoothDeviceTestDataBuilder *BluetoothDeviceTestDataBuilder::configureSettingsWith(ConfigurationApplicatorMultiple applicator) {
if(this->applicatorMultiple || this->applicatorSingle)
throw std::invalid_argument("Only 1 configurator is supported.");
this->applicatorMultiple = applicator;
return this;
}
BluetoothDeviceTestDataBuilder *BluetoothDeviceTestDataBuilder::configureSettingsWith(ConfigurationApplicatorSingle applicator) {
if(this->applicatorMultiple || this->applicatorSingle)
throw std::invalid_argument("Only 1 configurator is supported.");
this->applicatorSingle = applicator;
return this;
}
BluetoothDeviceTestDataBuilder *BluetoothDeviceTestDataBuilder::configureSettingsWith(const QString &qzSettingsKey, bool enablingValue) {
return this->configureSettingsWith(qzSettingsKey, enablingValue, !enablingValue);
}
BluetoothDeviceTestDataBuilder *BluetoothDeviceTestDataBuilder::configureSettingsWith(const QString &qzSettingsKey, QVariant enablingValue, QVariant disablingValue) {
if(this->applicatorMultiple || this->applicatorSingle)
throw std::invalid_argument("Only 1 configurator is supported.");
if(enablingValue==disablingValue)
throw std::invalid_argument("Enabling and disabling values must be different.");
this->applicatorSingle = [qzSettingsKey, enablingValue, disablingValue](DeviceDiscoveryInfo& info, bool enable) -> void {
info.setValue(qzSettingsKey, enable ? enablingValue:disablingValue);
};
return this;
}
BluetoothDeviceTestDataBuilder *BluetoothDeviceTestDataBuilder::configureSettingsWith(const QBluetoothUuid &uuid, bool addedIsEnabled) {
this->applicatorSingle = [uuid,addedIsEnabled](DeviceDiscoveryInfo& info, bool enable) -> void {
if(enable==addedIsEnabled)
info.addBluetoothService(uuid);
else
info.removeBluetoothService(uuid);
};
return this;
}
BluetoothDeviceTestDataBuilder *BluetoothDeviceTestDataBuilder::excluding(std::initializer_list<DeviceTypeId> exclusions) {
this->exclusions.insert(exclusions);
return this;
}
BluetoothDeviceTestDataBuilder *BluetoothDeviceTestDataBuilder::disable(const QString& reason) {
this->enabled = false;
this->disabledReason = reason;
return this;
}
BluetoothDeviceTestDataBuilder *BluetoothDeviceTestDataBuilder::skip(const QString &reason) {
this->skipped = true;
this->skippedReason = reason;
return this;
}

View File

@@ -0,0 +1,145 @@
#pragma once
#include "bluetoothdevice.h"
#include "bluetoothdevicetestdata.h"
#include "devicetestdataindex.h"
/**
* @brief Extra functionality on a BluetoothDeviceTestData for configuring it.
*/
class BluetoothDeviceTestDataBuilder : public virtual BluetoothDeviceTestData
{
public:
/**
* @brief Constructor.
* @param name A user-friendly name for the device variant this test data is for. Should be unique for this object.
*/
BluetoothDeviceTestDataBuilder(QString name);
/**
* @brief Indicates the type of bluetoothdevice object that should be produced from the conditions defined in this object.
* @return
*/
template <class T>
BluetoothDeviceTestDataBuilder * expectDevice()
{
if(this->isExpectedDevice)
throw std::invalid_argument("Expected device already set.");
this->isExpectedDevice= [](bluetoothdevice * detectedDevice) -> bool { return dynamic_cast<T*>(detectedDevice)!=nullptr; };
this->expectedDeviceType = DeviceTestDataIndex::GetTypeId<T>();
// TODO enhance exclusion test to be able to distinguish instances rather than just type.
// // Exclude this type, i.e. don't redetect and recreate.
// this->excluding<T>();
return this;
}
/**
* @brief Add a list of device names that should be identified as this device.
* If the comparison specified contains "starts with", then samples that start with the
* specified device name will be added. If a case sensitive comparison is specified,
* samples with invalid casing will be added to the invalid names list.
* @param deviceNames
*/
BluetoothDeviceTestDataBuilder * acceptDeviceNames(const QStringList& deviceNames, DeviceNameComparison cmp);
/**
* @brief Add a device name that should be identified as this device.
* If the comparison specified contains "starts with", then samples that start with the
* specified device name will be added. If a case sensitive comparison is specified,
* samples with invalid casing will be added to the invalid names list.
* @param deviceName
* @param length The expected length. Use 0 for unrestricted.
*/
BluetoothDeviceTestDataBuilder * acceptDeviceName(const QString& deviceName, DeviceNameComparison cmp, uint8_t length=0);
/**
* @brief Add a device name as a prefix and suffix that should be identified as this device.
* If a case sensitive comparison is specified,
* samples with invalid casing will be added to the invalid names list.
* @param deviceName
*/
BluetoothDeviceTestDataBuilder * acceptDeviceName(const QString& deviceNameStartsWith, const QString& deviceNameEndsWith, DeviceNameComparison cmp);
/**
* @brief Add a device name that should NOT be identified as this device.
* @param deviceName
*/
BluetoothDeviceTestDataBuilder * rejectDeviceName(const QString& deviceName, const DeviceNameComparison cmp);
/**
* @brief Sets a generator for multiple enabling or disabling settings configurations.
* @param applicator
* @return
*/
BluetoothDeviceTestDataBuilder * configureSettingsWith(ConfigurationApplicatorMultiple applicator);
/**
* @brief Sets a functor to produce the single enabling or disabling settings configuration.
* @param applicator
* @return
*/
BluetoothDeviceTestDataBuilder * configureSettingsWith(ConfigurationApplicatorSingle applicator);
/**
* @brief Specifies that a single boolean setting is used to generate an enabling or
* disabling configuration.
* @param qzSettingsKey The settings key to alter.
* @param enabledValue The value of the setting that indicates an enabling configuration.
* @return
*/
BluetoothDeviceTestDataBuilder * configureSettingsWith(const QString& qzSettingsKey, bool enabledValue=true);
/**
* @brief Specifies that a single setting is used to generate an enabling or disabling configuration,
* and additionally specify the enabling value and disabling value, which must be different.
* @param qzSettingsKey The settings key to alter.
* @param enablingValue The value of the setting that indicates an enabling configuration.
* @param disablingValue The value of the setting that indicates a disabling configuration.
* @return
*/
BluetoothDeviceTestDataBuilder * configureSettingsWith(const QString &qzSettingsKey, QVariant enablingValue, QVariant disablingValue);
/**
* @brief Specifies that a single bluetooth service is used to generate an enabling or disabling configuration.
* @param uuid The UUID of the bluetooth service.
* @param addedIsEnabled Indicates what the presence of the service indicates.
* @return
*/
BluetoothDeviceTestDataBuilder * configureSettingsWith(const QBluetoothUuid &uuid, bool addedIsEnabled=true);
/**
* @brief Indicates that if a device of the types with the specified type ids is already recognised,
* this one should not be detected even if the other conditions are met.
* @param exclusions
* @return
*/
BluetoothDeviceTestDataBuilder * excluding(std::initializer_list<DeviceTypeId> exclusions);
/**
* @brief Indicates that if a device of the specified type is already recognised,
* this one should not be detected even if the other conditions are met.
* @return
*/
template<class T>
BluetoothDeviceTestDataBuilder * excluding() { return excluding({DeviceTestDataIndex::GetTypeId<T>()}); }
/**
* @brief Disable the test data, optionally stating a reason, and excluding it from any test reports.
* @param reason
* @return
*/
BluetoothDeviceTestDataBuilder * disable(const QString& reason=nullptr);
/**
* @brief Indicates that the test data should be included in tests, but skipped so it appears in reports as having been skipped,
* with an optional reason.
* @param reason
* @return
*/
BluetoothDeviceTestDataBuilder * skip(const QString& reason=nullptr);
};

Some files were not shown because too many files have changed in this diff Show More