Changeset View
Changeset View
Standalone View
Standalone View
test/rsitimer_test.cpp
Show All 26 Lines | 25 | { | |||
---|---|---|---|---|---|
27 | m_intervals[TINY_BREAK_INTERVAL] = 15 * 60; | 27 | m_intervals[TINY_BREAK_INTERVAL] = 15 * 60; | ||
28 | m_intervals[TINY_BREAK_DURATION] = 20; | 28 | m_intervals[TINY_BREAK_DURATION] = 20; | ||
29 | m_intervals[TINY_BREAK_THRESHOLD] = 60; | 29 | m_intervals[TINY_BREAK_THRESHOLD] = 60; | ||
30 | m_intervals[BIG_BREAK_INTERVAL] = 60 * 60; | 30 | m_intervals[BIG_BREAK_INTERVAL] = 60 * 60; | ||
31 | m_intervals[BIG_BREAK_DURATION] = 60; | 31 | m_intervals[BIG_BREAK_DURATION] = 60; | ||
32 | m_intervals[BIG_BREAK_THRESHOLD] = 5 * 60; | 32 | m_intervals[BIG_BREAK_THRESHOLD] = 5 * 60; | ||
33 | m_intervals[POSTPONE_BREAK_INTERVAL] = 3 * 60; | 33 | m_intervals[POSTPONE_BREAK_INTERVAL] = 3 * 60; | ||
34 | m_intervals[PATIENCE_INTERVAL] = 30; | 34 | m_intervals[PATIENCE_INTERVAL] = 30; | ||
35 | m_intervals[SHORT_INPUT_INTERVAL] = 2; | ||||
35 | } | 36 | } | ||
36 | 37 | | |||
37 | void RSITimerTest::triggerSimpleTinyBreak() | 38 | void RSITimerTest::triggerSimpleTinyBreak() | ||
38 | { | 39 | { | ||
39 | std::unique_ptr<RSIIdleTimeFake> idle_time( new RSIIdleTimeFake() ); | 40 | std::unique_ptr<RSIIdleTimeFake> idle_time( new RSIIdleTimeFake() ); | ||
40 | RSIIdleTimeFake* idle_time_ptr = idle_time.get(); | 41 | RSIIdleTimeFake* idle_time_ptr = idle_time.get(); | ||
41 | RSITimer timer( std::move( idle_time ), m_intervals, true, true ); | 42 | RSITimer timer( std::move( idle_time ), m_intervals, true, true ); | ||
42 | 43 | | |||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | |||||
163 | void RSITimerTest::triggerSimpleBigBreak() | 164 | void RSITimerTest::triggerSimpleBigBreak() | ||
164 | { | 165 | { | ||
165 | std::unique_ptr<RSIIdleTimeFake> idle_time( new RSIIdleTimeFake() ); | 166 | std::unique_ptr<RSIIdleTimeFake> idle_time( new RSIIdleTimeFake() ); | ||
166 | RSIIdleTimeFake* idle_time_ptr = idle_time.get(); | 167 | RSIIdleTimeFake* idle_time_ptr = idle_time.get(); | ||
167 | RSITimer timer( std::move( idle_time ), m_intervals, true, true ); | 168 | RSITimer timer( std::move( idle_time ), m_intervals, true, true ); | ||
168 | 169 | | |||
169 | int tinyBreaks = m_intervals[BIG_BREAK_INTERVAL] / ( m_intervals[TINY_BREAK_INTERVAL] + m_intervals[PATIENCE_INTERVAL] + m_intervals[TINY_BREAK_DURATION] ); | 170 | int tinyBreaks = m_intervals[BIG_BREAK_INTERVAL] / ( m_intervals[TINY_BREAK_INTERVAL] + m_intervals[PATIENCE_INTERVAL] + m_intervals[TINY_BREAK_DURATION] ); | ||
170 | // We don't tick big pause timer during tiny breaks and patience, so it will actually happen later. | 171 | // We don't tick big pause timer during tiny breaks and patience, so it will actually happen later. | ||
171 | int ticks = m_intervals[BIG_BREAK_INTERVAL] + tinyBreaks * ( m_intervals[PATIENCE_INTERVAL] + m_intervals[TINY_BREAK_DURATION] ); | 172 | // In time the patience wears out, the tiny break could already accumulate some seconds due to SHORT_INPUT_INTERVAL filter, so substract them. | ||
173 | int ticks = m_intervals[BIG_BREAK_INTERVAL] + tinyBreaks * ( m_intervals[PATIENCE_INTERVAL] + m_intervals[TINY_BREAK_DURATION] - (m_intervals[PATIENCE_INTERVAL] - 1) % m_intervals[SHORT_INPUT_INTERVAL] ); | ||||
172 | 174 | | |||
173 | QSignalSpy spyEndLongBreak( &timer, SIGNAL(endLongBreak()) ); | 175 | QSignalSpy spyEndLongBreak( &timer, SIGNAL(endLongBreak()) ); | ||
174 | 176 | | |||
175 | // Part one, no idleness till big break. | 177 | // Part one, no idleness till big break. | ||
176 | QSignalSpy spy1Relax( &timer, SIGNAL(relax(int,bool)) ); | 178 | QSignalSpy spy1Relax( &timer, SIGNAL(relax(int,bool)) ); | ||
177 | QSignalSpy spy1UpdateIdleAvg( &timer, SIGNAL(updateIdleAvg(double)) ); | 179 | QSignalSpy spy1UpdateIdleAvg( &timer, SIGNAL(updateIdleAvg(double)) ); | ||
178 | 180 | | |||
179 | idle_time_ptr->setIdleTime( 0 ); | 181 | idle_time_ptr->setIdleTime( 0 ); | ||
▲ Show 20 Lines • Show All 209 Lines • Show Last 20 Lines |