summaryrefslogtreecommitdiffstats
path: root/test/unit/app/system_mock.h
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2013-03-24 00:03:37 +0100
committerPiotr Dziwinski <piotrdz@gmail.com>2013-03-24 12:00:12 +0100
commit195d6cded05f7ef5bde695ee047b341a0265eab3 (patch)
treeaf6ffa3622ae9bf7f2f5f065e269e86a019af854 /test/unit/app/system_mock.h
parentc211b001d2a4c9b36034a812650f1a2ac693ee54 (diff)
downloadcolobot-195d6cded05f7ef5bde695ee047b341a0265eab3.tar.gz
colobot-195d6cded05f7ef5bde695ee047b341a0265eab3.tar.bz2
colobot-195d6cded05f7ef5bde695ee047b341a0265eab3.zip
Fixed timer functions on win32
* changed win32 implementation to QueryPerformaceTimer system function * refactored system utils code * proper tests for time utils and update event creation in application * should fix issue #134
Diffstat (limited to 'test/unit/app/system_mock.h')
-rw-r--r--test/unit/app/system_mock.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/unit/app/system_mock.h b/test/unit/app/system_mock.h
new file mode 100644
index 0000000..470a4e1
--- /dev/null
+++ b/test/unit/app/system_mock.h
@@ -0,0 +1,48 @@
+#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));
+};