feat: add energy-aware scheduling and daily insights
- Learn a per-device 7x24 energy profile from completed tasks\n- Constrain high-energy scheduling and expose energy peaks to AI\n- Add ghost-time overlays, daily review dialog, and proactive suggestions\n- Cover energy/insights logic and local OpenAI-compatible providers with tests\n- Update validation docs and screenshots
This commit is contained in:
@@ -57,6 +57,7 @@ private slots:
|
||||
void fallsBackWhenPreferredIsFull();
|
||||
void preferredWindowCanOverrideDefaultHours();
|
||||
void reportsFailureWhenNoRoom();
|
||||
void usesEnergyProfile();
|
||||
};
|
||||
|
||||
void TestScheduler::skipsBusyIntervals()
|
||||
@@ -157,5 +158,33 @@ void TestScheduler::reportsFailureWhenNoRoom()
|
||||
QCOMPARE(result.failures.size(), std::size_t(1));
|
||||
}
|
||||
|
||||
void TestScheduler::usesEnergyProfile()
|
||||
{
|
||||
scheduler::Options options;
|
||||
options.energyAt = [](SysTime value) {
|
||||
const int hour = static_cast<int>((value.time_since_epoch().count() / 3600) % 24);
|
||||
return hour < 14 ? 0 : 2;
|
||||
};
|
||||
|
||||
auto high = task(QStringLiteral("high").toStdString(), 60);
|
||||
high.energyRequired = 2;
|
||||
auto result = scheduler::schedule({high}, {}, workWindows(1), at(0, 8), at(0, 22), options);
|
||||
QCOMPARE(result.placements.size(), std::size_t(1));
|
||||
QVERIFY(result.placements[0].start == at(0, 14));
|
||||
QVERIFY(result.placements[0].end == at(0, 15));
|
||||
|
||||
auto medium = task(QStringLiteral("medium").toStdString(), 60);
|
||||
medium.energyRequired = 1;
|
||||
result = scheduler::schedule({medium}, {}, workWindows(1), at(0, 8), at(0, 22), options);
|
||||
QCOMPARE(result.placements.size(), std::size_t(1));
|
||||
QVERIFY(result.placements[0].start == at(0, 14));
|
||||
|
||||
auto strictHigh = task(QStringLiteral("strict-high").toStdString(), 60);
|
||||
strictHigh.energyRequired = 2;
|
||||
result = scheduler::schedule({strictHigh}, {}, workWindows(1), at(0, 8), at(0, 13), options);
|
||||
QVERIFY(result.placements.empty());
|
||||
QCOMPARE(result.failures.size(), std::size_t(1));
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(TestScheduler)
|
||||
#include "test_scheduler.moc"
|
||||
|
||||
Reference in New Issue
Block a user