1 /* 2 GWEN 3 Copyright (c) 2011 Facepunch Studios 4 See license in Gwen.h 5 */ 6 7 #pragma once 8 #ifndef GWEN_UNITTEST_UNITTEST_H 9 #define GWEN_UNITTEST_UNITTEST_H 10 11 #include "Gwen/Gwen.h" 12 #include "Gwen/Align.h" 13 #include "Gwen/Utility.h" 14 #include "Gwen/Controls/WindowControl.h" 15 #include "Gwen/Controls/TabControl.h" 16 #include "Gwen/Controls/ListBox.h" 17 18 class UnitTest; 19 20 class GUnit : public Gwen::Controls::Base 21 { 22 public: GWEN_CONTROL_INLINE(GUnit,Gwen::Controls::Base)23 GWEN_CONTROL_INLINE(GUnit, Gwen::Controls::Base) 24 { 25 m_pUnitTest = NULL; 26 } 27 SetUnitTest(UnitTest * u)28 void SetUnitTest(UnitTest* u) { m_pUnitTest = u; } 29 30 void UnitPrint(const Gwen::UnicodeString& str); 31 void UnitPrint(const Gwen::String& str); 32 33 UnitTest* m_pUnitTest; 34 }; 35 36 class UnitTest : public Gwen::Controls::WindowControl 37 { 38 public: 39 GWEN_CONTROL(UnitTest, Gwen::Controls::WindowControl); 40 41 void PrintText(const Gwen::UnicodeString& str); 42 43 void Render(Gwen::Skin::Base* skin); 44 45 private: 46 Gwen::Controls::TabControl* m_TabControl; 47 Gwen::Controls::ListBox* m_TextOutput; 48 unsigned int m_iFrames; 49 float m_fLastSecond; 50 }; 51 52 #define DEFINE_UNIT_TEST(name, displayname) \ 53 GUnit* RegisterUnitTest_##name(Gwen::Controls::TabControl* tab) \ 54 { \ 55 GUnit* u = new name(tab); \ 56 tab->AddPage(displayname, u); \ 57 return u; \ 58 } 59 #endif 60