File: TestUpdateTimer.cpp

package info (click to toggle)
bornagain 23.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,936 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (32 lines) | stat: -rw-r--r-- 954 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "GUI/Model/Type/UpdateTimer.h"
#include "Tests/GTestWrapper/google_test.h"
#include <QSignalSpy>

TEST(UpdateTimer, updateTimerShort)
{
    const int timer_interval(100);
    UpdateTimer timer(timer_interval);

    QSignalSpy spy(&timer, SIGNAL(timeToUpdate()));

    for (int i = 0; i < 10; ++i)
        timer.scheduleUpdate();

    // Checks that after time bigger than timer interval, we have a valid signal
    EXPECT_TRUE(spy.wait(timer_interval * 3));
    EXPECT_EQ(spy.count(), 1);

    // once again
    timer.scheduleUpdate();
    EXPECT_TRUE(spy.wait(timer_interval * 3));
    EXPECT_EQ(spy.count(), 2);

    /* The following test is disabled because it occasionally fails on Travis
        // Checks that after time smaller than timer interval, we have no signals
        for (int i = 0; i < 10; ++i)
            timer.scheduleUpdate();

        EXPECT_FALSE(spy.wait(timer_interval / 2));
        EXPECT_EQ(spy.count(), 2);
    */
}