Refine Framework graph legends and history keyboard controls
This commit is contained in:
1 parent
535ac5b480
commit
851e0d1d24
4 files changed
+47
-11
No files matched your search
@@ -544,19 +544,38 @@ private Q_SLOTS:
|
||||
Window window;
|
||||
auto *slider = window.findChild<QSlider *>("monitorHistory"); QVERIFY(slider);
|
||||
auto *stretch = window.findChild<QCheckBox *>("monitorStretch"); QVERIFY(stretch);
|
||||
QCOMPARE(slider->value(), 1000); QVERIFY(stretch->isChecked());
|
||||
QCOMPARE(slider->value(), slider->maximum()); QVERIFY(stretch->isChecked());
|
||||
QSettings settings("fedora-tools", "framework-laptop-tools");
|
||||
QTest::keyClick(slider, Qt::Key_Left);
|
||||
QCOMPARE(settings.value("monitor/historyMinutes").toInt(), 1439);
|
||||
QTest::keyClick(slider, Qt::Key_Left);
|
||||
QCOMPARE(settings.value("monitor/historyMinutes").toInt(), 1438);
|
||||
QTest::keyClick(slider, Qt::Key_Right);
|
||||
QCOMPARE(settings.value("monitor/historyMinutes").toInt(), 1439);
|
||||
QTest::keyClick(slider, Qt::Key_End);
|
||||
QTest::keyClick(slider, Qt::Key_Right);
|
||||
QCOMPARE(settings.value("monitor/historyMinutes").toInt(), 1440);
|
||||
slider->setValue(0); stretch->setChecked(false);
|
||||
for (auto *chart : window.findChildren<Chart *>())
|
||||
QCOMPARE(chart->timeRange().second - chart->timeRange().first, 300000.);
|
||||
slider->setValue(500);
|
||||
QSettings settings("fedora-tools", "framework-laptop-tools");
|
||||
QTest::keyClick(slider, Qt::Key_Left);
|
||||
QCOMPARE(settings.value("monitor/historyMinutes").toInt(), 5);
|
||||
QTest::keyClick(slider, Qt::Key_Right);
|
||||
QCOMPARE(settings.value("monitor/historyMinutes").toInt(), 6);
|
||||
slider->setValue(slider->maximum() / 2);
|
||||
const int minutes = settings.value("monitor/historyMinutes").toInt();
|
||||
QVERIFY(minutes >= 84 && minutes <= 86); // Geometric, not arithmetic, midpoint.
|
||||
QTest::keyClick(slider, Qt::Key_Right);
|
||||
QCOMPARE(settings.value("monitor/historyMinutes").toInt(), minutes + 1);
|
||||
QTest::keyClick(slider, Qt::Key_Left);
|
||||
QCOMPARE(settings.value("monitor/historyMinutes").toInt(), minutes);
|
||||
}
|
||||
Window restored;
|
||||
QCOMPARE(restored.findChild<QSlider *>("monitorHistory")->value(), 500);
|
||||
QVERIFY(!restored.findChild<QCheckBox *>("monitorStretch")->isChecked());
|
||||
QSettings settings("fedora-tools", "framework-laptop-tools");
|
||||
for (auto *chart : restored.findChildren<Chart *>())
|
||||
QCOMPARE(chart->timeRange().second - chart->timeRange().first,
|
||||
settings.value("monitor/historyMinutes").toInt() * 60000.);
|
||||
settings.setValue("tray/historyMs", 86400000);
|
||||
TrayPage tray(settings, {{"cpu-usage", "CPU usage", {}, "%"}});
|
||||
QCOMPARE(tray.iconStyle().historyMs, qint64(60000)); // Retired choices use the new default.
|
||||
|
||||
Reference in new issue
Block a user