From 209c6412ae149cc7c503fd7da384f344a830423c Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 3 Feb 2013 20:03:36 +0100 Subject: Refactoring in tests infrastructure * all tests are now in /test/ subdirectory * unit tests concatenated to one executable (TODO: ui, common) * preparation for test environments (OpenGL and others) * removed old TestCBot --- src/ui/test/edit_test.cpp | 73 ----------------------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 src/ui/test/edit_test.cpp (limited to 'src/ui/test/edit_test.cpp') diff --git a/src/ui/test/edit_test.cpp b/src/ui/test/edit_test.cpp deleted file mode 100644 index 489b873..0000000 --- a/src/ui/test/edit_test.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "../edit.h" -#include "../../app/app.h" -#include "mocks/text_mock.h" -#include -#include -#include - -class CEditTest : public testing::Test -{ -public: - CEditTest(){}; - - virtual void SetUp() - { - m_engine = new Gfx::CEngine(&m_iMan, NULL); - - m_iMan.AddInstance(CLASS_ENGINE, m_engine); - m_edit = new Ui::CEdit; - } - - virtual void TearDown() - { - m_iMan.DeleteInstance(CLASS_ENGINE, m_engine); - delete m_engine; - m_engine = NULL; - delete m_edit; - m_edit = NULL; - - } - virtual ~CEditTest() - { - - }; - -protected: - CInstanceManager m_iMan; - CApplication m_app; - Gfx::CEngine * m_engine; - Ui::CEdit * m_edit; - CLogger m_logger; -}; - -using ::testing::_; -using ::testing::Return; - -TEST_F(CEditTest, WriteTest) -{ - ASSERT_TRUE(true); - CTextMock * text = dynamic_cast(m_engine->GetText()); - EXPECT_CALL(*text, GetCharWidth(_, _, _, _)).WillRepeatedly(Return(1.0f)); - EXPECT_CALL(*text, GetStringWidth(_, _, _)).WillOnce(Return(1.0f)); - std::string filename = "test.file"; - m_edit->SetMaxChar(Ui::EDITSTUDIOMAX); - m_edit->SetAutoIndent(true); - std::string inputScript = "{\ntext1\ntext2\n\ntext3\n{\ntext4\n}\n}"; - std::string expectedScript = "{\r\n\ttext1\r\n\ttext2\r\n\t\r\n\ttext3\r\n\t{\r\n\t\ttext4\r\n\t}\r\n}"; - m_edit->SetText(inputScript.c_str(), true); - GetLogger()->Info("Writing text \n"); - m_edit->WriteText("script.txt"); - - std::fstream scriptFile; - - scriptFile.open("script.txt", std::ios_base::binary | std::ios_base::in); - std::string outputScript((std::istreambuf_iterator(scriptFile)), std::istreambuf_iterator()); - ASSERT_STREQ(expectedScript.c_str(), outputScript.c_str()); -} - -int main(int argc, char *argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - -- cgit v1.2.3-1-g7c22