1 /*
2     KStars UI tests for verifying correct counting of the capture module
3 
4     SPDX-FileCopyrightText: 2020 Wolfgang Reissenberger <sterne-jaeger@openfuture.de>
5 
6     SPDX-License-Identifier: GPL-2.0-or-later
7 */
8 
9 #include "test_ekos_capture_count.h"
10 
11 #include "kstars_ui_tests.h"
12 #include "test_ekos.h"
13 #include "Options.h"
14 
15 #include "test_ekos_capture_helper.h"
16 
17 /* *****************************************************************************
18  * Determining the correct number of frames being already captured and need to be
19  * captured in future is surprisingly complex - which comes from the variety of
20  * options how capturing can be configured and is being processed.
21  *
22  * The simplest way is when the Capture module is used standalone. The only thing
23  * that needs to be considered is the option setting a captured frames map before
24  * starting. This map needs to be considered and the Capture module should capture
25  * only the difference between the numbers defined by the capture sequence and
26  * these already existing frames.
27  *
28  * In combination with the Scheduler module, things get complicated, since the
29  * Scheduler module
30  * - has several options how a capture sequence will be repeated
31  *   (single run, fixed number of iterations, infinite looping, termination by date)
32  * - has the option "Remember job progress", where if selected existing frames
33  *   need to be considered and counted.
34  * ***************************************************************************** */
35 
TestEkosCaptureCount(QObject * parent)36 TestEkosCaptureCount::TestEkosCaptureCount(QObject *parent) : QObject(parent) {
37     m_CaptureHelper = new TestEkosCaptureHelper();
38 }
39 
40 
testCaptureWithCaptureFramesMap()41 void TestEkosCaptureCount::testCaptureWithCaptureFramesMap()
42 {
43     // clean up capture module
44     Ekos::Manager::Instance()->captureModule()->clearSequenceQueue();
45     KTRY_GADGET(Ekos::Manager::Instance()->captureModule(), QTableWidget, queueTable);
46     QTRY_VERIFY_WITH_TIMEOUT(queueTable->rowCount() == 0, 2000);
47 
48     // setup capture sequence, fill captured frames map and set expectations
49     QVERIFY(prepareCapture());
50 
51     // verify if at least one capture is expected
52     QVERIFY(executeCapturing());
53 }
54 
testSchedulerCapture()55 void TestEkosCaptureCount::testSchedulerCapture()
56 {
57     KTELL("Expect captures and an idle signal at the end");
58     m_CaptureHelper->expectedCaptureStates.enqueue(Ekos::CAPTURE_CAPTURING);
59     expectedSchedulerStates.enqueue(Ekos::SCHEDULER_IDLE);
60 
61     KTELL("Prepare scheduler captures");
62     QVERIFY(prepareScheduledCapture(SchedulerJob::FINISH_REPEAT));
63 
64     KTELL("Start scheduler job");
65     KTRY_CLICK(Ekos::Manager::Instance()->schedulerModule(), startB);
66 
67     KTELL("Ensure that the scheduler has started capturing");
68     QTRY_VERIFY_WITH_TIMEOUT(m_CaptureHelper->expectedCaptureStates.size() == 0, 120000);
69 
70     KTELL("Wait for Scheduler to finish capturing");
71     KVERIFY_EMPTY_QUEUE_WITH_TIMEOUT(expectedSchedulerStates, 120000);
72 
73     KTELL("Verify whether all frames are captured as expected");
74     QVERIFY2(checkCapturedFrames(), "Capturing did not produce the expected amount of frames.");
75 }
76 
testSchedulerCaptureInfiteLooping()77 void TestEkosCaptureCount::testSchedulerCaptureInfiteLooping()
78 {
79     // prepare captured frames
80     QVERIFY(prepareScheduledCapture(SchedulerJob::FINISH_LOOP));
81 }
82 
83 /* *********************************************************************************
84  *
85  * Test data
86  *
87  * ********************************************************************************* */
88 
testSchedulerCapture_data()89 void TestEkosCaptureCount::testSchedulerCapture_data()
90 {
91 #ifdef LONG_TEST
92     prepareTestData(0.1, "Red:2,Green:2,Blue:2", "Red:2,Green:1,Blue:2", "Green:1");
93     prepareTestData(0.1, "Red:2,Green:2,Blue:2", "Red:3,Green:1,Blue:2", "Green:1");
94     prepareTestData(0.1, "Red:1,Red:1,Green:1,Green:1,Blue:1,Blue:1", "Red:2,Green:1,Blue:2", "Green:1");
95     prepareTestData(0.1, "Red:1,Green:1,Blue:1,Red:1,Green:1,Blue:1", "Red:2,Green:1,Blue:2", "Green:1");
96     prepareTestData(0.1, "Red:1,Green:1,Blue:1", "Red:3,Green:1,Blue:3", "Green:2", 3);
97     prepareTestData(0.1, "Luminance:3,Red:1,Green:1,Blue:1,Luminance:2", "Luminance:4,Green:1,Blue:1", "Luminance:1,Red:1");
98     prepareTestData(0.1, "Luminance:3,Red:1,Green:1,Blue:1,Luminance:2", "", "Luminance:10,Red:2,Green:2,Blue:2", 2);
99     prepareTestData(0.1, "Luminance:3,Red:1,Green:1,Blue:1,Luminance:2", "Luminance:15,Red:1,Green:2,Blue:2", "Red:1", 2);
100     prepareTestData(0.1, "Luminance:3,Red:1,Green:1,Blue:1,Luminance:2", "Luminance:15,Red:2,Green:3,Blue:3", "Red:1", 3);
101     prepareTestData(0.1, "Luminance:3,Red:1,Green:1,Blue:1,Luminance:2", "Luminance:15,Red:3,Green:3,Blue:2", "Blue:1", 3);
102     prepareTestData(0.1, "Luminance:3,Red:1,Green:1,Blue:1,Luminance:2", "Luminance:5,Red:1,Green:1,Blue:1", "Luminance:10,Red:2,Green:2,Blue:2", 3);
103     prepareTestData(0.1, "Luminance:3,Red:1,Green:1,Blue:1,Luminance:2", "Luminance:2,Red:1,Green:1,Blue:1", "Luminance:13,Red:2,Green:2,Blue:2", 3);
104 #else
105     prepareTestData(0.1, "Red:2,Green:2,Blue:2", "Red:2,Green:1,Blue:2", "Green:1");
106     prepareTestData(0.1, "Red:1,Green:1,Blue:1,Red:1,Green:1,Blue:1", "Red:2,Green:1,Blue:2", "Green:1");
107     prepareTestData(0.1, "Luminance:3,Red:1,Green:1,Blue:1,Luminance:2", "Luminance:4,Green:1,Blue:1", "Luminance:1,Red:1");
108     prepareTestData(0.1, "Luminance:3,Red:1,Green:1,Blue:1,Luminance:2", "Luminance:5,Red:1,Green:1,Blue:1", "Luminance:10,Red:2,Green:2,Blue:2", 3);
109 #endif
110 }
111 
testCaptureWithCaptureFramesMap_data()112 void TestEkosCaptureCount::testCaptureWithCaptureFramesMap_data()
113 {
114     // use the same test set
115     testSchedulerCapture_data();
116 }
117 
testSchedulerCaptureInfiteLooping_data()118 void TestEkosCaptureCount::testSchedulerCaptureInfiteLooping_data()
119 {
120     prepareTestData(0.1, "Luminance:2", "Luminance:2", "");
121     prepareTestData(0.1, "Luminance:3,Red:1,Green:1,Blue:1,Luminance:2", "Luminance:5,Green:1,Blue:1", "");
122 }
123 
124 /* *********************************************************************************
125  *
126  * Test infrastructure
127  *
128  * ********************************************************************************* */
129 
initTestCase()130 void TestEkosCaptureCount::initTestCase()
131 {
132     KVERIFY_EKOS_IS_HIDDEN();
133     KTRY_OPEN_EKOS();
134     KVERIFY_EKOS_IS_OPENED();
135     // start the profile
136     QVERIFY(m_CaptureHelper->startEkosProfile());
137     m_CaptureHelper->init();
138     // do not show images
139     Options::setUseFITSViewer(false);
140     // disable twilight warning
141     KMessageBox::saveDontShowAgainYesNo("astronomical_twilight_warning", KMessageBox::ButtonCode::No);
142 }
143 
cleanupTestCase()144 void TestEkosCaptureCount::cleanupTestCase()
145 {
146     m_CaptureHelper->cleanup();
147     QVERIFY(m_CaptureHelper->shutdownEkosProfile());
148     KTRY_CLOSE_EKOS();
149     KVERIFY_EKOS_IS_HIDDEN();
150 }
151 
init()152 void TestEkosCaptureCount::init()
153 {
154     connect(Ekos::Manager::Instance()->captureModule(), &Ekos::Capture::captureComplete, this, &TestEkosCaptureCount::captureComplete);
155     connect(Ekos::Manager::Instance()->schedulerModule(), &Ekos::Scheduler::newStatus, this, &TestEkosCaptureCount::schedulerStateChanged);
156     QStandardPaths::setTestModeEnabled(true);
157     // clear image directory
158     QVERIFY(m_CaptureHelper->getImageLocation()->removeRecursively());
159 }
160 
cleanup()161 void TestEkosCaptureCount::cleanup()
162 {
163     QVERIFY(m_CaptureHelper->stopCapturing());
164 
165     disconnect(Ekos::Manager::Instance()->schedulerModule(), &Ekos::Scheduler::newStatus, this, &TestEkosCaptureCount::schedulerStateChanged);
166     disconnect(Ekos::Manager::Instance()->captureModule(), &Ekos::Capture::captureComplete, this, &TestEkosCaptureCount::captureComplete);
167 
168     // clean up capture page
169     Ekos::Manager::Instance()->captureModule()->clearSequenceQueue();
170 
171     // clean up expected images
172     m_expectedImages.clear();
173 
174     // cleanup scheduler
175     m_CaptureHelper->cleanupScheduler();
176 }
177 
178 
179 /* *********************************************************************************
180  *
181  * Helper functions
182  *
183  * ********************************************************************************* */
184 
checkCapturedFrames()185 bool TestEkosCaptureCount::checkCapturedFrames()
186 {
187     bool success = true;
188     for (QMap<QString, int>::iterator it = m_expectedImages.begin(); it != m_expectedImages.end(); ++it)
189         if (it.value() != 0)
190         {
191             QWARN(QString("Capture count for signature %1 does not match: %2 frames too %3 captured.").arg(it.key()).arg(abs(it.value())).arg(it.value() < 0 ? "much" : "few").toStdString().c_str());
192             success = false;
193         }
194 
195     return success;
196 }
197 
executeCapturing()198 bool TestEkosCaptureCount::executeCapturing()
199 {
200 
201     // calculate frame counts
202     int framesCount = 0;
203     for(int value: m_expectedImages.values())
204             framesCount += value;
205 
206     // capture
207     KWRAP_SUB(QVERIFY(m_CaptureHelper->startCapturing(framesCount > 0)));
208 
209     // expect receiving a new CAPTURE_COMPLETE signal
210     if (framesCount > 0)
211         m_CaptureHelper->expectedCaptureStates.enqueue(Ekos::CAPTURE_COMPLETE);
212 
213     // wait for finish capturing
214     // ensure that the scheduler has started capturing
215     KWRAP_SUB(QTRY_VERIFY_WITH_TIMEOUT(m_CaptureHelper->expectedCaptureStates.size() == 0, 120000));
216 
217     // verify whether all frames are captured as expected
218     KWRAP_SUB(QVERIFY2(checkCapturedFrames(), "Capturing did not produce the expected amount of frames."));
219 
220     // wait for shutdown
221     QTest::qWait(500);
222     return true;
223 }
224 
prepareCapture()225 bool TestEkosCaptureCount::prepareCapture()
226 {
227     QFETCH(double, exptime);
228     QFETCH(QString, sequence);
229     QFETCH(QString, capturedFramesMap);
230     QFETCH(QString, expectedFrames);
231     QFETCH(int, iterations);
232 
233     // switch to capture module
234     Ekos::Capture *capture = Ekos::Manager::Instance()->captureModule();
235     KWRAP_SUB(KTRY_SWITCH_TO_MODULE_WITH_TIMEOUT(capture, 1000));
236 
237     // add target to path to emulate the behavior of the scheduler
238     QString imagepath = m_CaptureHelper->getImageLocation()->path() + "/" + target;
239 
240     // create the destination for images
241     qCInfo(KSTARS_EKOS_TEST) << "FITS path: " << imagepath;
242 
243     // create capture sequences
244     for (int i = 0; i < iterations; i++)
245         KVERIFY_SUB(m_CaptureHelper->fillCaptureSequences(target, sequence, exptime, imagepath));
246 
247     // fill the captured frames map that hold the numbers of already taken frames
248     KVERIFY_SUB(fillCapturedFramesMap(capturedFramesMap));
249 
250     // fill the map of expected frames
251     KVERIFY_SUB(setExpectedFrames(expectedFrames));
252 
253     // everything successfully completed
254     return true;
255 }
256 
prepareScheduledCapture(SchedulerJob::CompletionCondition completionCondition)257 bool TestEkosCaptureCount::prepareScheduledCapture(SchedulerJob::CompletionCondition completionCondition)
258 {
259     QFETCH(double, exptime);
260     QFETCH(QString, sequence);
261     QFETCH(QString, capturedFramesMap);
262     QFETCH(QString, expectedFrames);
263     QFETCH(int, iterations);
264     QFETCH(bool, rememberJobProgress);
265 
266     // switch to capture module
267     Ekos::Capture *capture = Ekos::Manager::Instance()->captureModule();
268     KWRAP_SUB(KTRY_SWITCH_TO_MODULE_WITH_TIMEOUT(capture, 1000));
269 
270     // create the destination for images
271     qCInfo(KSTARS_EKOS_TEST) << "FITS path: " << m_CaptureHelper->getImageLocation()->path();
272 
273     // step 1: create the frames due to the captured frames map
274     if (capturedFramesMap != "")
275     {
276         KVERIFY_SUB(m_CaptureHelper->fillCaptureSequences(target, capturedFramesMap, exptime, m_CaptureHelper->getImageLocation()->filePath(target)));
277         KVERIFY_SUB(fillCapturedFramesMap(""));
278         KVERIFY_SUB(setExpectedFrames(capturedFramesMap));
279 
280         // create the expected frames
281         KVERIFY_SUB(executeCapturing());
282 
283         // clean up
284         capture->clearSequenceQueue();
285     }
286 
287     // step 2: create the sequence for the test
288     KVERIFY_SUB(m_CaptureHelper->fillCaptureSequences(target, sequence, exptime, m_CaptureHelper->getImageLocation()->path()));
289     KVERIFY_SUB(fillCapturedFramesMap(""));
290     if (rememberJobProgress)
291         KVERIFY_SUB(setExpectedFrames(expectedFrames));
292     else
293         for (int i = 0; i < iterations; i++)
294             KVERIFY_SUB(setExpectedFrames(sequence));
295 
296     // save current capture sequence to Ekos sequence file
297     QString sequenceFile = m_CaptureHelper->destination->filePath("test.esq");
298     qCInfo(KSTARS_EKOS_TEST) << "Sequence file" << sequenceFile << "created.";
299     KVERIFY_SUB(Ekos::Manager::Instance()->captureModule()->saveSequenceQueue(sequenceFile));
300 
301     // setup scheduler
302     setupScheduler(sequenceFile, sequence, capturedFramesMap, completionCondition, iterations, rememberJobProgress, exptime);
303 
304     // everything successfully completed
305     return true;
306 }
307 
setupScheduler(QString sequenceFile,QString sequence,QString capturedFramesMap,SchedulerJob::CompletionCondition completionCondition,int iterations,bool rememberJobProgress,double exptime)308 bool TestEkosCaptureCount::setupScheduler(QString sequenceFile, QString sequence, QString capturedFramesMap, SchedulerJob::CompletionCondition completionCondition,
309                                           int iterations, bool rememberJobProgress, double exptime)
310 {
311     Ekos::Scheduler *scheduler = Ekos::Manager::Instance()->schedulerModule();
312     KWRAP_SUB(KTRY_SWITCH_TO_MODULE_WITH_TIMEOUT(scheduler, 1000));
313     // set sequence file
314     scheduler->setSequence(sequenceFile);
315     // set Kocab as target
316     KTRY_SET_LINEEDIT_SUB(scheduler, nameEdit, target);
317     KTRY_SET_LINEEDIT_SUB(scheduler, raBox, "14 50 42");
318     KTRY_SET_LINEEDIT_SUB(scheduler, decBox, "74 09 20");
319     // disable all step checks
320     KTRY_SET_CHECKBOX_SUB(scheduler, trackStepCheck, false);
321     KTRY_SET_CHECKBOX_SUB(scheduler, focusStepCheck, false);
322     KTRY_SET_CHECKBOX_SUB(scheduler, alignStepCheck, false);
323     KTRY_SET_CHECKBOX_SUB(scheduler, guideStepCheck, false);
324     // ignore twilight
325     KTRY_SET_CHECKBOX_SUB(scheduler, twilightCheck, false);
326     // set remember job progress
327     Options::setRememberJobProgress(rememberJobProgress);
328     // disable INDI stopping after scheduler finished
329     Options::setStopEkosAfterShutdown(false);
330 
331     // set the completion condition
332     switch (completionCondition) {
333     case SchedulerJob::FINISH_REPEAT:
334         // repeat the job for a fixed amount
335         KTRY_SET_RADIOBUTTON_SUB(scheduler, repeatCompletionR, true);
336         KTRY_SET_SPINBOX_SUB(scheduler, repeatsSpin, iterations);
337         break;
338     case SchedulerJob::FINISH_LOOP:
339         KTRY_SET_RADIOBUTTON_SUB(scheduler, loopCompletionR, true);
340         break;
341     default:
342         QWARN(QString("Unsupported completion condition %1!").arg(completionCondition).toStdString().c_str());
343         return false;
344         break;
345     }
346     // add scheduler job
347     KTRY_CLICK_SUB(scheduler, addToQueueB);
348 
349     // verify the displayed capture counts
350     KVERIFY_SUB(verifySchedulerCounting(sequence, capturedFramesMap, completionCondition, iterations, rememberJobProgress, exptime));
351 
352     // everything worked as expected
353     return true;
354 }
355 
verifySchedulerCounting(QString sequence,QString capturedFramesMap,SchedulerJob::CompletionCondition completionCondition,int iterations,bool rememberJobProgress,double exptime)356 bool TestEkosCaptureCount::verifySchedulerCounting(QString sequence, QString capturedFramesMap, SchedulerJob::CompletionCondition completionCondition,
357                                                    int iterations, bool rememberJobProgress, double exptime)
358 {
359     Ekos::Scheduler *scheduler = Ekos::Manager::Instance()->schedulerModule();
360     KTRY_GADGET_SUB(scheduler, QTableWidget, queueTable);
361     KVERIFY_SUB(queueTable->rowCount() == 1);
362     KVERIFY_SUB(queueTable->columnCount() > 3);
363     QString displayedCounts = queueTable->item(0, 2)->text();
364     KVERIFY2_SUB(displayedCounts.indexOf("/") > 0, "Scheduler job table does not display in style captured/total.");
365 
366     int total = -1, captured = -1, total_repeat_expected = 0;
367 
368     // check display of expected frames
369     if (completionCondition == SchedulerJob::FINISH_REPEAT)
370     {
371         total = displayedCounts.right(displayedCounts.length() - displayedCounts.indexOf("/") - 1).toInt();
372         total_repeat_expected = totalCount(sequence) * iterations;
373         KVERIFY2_SUB(total == total_repeat_expected,
374                      QString("Scheduler job table shows %1 expected frames instead of %2.").arg(total).arg(total_repeat_expected).toStdString().c_str());
375     }
376 
377     // check display of already captured
378     captured = displayedCounts.left(displayedCounts.indexOf("/")).toInt();
379     // determine expected captures
380     int captured_expected = 0;
381     // the captured frames map is only relevant if the "Remember job progress" option is selected
382     if (rememberJobProgress)
383     {
384         QMap<QString, uint16_t> capturedMap = framesMap(capturedFramesMap);
385         QMap<QString, uint16_t> sequenceMap = framesMap(sequence);
386         // for each filter, the displayed total is limited by the capture sequence multiplied by the number of iterations
387         for (QString key : sequenceMap.keys())
388             captured_expected += std::min(capturedMap[key], static_cast<uint16_t>(sequenceMap[key] * iterations));
389     }
390     // execute the check
391     KVERIFY2_SUB(captured == captured_expected,
392                  QString("Scheduler job table shows %1 captured frames instead of %2.").arg(captured).arg(captured_expected).toStdString().c_str());
393 
394     // check estimated duration time (only relevant for repeats
395     if (completionCondition == SchedulerJob::FINISH_REPEAT)
396     {
397         QString estimation = queueTable->item(0, 7)->text();
398         QTime estimatedDuration = QTime::fromString(estimation, "HH:mm:ss");
399         int duration = estimatedDuration.second() + 60*estimatedDuration.minute() + 3600*estimatedDuration.hour();
400         KVERIFY2_SUB(std::fabs((total_repeat_expected - captured_expected)*exptime - duration) <= 1,
401                      QString("Scheduler job table shows %1 seconds expected instead of %2.").arg(duration).arg((total_repeat_expected - captured_expected)*exptime).toStdString().c_str());
402     }
403     // everything worked as expected
404     return true;
405 }
406 
prepareTestData(double exptime,QString sequence,QString capturedFramesMap,QString expectedFrames,int iterations)407 void TestEkosCaptureCount::prepareTestData(double exptime, QString sequence, QString capturedFramesMap, QString expectedFrames, int iterations)
408 {
409 
410     QTest::addColumn<double>("exptime");             /*!< exposure time */
411     QTest::addColumn<QString>("sequence");           /*!< list of filters */
412     QTest::addColumn<QString>("capturedFramesMap");  /*!< list of frame counts */
413     QTest::addColumn<QString>("expectedFrames");     /*!< list of frames per filter that are expected */
414     QTest::addColumn<int>("iterations");             /*!< how often should the sequence be repeated */
415     QTest::addColumn<bool>("rememberJobProgress");   /*!< "Remember job progress" option selected */
416 
417     for (bool remember : {false, true})
418         QTest::newRow(QString("seq=%1, captured=%2, it=%3, remember=%4").arg(sequence).arg(capturedFramesMap).arg(iterations).arg(remember ? "true":"false").toStdString().c_str())
419                 << exptime << sequence << capturedFramesMap << expectedFrames << iterations << remember;
420  }
421 
fillCapturedFramesMap(QString capturedFramesMap)422 bool TestEkosCaptureCount::fillCapturedFramesMap(QString capturedFramesMap)
423 {
424     if (capturedFramesMap != "")
425     {
426         for (QString value : capturedFramesMap.split(","))
427         {
428             KVERIFY_SUB(value.indexOf(":") > -1);
429             QString filter = value.left(value.indexOf(":"));
430             int count      = value.right(value.length()-value.indexOf(":")-1).toInt();
431             Ekos::Manager::Instance()->captureModule()->setCapturedFramesMap(m_CaptureHelper->calculateSignature(target, filter), count);
432         }
433     }
434 
435     return true;
436 }
437 
setExpectedFrames(QString expectedFrames)438 bool TestEkosCaptureCount::setExpectedFrames(QString expectedFrames)
439 {
440     if (expectedFrames != "")
441     {
442         for (QString value : expectedFrames.split(","))
443         {
444             KVERIFY_SUB(value.indexOf(":") > -1);
445             QString filter = value.left(value.indexOf(":"));
446             int count      = value.right(value.length()-value.indexOf(":")-1).toInt();
447             if (m_expectedImages.contains(filter))
448                 m_expectedImages[filter] += count;
449             else
450                 m_expectedImages.insert(filter, count);
451         }
452     }
453     else
454         m_expectedImages.clear();
455 
456     return true;
457 }
458 
totalCount(QString sequence)459 int TestEkosCaptureCount::totalCount(QString sequence)
460 {
461     if (sequence == "")
462         return 0;
463 
464     int total = 0;
465     for (QString value : sequence.split(","))
466         total += value.right(value.length()-value.indexOf(":")-1).toInt();
467 
468     return total;
469 }
470 
471 
framesMap(QString sequence)472 QMap<QString, uint16_t> TestEkosCaptureCount::framesMap(QString sequence)
473 {
474     QMap<QString, uint16_t> result;
475 
476     if (sequence == "")
477         return result;
478 
479     for (QString value : sequence.split(","))
480     {
481         QString filter = value.left(value.indexOf(":"));
482         int count      = value.right(value.length()-value.indexOf(":")-1).toInt();
483         if (result.contains(filter))
484             result[filter] += count;
485         else
486             result[filter] = count;
487     }
488 
489     return result;
490 }
491 /* *********************************************************************************
492  *
493  * Slots
494  *
495  * ********************************************************************************* */
496 
captureComplete(const QString & filename,double exposureSeconds,const QString & filter,double hfr)497 void TestEkosCaptureCount::captureComplete(const QString &filename, double exposureSeconds, const QString &filter, double hfr)
498 {
499     Q_UNUSED(filename);
500     Q_UNUSED(exposureSeconds);
501     Q_UNUSED(hfr);
502 
503     // reduce the for the job's signature the number of expected images
504     m_expectedImages.insert(filter, m_expectedImages.value(filter, 0) - 1);
505 }
506 
schedulerStateChanged(Ekos::SchedulerState status)507 void TestEkosCaptureCount::schedulerStateChanged(Ekos::SchedulerState status)
508 {
509     m_SchedulerStatus = status;
510     // check if the new state is the next one expected, then remove it from the stack
511     if (!expectedSchedulerStates.isEmpty() && expectedSchedulerStates.head() == status)
512         expectedSchedulerStates.dequeue();
513 
514 }
515 
516 /* *********************************************************************************
517  *
518  * Main function
519  *
520  * ********************************************************************************* */
521 
522 QTEST_KSTARS_MAIN(TestEkosCaptureCount)
523