Fixed edit_test

dev-ui
Piotr Dziwinski 2013-03-27 23:48:44 +01:00
parent 8659fb984f
commit 212f2e41f8
4 changed files with 54 additions and 24 deletions

View File

@ -7,25 +7,35 @@ ${GTEST_INCLUDE_DIR}
${GMOCK_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR}
) )
# add_executable(edit_test # Platform-dependent implementation of CSystemUtils
# ${SRC_DIR}/common/event.cpp if (${PLATFORM_WINDOWS})
# ${SRC_DIR}/common/logger.cpp set(SYSTEM_CPP_MODULE "system_windows.cpp")
# ${SRC_DIR}/common/misc.cpp elseif(${PLATFORM_LINUX})
# ${SRC_DIR}/common/profile.cpp set(SYSTEM_CPP_MODULE "system_linux.cpp")
# ${SRC_DIR}/common/iman.cpp else()
# ${SRC_DIR}/common/stringutils.cpp set(SYSTEM_CPP_MODULE "system_other.cpp")
# ${SRC_DIR}/graphics/engine/text.cpp endif()
# ${SRC_DIR}/ui/button.cpp
# ${SRC_DIR}/ui/control.cpp add_executable(edit_test
# ${SRC_DIR}/ui/edit.cpp ${SRC_DIR}/app/system.cpp
# ${SRC_DIR}/ui/scroll.cpp ${SRC_DIR}/app/${SYSTEM_CPP_MODULE}
# stubs/app_stub.cpp ${SRC_DIR}/common/event.cpp
# stubs/engine_stub.cpp ${SRC_DIR}/common/logger.cpp
# stubs/particle_stub.cpp ${SRC_DIR}/common/misc.cpp
# stubs/restext_stub.cpp ${SRC_DIR}/common/profile.cpp
# stubs/robotmain_stub.cpp ${SRC_DIR}/common/iman.cpp
# edit_test.cpp) ${SRC_DIR}/common/stringutils.cpp
# target_link_libraries(edit_test gtest gmock ${SDL_LIBRARY} ${SDLTTF_LIBRARY} ${Boost_LIBRARIES}) ${SRC_DIR}/graphics/engine/text.cpp
# ${SRC_DIR}/ui/button.cpp
# TODO: Edit test doesn't work, comment it away for now ${SRC_DIR}/ui/control.cpp
# add_test(edit_test ./edit_test) ${SRC_DIR}/ui/edit.cpp
${SRC_DIR}/ui/scroll.cpp
stubs/app_stub.cpp
stubs/engine_stub.cpp
stubs/particle_stub.cpp
stubs/restext_stub.cpp
stubs/robotmain_stub.cpp
edit_test.cpp)
target_link_libraries(edit_test gtest gmock ${SDL_LIBRARY} ${SDLTTF_LIBRARY} ${Boost_LIBRARIES})
add_test(edit_test ./edit_test)

View File

@ -9,10 +9,16 @@
class CEditTest : public testing::Test class CEditTest : public testing::Test
{ {
public: public:
CEditTest(){}; CEditTest()
: m_robotMain(nullptr)
, m_engine(nullptr)
, m_edit(nullptr)
{}
virtual void SetUp() virtual void SetUp()
{ {
m_robotMain = new CRobotMain(&m_app);
m_engine = new Gfx::CEngine(nullptr); m_engine = new Gfx::CEngine(nullptr);
m_edit = new Ui::CEdit; m_edit = new Ui::CEdit;
@ -20,6 +26,8 @@ public:
virtual void TearDown() virtual void TearDown()
{ {
delete m_robotMain;
m_robotMain = nullptr;
delete m_engine; delete m_engine;
m_engine = nullptr; m_engine = nullptr;
delete m_edit; delete m_edit;
@ -33,6 +41,7 @@ public:
protected: protected:
CApplication m_app; CApplication m_app;
CRobotMain* m_robotMain;
Gfx::CEngine * m_engine; Gfx::CEngine * m_engine;
Ui::CEdit * m_edit; Ui::CEdit * m_edit;
CLogger m_logger; CLogger m_logger;
@ -46,7 +55,7 @@ TEST_F(CEditTest, WriteTest)
ASSERT_TRUE(true); ASSERT_TRUE(true);
CTextMock * text = dynamic_cast<CTextMock *>(m_engine->GetText()); CTextMock * text = dynamic_cast<CTextMock *>(m_engine->GetText());
EXPECT_CALL(*text, GetCharWidth(_, _, _, _)).WillRepeatedly(Return(1.0f)); EXPECT_CALL(*text, GetCharWidth(_, _, _, _)).WillRepeatedly(Return(1.0f));
EXPECT_CALL(*text, GetStringWidth(_, _, _)).WillOnce(Return(1.0f)); EXPECT_CALL(*text, GetStringWidth(_, _, _, _)).WillOnce(Return(1.0f));
std::string filename = "test.file"; std::string filename = "test.file";
m_edit->SetMaxChar(Ui::EDITSTUDIOMAX); m_edit->SetMaxChar(Ui::EDITSTUDIOMAX);
m_edit->SetAutoIndent(true); m_edit->SetAutoIndent(true);

View File

@ -16,6 +16,9 @@ public:
}; };
MOCK_METHOD4(GetCharWidth, float(Gfx::UTF8Char, Gfx::FontType, float, float)); MOCK_METHOD4(GetCharWidth, float(Gfx::UTF8Char, Gfx::FontType, float, float));
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)); MOCK_METHOD3(GetStringWidth, float(const std::string &, Gfx::FontType, float));
}; };

View File

@ -3,6 +3,14 @@
template<> CRobotMain* CSingleton<CRobotMain>::m_instance = nullptr; template<> CRobotMain* CSingleton<CRobotMain>::m_instance = nullptr;
CRobotMain::CRobotMain(CApplication* app)
{
}
CRobotMain::~CRobotMain()
{
}
bool CRobotMain::GetGlint() bool CRobotMain::GetGlint()
{ {
return false; return false;