diff options
author | Didier Raboud <odyx@debian.org> | 2014-07-02 11:33:47 +0200 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2014-07-02 11:33:47 +0200 |
commit | 2e136acd34c45e5e6d105cabf91c67e5865c38fe (patch) | |
tree | 8561603160cce0b41ba31250539a22d37a2951de /test/unit/ui | |
parent | 562be6fe765d7742f7c38fbd82f8cc26369e238b (diff) | |
parent | d9fee8b2adad613cf8c10d153cd5cd7b261b7863 (diff) | |
download | colobot-2e136acd34c45e5e6d105cabf91c67e5865c38fe.tar.gz colobot-2e136acd34c45e5e6d105cabf91c67e5865c38fe.tar.bz2 colobot-2e136acd34c45e5e6d105cabf91c67e5865c38fe.zip |
Merge tag 'colobot-gold-0.1.3-alpha' into debian
Diffstat (limited to 'test/unit/ui')
-rw-r--r-- | test/unit/ui/CMakeLists.txt | 3 | ||||
-rw-r--r-- | test/unit/ui/edit_test.cpp | 23 | ||||
-rw-r--r-- | test/unit/ui/mocks/text_mock.h | 16 | ||||
-rw-r--r-- | test/unit/ui/stubs/app_stub.cpp | 10 | ||||
-rw-r--r-- | test/unit/ui/stubs/restext_stub.cpp | 2 |
5 files changed, 30 insertions, 24 deletions
diff --git a/test/unit/ui/CMakeLists.txt b/test/unit/ui/CMakeLists.txt index 8086967..7f7b2f8 100644 --- a/test/unit/ui/CMakeLists.txt +++ b/test/unit/ui/CMakeLists.txt @@ -10,8 +10,6 @@ ${CLIPBOARD_INCLUDE_DIR} # Platform-dependent implementation of CSystemUtils if(PLATFORM_WINDOWS) -elseif(PLATFORM_LINUX) - set(ADDITIONAL_LIB "-lX11") elseif(PLATFORM_MACOSX) set(ADDITIONAL_LIB "${X11_X11_LIB}") else() @@ -19,6 +17,7 @@ else() endif() add_executable(edit_test +${SRC_DIR}/app/gamedata.cpp ${SRC_DIR}/app/system.cpp ${SRC_DIR}/app/${SYSTEM_CPP_MODULE} ${SRC_DIR}/app/system_other.cpp diff --git a/test/unit/ui/edit_test.cpp b/test/unit/ui/edit_test.cpp index 21af00f..34af013 100644 --- a/test/unit/ui/edit_test.cpp +++ b/test/unit/ui/edit_test.cpp @@ -1,4 +1,5 @@ #include "app/app.h" +#include "app/gamedata.h" #include "ui/edit.h" @@ -14,6 +15,7 @@ class CEditTest : public testing::Test public: CEditTest() : m_robotMain(nullptr) + , m_gameData(nullptr) , m_engine(nullptr) , m_edit(nullptr) {} @@ -21,21 +23,24 @@ public: virtual void SetUp() { m_robotMain = new CRobotMain(&m_app, false); - + + m_gameData = new CGameData(); + m_engine = new Gfx::CEngine(nullptr); - + m_edit = new Ui::CEdit; } virtual void TearDown() { - delete m_robotMain; - m_robotMain = nullptr; - delete m_engine; - m_engine = nullptr; delete m_edit; m_edit = nullptr; - + delete m_engine; + m_engine = nullptr; + delete m_gameData; + m_gameData = nullptr; + delete m_robotMain; + m_robotMain = nullptr; } virtual ~CEditTest() { @@ -45,12 +50,14 @@ public: protected: CApplication m_app; CRobotMain* m_robotMain; + CGameData * m_gameData; Gfx::CEngine * m_engine; Ui::CEdit * m_edit; CLogger m_logger; }; using ::testing::_; +using ::testing::An; using ::testing::Return; TEST_F(CEditTest, WriteTest) @@ -58,7 +65,7 @@ TEST_F(CEditTest, WriteTest) ASSERT_TRUE(true); CTextMock * text = dynamic_cast<CTextMock *>(m_engine->GetText()); EXPECT_CALL(*text, GetCharWidth(_, _, _, _)).WillRepeatedly(Return(1.0f)); - EXPECT_CALL(*text, GetStringWidth(_, _, _, _)).WillOnce(Return(1.0f)); + EXPECT_CALL(*text, GetStringWidth(An<const std::string&>(), _, _, _)).WillOnce(Return(1.0f)); std::string filename = "test.file"; m_edit->SetMaxChar(Ui::EDITSTUDIOMAX); m_edit->SetAutoIndent(true); diff --git a/test/unit/ui/mocks/text_mock.h b/test/unit/ui/mocks/text_mock.h index f38b977..b9af6d3 100644 --- a/test/unit/ui/mocks/text_mock.h +++ b/test/unit/ui/mocks/text_mock.h @@ -15,11 +15,21 @@ public: { }; - MOCK_METHOD4(GetCharWidth, float(Gfx::UTF8Char, Gfx::FontType, float, float)); + MOCK_METHOD4(GetCharWidth, float(Gfx::UTF8Char ch, + Gfx::FontType type, + float size, + float offset)); MOCK_METHOD4(GetStringWidth, float(const std::string &text, std::vector<Gfx::FontMetaChar>::iterator format, - std::vector<Gfx::FontMetaChar>::iterator end, float size)); - MOCK_METHOD3(GetStringWidth, float(const std::string &, Gfx::FontType, float)); + std::vector<Gfx::FontMetaChar>::iterator end, + float size)); + MOCK_METHOD3(GetStringWidth, float(std::string text, + Gfx::FontType font, + float size)); + MOCK_METHOD4(GetStringWidth, float(Gfx::UTF8Char ch, + Gfx::FontType font, + float size, + float offset)); }; diff --git a/test/unit/ui/stubs/app_stub.cpp b/test/unit/ui/stubs/app_stub.cpp index 960972f..95430d8 100644 --- a/test/unit/ui/stubs/app_stub.cpp +++ b/test/unit/ui/stubs/app_stub.cpp @@ -21,11 +21,6 @@ CApplication::~CApplication() { } -std::string CApplication::GetDataFilePath(DataDir /* dataDir */, const std::string& subpath) const -{ - return subpath; -} - CSoundInterface* CApplication::GetSound() { return nullptr; @@ -36,11 +31,6 @@ CEventQueue* CApplication::GetEventQueue() return nullptr; } -std::string CApplication::GetDataDirPath() const -{ - return ""; -} - Event CApplication::CreateUpdateEvent() { return Event(EVENT_NULL); diff --git a/test/unit/ui/stubs/restext_stub.cpp b/test/unit/ui/stubs/restext_stub.cpp index 004da19..fa47da6 100644 --- a/test/unit/ui/stubs/restext_stub.cpp +++ b/test/unit/ui/stubs/restext_stub.cpp @@ -1,6 +1,6 @@ #include "common/restext.h" -bool GetResource(ResType /* type */, int /* num */, char* /* text */) +bool GetResource(ResType /* type */, int /* num */, std::string& /* text */) { return true; } |