mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-14 22:35:49 +00:00
gpu support
This commit is contained in:
@ -29,7 +29,7 @@ set(TEST_MODULES
|
||||
abstractextitem extquotes extscript extupgrade extweather
|
||||
abstractformatter datetimeformatter floatformatter jsonformatter listformatter noformatter scriptformatter stringformatter
|
||||
extitemaggregator
|
||||
batterysource desktopsource gpuloadsource gputempsource hddtempsource networksource playersource processessource
|
||||
batterysource desktopsource networksource playersource processessource
|
||||
awbugreporter awconfighelper awkeycache awkeys awpatternfunctions awtelemetryhandler awupdatehelper
|
||||
dpplugin)
|
||||
foreach (TEST_MODULE ${TEST_MODULES})
|
||||
|
@ -1,66 +0,0 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testgpuloadsource.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "awtestlibrary.h"
|
||||
#include "gpuloadsource.h"
|
||||
|
||||
|
||||
void TestGPULoadSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
device = GPULoadSource::autoGpu();
|
||||
QVERIFY(!device.isEmpty());
|
||||
|
||||
source = new GPULoadSource(this, QStringList() << device);
|
||||
}
|
||||
|
||||
|
||||
void TestGPULoadSource::cleanupTestCase()
|
||||
{
|
||||
delete source;
|
||||
}
|
||||
|
||||
|
||||
void TestGPULoadSource::test_sources()
|
||||
{
|
||||
QCOMPARE(source->sources(), QStringList() << src);
|
||||
}
|
||||
|
||||
|
||||
void TestGPULoadSource::test_gpuload()
|
||||
{
|
||||
if (device == "disable")
|
||||
QSKIP("Not supported device, test will be skipped");
|
||||
|
||||
QSignalSpy spy(source, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
float firstValue = source->data(src).toFloat();
|
||||
|
||||
QVERIFY(spy.wait(5000));
|
||||
QVariantHash arguments = spy.takeFirst().at(0).toHash();
|
||||
float secondValue = arguments[src].toFloat();
|
||||
|
||||
QCOMPARE(firstValue, 0.0f);
|
||||
QVERIFY((secondValue >= load.first) && (secondValue <= load.second));
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(TestGPULoadSource);
|
@ -1,48 +0,0 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef TESTGPULOADSOURCE_H
|
||||
#define TESTGPULOADSOURCE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
|
||||
|
||||
class GPULoadSource;
|
||||
|
||||
class TestGPULoadSource : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
// initialization
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
// test
|
||||
void test_sources();
|
||||
void test_gpuload();
|
||||
|
||||
private:
|
||||
GPULoadSource *source = nullptr;
|
||||
QString device;
|
||||
QString src = "gpu/load";
|
||||
QPair<float, float> load = QPair<float, float>(0.0f, 100.0f);
|
||||
};
|
||||
|
||||
|
||||
#endif /* TESTGPULOADSOURCE_H */
|
@ -1,67 +0,0 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testgputempsource.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "awtestlibrary.h"
|
||||
#include "gpuloadsource.h"
|
||||
#include "gputempsource.h"
|
||||
|
||||
|
||||
void TestGPUTemperatureSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
device = GPULoadSource::autoGpu();
|
||||
QVERIFY(!device.isEmpty());
|
||||
|
||||
source = new GPUTemperatureSource(this, QStringList() << device);
|
||||
}
|
||||
|
||||
|
||||
void TestGPUTemperatureSource::cleanupTestCase()
|
||||
{
|
||||
delete source;
|
||||
}
|
||||
|
||||
|
||||
void TestGPUTemperatureSource::test_sources()
|
||||
{
|
||||
QCOMPARE(source->sources(), QStringList() << src);
|
||||
}
|
||||
|
||||
|
||||
void TestGPUTemperatureSource::test_gputemp()
|
||||
{
|
||||
if (device == "disable")
|
||||
QSKIP("Not supported device, test will be skipped");
|
||||
|
||||
QSignalSpy spy(source, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
float firstValue = source->data(src).toFloat();
|
||||
|
||||
QVERIFY(spy.wait(5000));
|
||||
QVariantHash arguments = spy.takeFirst().at(0).toHash();
|
||||
float secondValue = arguments[src].toFloat();
|
||||
|
||||
QCOMPARE(firstValue, 0.0f);
|
||||
QVERIFY((secondValue >= temp.first) && (secondValue <= temp.second));
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(TestGPUTemperatureSource);
|
@ -1,48 +0,0 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef TESTGPUTEMPSOURCE_H
|
||||
#define TESTGPUTEMPSOURCE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
|
||||
|
||||
class GPUTemperatureSource;
|
||||
|
||||
class TestGPUTemperatureSource : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
// initialization
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
// test
|
||||
void test_sources();
|
||||
void test_gputemp();
|
||||
|
||||
private:
|
||||
GPUTemperatureSource *source = nullptr;
|
||||
QString device;
|
||||
QString src = "gpu/temperature";
|
||||
QPair<float, float> temp = QPair<float, float>(0.0f, 120.0f);
|
||||
};
|
||||
|
||||
|
||||
#endif /* TESTGPUTEMPSOURCE_H */
|
@ -1,96 +0,0 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testhddtempsource.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "awtestlibrary.h"
|
||||
#include "hddtempsource.h"
|
||||
|
||||
|
||||
void TestHDDTemperatureSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
devices = HDDTemperatureSource::allHdd();
|
||||
|
||||
hddtempSource = new HDDTemperatureSource(this, QStringList() << devices.join(',') << hddtempCmd);
|
||||
smartctlSource = new HDDTemperatureSource(this, QStringList() << devices.join(',') << smartctlCmd);
|
||||
}
|
||||
|
||||
|
||||
void TestHDDTemperatureSource::cleanupTestCase()
|
||||
{
|
||||
delete hddtempSource;
|
||||
delete smartctlSource;
|
||||
}
|
||||
|
||||
|
||||
void TestHDDTemperatureSource::test_sources()
|
||||
{
|
||||
if (devices.isEmpty())
|
||||
QSKIP("No hdd devices found, test will be skipped");
|
||||
|
||||
std::for_each(devices.begin(), devices.end(), [](QString &device) { device.prepend("hdd/temperature"); });
|
||||
|
||||
QCOMPARE(hddtempSource->sources(), devices);
|
||||
QCOMPARE(smartctlSource->sources(), devices);
|
||||
}
|
||||
|
||||
|
||||
void TestHDDTemperatureSource::test_hddtemp()
|
||||
{
|
||||
if (devices.isEmpty())
|
||||
QSKIP("No hdd devices found, test will be skipped");
|
||||
|
||||
std::for_each(devices.begin(), devices.end(), [this](QString device) {
|
||||
QSignalSpy spy(hddtempSource, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
float firstValue = hddtempSource->data(device).toFloat();
|
||||
|
||||
QVERIFY(spy.wait(5000));
|
||||
QVariantHash arguments = spy.takeFirst().at(0).toHash();
|
||||
device.remove("hdd/temperature");
|
||||
float secondValue = arguments[device].toFloat();
|
||||
|
||||
QCOMPARE(firstValue, 0.0f);
|
||||
QVERIFY((secondValue >= temp.first) && (secondValue <= temp.second));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void TestHDDTemperatureSource::test_smartctl()
|
||||
{
|
||||
if (devices.isEmpty())
|
||||
QSKIP("No hdd devices found, test will be skipped");
|
||||
|
||||
std::for_each(devices.begin(), devices.end(), [this](QString &device) {
|
||||
QSignalSpy spy(smartctlSource, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
float firstValue = smartctlSource->data(device).toFloat();
|
||||
|
||||
QVERIFY(spy.wait(5000));
|
||||
QVariantHash arguments = spy.takeFirst().at(0).toHash();
|
||||
device.remove("hdd/temperature");
|
||||
float secondValue = arguments[device].toFloat();
|
||||
|
||||
QCOMPARE(firstValue, 0.0f);
|
||||
QVERIFY((secondValue >= temp.first) && (secondValue <= temp.second));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(TestHDDTemperatureSource);
|
@ -1,51 +0,0 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef TESTHDDTEMPSOURCE_H
|
||||
#define TESTHDDTEMPSOURCE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
|
||||
|
||||
class HDDTemperatureSource;
|
||||
|
||||
class TestHDDTemperatureSource : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
// initialization
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
// test
|
||||
void test_sources();
|
||||
void test_hddtemp();
|
||||
void test_smartctl();
|
||||
|
||||
private:
|
||||
HDDTemperatureSource *hddtempSource = nullptr;
|
||||
HDDTemperatureSource *smartctlSource = nullptr;
|
||||
QStringList devices;
|
||||
QString hddtempCmd = "sudo hddtemp";
|
||||
QString smartctlCmd = "sudo smartctl -a";
|
||||
QPair<float, float> temp = QPair<float, float>(0.0f, 120.0f);
|
||||
};
|
||||
|
||||
|
||||
#endif /* TESTHDDTEMPSOURCE_H */
|
Reference in New Issue
Block a user