@@ -498,6 +498,47 @@ TEST test_datachange_endless_agethreshold(void)
498
498
PASS ();
499
499
}
500
500
501
+ TEST test_datachange_agethreshold_at_second (void )
502
+ {
503
+ settings .show_age_threshold = S2US (5 );
504
+
505
+ queues_init ();
506
+
507
+ const gint64 NOTIF_DELTA = 200 ;
508
+
509
+ gint64 cur_time = 500 * 1000 ; // T = 0.5s
510
+ struct notification * n = test_notification ("n0" , 0 );
511
+ n -> timestamp = cur_time ;
512
+ queues_notification_insert (n );
513
+
514
+ cur_time += NOTIF_DELTA ;
515
+ n = test_notification ("n1" , 0 );
516
+ n -> timestamp = cur_time ;
517
+ queues_notification_insert (n );
518
+
519
+ queues_update (STATUS_NORMAL , cur_time );
520
+
521
+ // The next update should be when age must be first displayed, at T=5.5s
522
+ ASSERTm ("Age threshold is activated, first wakeup should be at 5.5s" ,
523
+ cur_time + queues_get_next_datachange (cur_time ) == S2US (5 ) + 500000 );
524
+
525
+ const int NB_MICROSECS = 6 ;
526
+ const gint64 MICROSECS [] = {
527
+ 0 , 10 , NOTIF_DELTA , NOTIF_DELTA + 1 , 124131 , S2US (1 )- 1
528
+ };
529
+ for (gint64 base_time = S2US (5 ); base_time <= S2US (7 ); base_time += S2US (1 )) {
530
+ for (int musec_id = 0 ; musec_id < NB_MICROSECS ; ++ musec_id ) {
531
+ cur_time = base_time + MICROSECS [musec_id ];
532
+ gint64 next_wakeup = cur_time + queues_get_next_datachange (cur_time );
533
+ ASSERTm ("Age threshold is activated, next wakeup should be at next turn of second" ,
534
+ next_wakeup == base_time + S2US (1 ));
535
+ }
536
+ }
537
+
538
+ queues_teardown ();
539
+ PASS ();
540
+ }
541
+
501
542
TEST test_datachange_queues (void )
502
543
{
503
544
queues_init ();
@@ -1041,6 +1082,7 @@ SUITE(suite_queues)
1041
1082
RUN_TEST (test_datachange_beginning_empty );
1042
1083
RUN_TEST (test_datachange_endless );
1043
1084
RUN_TEST (test_datachange_endless_agethreshold );
1085
+ RUN_TEST (test_datachange_agethreshold_at_second );
1044
1086
RUN_TEST (test_datachange_queues );
1045
1087
RUN_TEST (test_datachange_ttl );
1046
1088
RUN_TEST (test_queue_history_clear );
0 commit comments