summaryrefslogtreecommitdiffstats
path: root/test/unit/app/system_mock.h
blob: 2f2c46406bebb5d8f774fe72ee86d3070f440bd5 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * This file is part of the Colobot: Gold Edition source code
 * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
 * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://gnu.org/licenses
 */
#pragma once

#include "app/system.h"

#include <gmock/gmock.h>

class CSystemUtilsMock : public CSystemUtils
{
public:
    CSystemUtilsMock(bool defaultExpects = false)
    {
        if (defaultExpects)
            SetDefaultExpects();
    }

    virtual ~CSystemUtilsMock() {}

    void SetDefaultExpects()
    {
        using testing::_;
        using testing::Return;
        using testing::AnyNumber;

        EXPECT_CALL(*this, CreateTimeStamp()).Times(AnyNumber()).WillRepeatedly(Return(nullptr));
        EXPECT_CALL(*this, DestroyTimeStamp(_)).Times(AnyNumber());
        EXPECT_CALL(*this, CopyTimeStamp(_, _)).Times(AnyNumber());
        EXPECT_CALL(*this, GetCurrentTimeStamp(_)).Times(AnyNumber());

        EXPECT_CALL(*this, GetTimeStampResolution(_)).Times(AnyNumber()).WillRepeatedly(Return(0.0f));
        EXPECT_CALL(*this, GetTimeStampExactResolution()).Times(AnyNumber()).WillRepeatedly(Return(0ll));
        EXPECT_CALL(*this, TimeStampDiff(_, _, _)).Times(AnyNumber()).WillRepeatedly(Return(0.0f));
        EXPECT_CALL(*this, TimeStampExactDiff(_, _)).Times(AnyNumber()).WillRepeatedly(Return(0ll));
    }

    MOCK_METHOD0(Init, void());

    MOCK_METHOD3(SystemDialog, SystemDialogResult(SystemDialogType, const std::string &title, const std::string &message));
    MOCK_METHOD3(ConsoleSystemDialog, SystemDialogResult(SystemDialogType type, const std::string& title, const std::string& message));

    MOCK_METHOD0(CreateTimeStamp, SystemTimeStamp*());
    MOCK_METHOD1(DestroyTimeStamp, void (SystemTimeStamp *stamp));
    MOCK_METHOD2(CopyTimeStamp, void (SystemTimeStamp *dst, SystemTimeStamp *src));
    MOCK_METHOD1(GetCurrentTimeStamp, void (SystemTimeStamp *stamp));
    MOCK_METHOD1(GetTimeStampResolution, float (SystemTimeUnit unit));
    MOCK_METHOD0(GetTimeStampExactResolution, long long());
    MOCK_METHOD3(TimeStampDiff, float(SystemTimeStamp *before, SystemTimeStamp *after, SystemTimeUnit unit));
    MOCK_METHOD2(TimeStampExactDiff, long long(SystemTimeStamp *before, SystemTimeStamp *after));
};