diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-08-02 16:51:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-08-02 16:51:19 +0300 |
commit | 70a9ee7cc6a2402c33c3cdd33bc86f02fcb59ade (patch) | |
tree | b36e2984b41b251797670a7569d03138e7f863ac | |
parent | d0d872ffeff89facdd35ce358bd4d9b73cf8332c (diff) | |
download | manaverse-70a9ee7cc6a2402c33c3cdd33bc86f02fcb59ade.tar.gz manaverse-70a9ee7cc6a2402c33c3cdd33bc86f02fcb59ade.tar.bz2 manaverse-70a9ee7cc6a2402c33c3cdd33bc86f02fcb59ade.tar.xz manaverse-70a9ee7cc6a2402c33c3cdd33bc86f02fcb59ade.zip |
Draw each window in unit tests.
-rw-r--r-- | src/gui/gui.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/label.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/label.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/tabs/tab.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/tabs/tab.h | 2 | ||||
-rw-r--r-- | src/gui/windowmanager_unittest.cc | 115 |
6 files changed, 133 insertions, 3 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index a4b704079..294f4fc89 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -71,8 +71,11 @@ #include "gui/fonts/font.h" +#include "gui/widgets/label.h" #include "gui/widgets/window.h" +#include "gui/widgets/tabs/tab.h" + #ifndef DYECMD #include "dragdrop.h" #else @@ -289,6 +292,8 @@ Gui::~Gui() setTop(nullptr); delete2(mFocusHandler); + Label::final(); + Tab::final(); } void Gui::logic() diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 249534945..c32b72b99 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -284,3 +284,8 @@ void Label::widgetHidden(const Event &event A_UNUSED) mTextChanged = true; mTextChunk.deleteImage(); } + +void Label::final() +{ + mSkin = nullptr; +} diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index 9d6777b3b..028d1e8d5 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -172,6 +172,7 @@ class Label final : public Widget, static int mInstances; + static void final(); private: /** * Holds the caption of the label. diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index 2555ca52b..39e966886 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -478,3 +478,11 @@ void Tab::mouseExited(MouseEvent& event A_UNUSED) { mHasMouse = false; } + +void Tab::final() +{ + for (int f = 0; f < TAB_COUNT; f ++) + { + tabImg[f] = nullptr; + } +} diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index d32cc176c..74b9f46be 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -202,6 +202,8 @@ class Tab notfinal : public BasicContainer, void setImage(Image *const image); + static void final(); + protected: friend class TabbedArea; diff --git a/src/gui/windowmanager_unittest.cc b/src/gui/windowmanager_unittest.cc index 567e0c96e..5366f3e9a 100644 --- a/src/gui/windowmanager_unittest.cc +++ b/src/gui/windowmanager_unittest.cc @@ -156,12 +156,16 @@ TEST_CASE("Windows tests", "windowmanager") SECTION("bankWindow") { CREATEWIDGETV0(bankWindow, BankWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(bankWindow); } SECTION("buyDialog") { BuyDialog *dialog; CREATEWIDGETV(dialog, BuyDialog, BeingId_zero); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("BuyingStoreSellDialog") @@ -169,12 +173,16 @@ TEST_CASE("Windows tests", "windowmanager") BuyingStoreSellDialog *dialog; CREATEWIDGETV(dialog, BuyingStoreSellDialog, BeingId_zero, 0); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("BuySellDialog") { BuySellDialog *dialog; CREATEWIDGETV(dialog, BuySellDialog, BeingId_zero); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("ChangeEmailDialog") @@ -182,6 +190,8 @@ TEST_CASE("Windows tests", "windowmanager") LoginData data; ChangeEmailDialog *dialog; CREATEWIDGETV(dialog, ChangeEmailDialog, data); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("ChangePasswordDialog") @@ -189,6 +199,8 @@ TEST_CASE("Windows tests", "windowmanager") LoginData data; ChangePasswordDialog *dialog; CREATEWIDGETV(dialog, ChangePasswordDialog, data); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } /* @@ -212,6 +224,8 @@ TEST_CASE("Windows tests", "windowmanager") SECTION("ChatWindow") { CREATEWIDGETV0(chatWindow, ChatWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(chatWindow); } SECTION("ConfirmDialog") @@ -219,21 +233,29 @@ TEST_CASE("Windows tests", "windowmanager") ConfirmDialog *dialog; CREATEWIDGETV(dialog, ConfirmDialog, "", "", "", false, Modal_false, nullptr); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("CutinWindow") { CREATEWIDGETV0(cutInWindow, CutInWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(cutInWindow); } SECTION("DebugWindow") { CREATEWIDGETV0(debugWindow, DebugWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(debugWindow); } SECTION("didYouKnowWindow") { CREATEWIDGETV0(didYouKnowWindow, DidYouKnowWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(didYouKnowWindow); } SECTION("EditDialog") @@ -241,6 +263,8 @@ TEST_CASE("Windows tests", "windowmanager") EditDialog *dialog; CREATEWIDGETV(dialog, EditDialog, "", "", "", 100, nullptr, Modal_false); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("EditServerDialog") @@ -252,17 +276,23 @@ TEST_CASE("Windows tests", "windowmanager") settings.configDir); EditServerDialog *editServerDialog = CREATEWIDGETR(EditServerDialog, serverDialog, mCurrentServer, 0); + gui->draw(); + mainGraphics->updateScreen(); delete2(editServerDialog); delete2(serverDialog); } SECTION("EggSelectionDialog") { EggSelectionDialog *dialog = CREATEWIDGETR0(EggSelectionDialog); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("EmoteWindow") { EmoteWindow *dialog = CREATEWIDGETR0(EmoteWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("EquipmentWindow") @@ -275,6 +305,8 @@ TEST_CASE("Windows tests", "windowmanager") map); EquipmentWindow *dialog = CREATEWIDGETR(EquipmentWindow, equipment, being, false); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); delete2(being); delete2(map); @@ -283,6 +315,8 @@ TEST_CASE("Windows tests", "windowmanager") SECTION("helpWindow") { CREATEWIDGETV0(helpWindow, HelpWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(helpWindow); } SECTION("InsertCardDialog") @@ -299,6 +333,8 @@ TEST_CASE("Windows tests", "windowmanager") Equipped_false); InsertCardDialog *dialog = CREATEWIDGETR(InsertCardDialog, 0, item); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); delete2(item); } @@ -307,6 +343,8 @@ TEST_CASE("Windows tests", "windowmanager") Inventory *inventory = new Inventory(InventoryType::Inventory); InventoryWindow *dialog = CREATEWIDGETR(InventoryWindow, inventory); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); delete2(inventory); } @@ -324,12 +362,16 @@ TEST_CASE("Windows tests", "windowmanager") Equipped_false); ItemAmountWindow *dialog = CREATEWIDGETR(ItemAmountWindow, ItemAmountWindowUsage::ItemDrop, nullptr, item); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); delete2(item); } SECTION("KillStats") { CREATEWIDGETV0(killStats, KillStats); + gui->draw(); + mainGraphics->updateScreen(); delete2(killStats); } SECTION("loginDialog") @@ -339,11 +381,15 @@ TEST_CASE("Windows tests", "windowmanager") loginData, &mCurrentServer, &settings.options.updateHost); + gui->draw(); + mainGraphics->updateScreen(); delete2(loginDialog); } SECTION("MailEditWindow") { CREATEWIDGETV0(mailEditWindow, MailEditWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(mailEditWindow); } SECTION("MailViewWindow") @@ -351,31 +397,43 @@ TEST_CASE("Windows tests", "windowmanager") MailMessage *message = new MailMessage; CREATEWIDGETV(mailViewWindow, MailViewWindow, message); + gui->draw(); + mainGraphics->updateScreen(); delete2(mailViewWindow); } SECTION("MailWindow") { CREATEWIDGETV0(mailWindow, MailWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(mailWindow); } SECTION("Minimap") { CREATEWIDGETV0(minimap, Minimap); + gui->draw(); + mainGraphics->updateScreen(); delete2(minimap); } SECTION("MiniStatusWindow") { CREATEWIDGETV0(miniStatusWindow, MiniStatusWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(miniStatusWindow); } SECTION("NpcDialog") { NpcDialog *dialog = CREATEWIDGETR(NpcDialog, BeingId_zero); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("NpcSellDialog") { NpcSellDialog *dialog = CREATEWIDGETR(NpcSellDialog, BeingId_zero); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("OkDialog") @@ -383,28 +441,38 @@ TEST_CASE("Windows tests", "windowmanager") OkDialog *dialog = CREATEWIDGETR(OkDialog, "", "", "", DialogType::SILENCE, Modal_false, ShowCenter_true, nullptr, 100); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("OutfitWindow") { CREATEWIDGETV0(outfitWindow, OutfitWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(outfitWindow); } SECTION("QuestsWindow") { CREATEWIDGETV0(questsWindow, QuestsWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(questsWindow); } SECTION("QuitDialog") { CREATEWIDGETV(quitDialog, QuitDialog, &quitDialog); + gui->draw(); + mainGraphics->updateScreen(); delete2(quitDialog); } SECTION("RegisterDialog") { RegisterDialog *dialog = CREATEWIDGETR(RegisterDialog, loginData); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("serversDialog") @@ -414,11 +482,15 @@ TEST_CASE("Windows tests", "windowmanager") ServerDialog *serverDialog = CREATEWIDGETR(ServerDialog, &mCurrentServer, settings.configDir); + gui->draw(); + mainGraphics->updateScreen(); delete2(serverDialog); } SECTION("setupWindow") { CREATEWIDGETV0(setupWindow, SetupWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(setupWindow); } SECTION("ShopSellDialog") @@ -428,26 +500,36 @@ TEST_CASE("Windows tests", "windowmanager") SECTION("ShopWindow") { CREATEWIDGETV0(shopWindow, ShopWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(shopWindow); } SECTION("ShortcutWindow") { CREATEWIDGETV(itemShortcutWindow, ShortcutWindow, ""); + gui->draw(); + mainGraphics->updateScreen(); delete2(itemShortcutWindow); } SECTION("SkillDialog") { CREATEWIDGETV0(skillDialog, SkillDialog); + gui->draw(); + mainGraphics->updateScreen(); delete2(skillDialog); } SECTION("SocialWindow") { CREATEWIDGETV0(socialWindow, SocialWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(socialWindow); } SECTION("StatusWindow") { CREATEWIDGETV0(statusWindow, StatusWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(statusWindow); } SECTION("TextCommandEditor") @@ -456,34 +538,46 @@ TEST_CASE("Windows tests", "windowmanager") CommandTarget::NoTarget, ""); TextCommandEditor *dialog = CREATEWIDGETR(TextCommandEditor, textCommand); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("TextDialog") { TextDialog *dialog = CREATEWIDGETR(TextDialog, "", "", nullptr, false); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("TextSelectDialog") { TextSelectDialog *dialog = CREATEWIDGETR(TextSelectDialog, "", "", AllowQuit_false); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("TradeWindow") { CREATEWIDGETV0(tradeWindow, TradeWindow); + gui->draw(); + mainGraphics->updateScreen(); delete2(tradeWindow); } SECTION("UpdaterWindow") { CREATEWIDGETV(updaterWindow, UpdaterWindow, "", "", false, UpdateType::Skip); + gui->draw(); + mainGraphics->updateScreen(); delete2(updaterWindow); } SECTION("WhoIsOnline") { CREATEWIDGETV0(whoIsOnline, WhoIsOnline); + gui->draw(); + mainGraphics->updateScreen(); delete2(whoIsOnline); } SECTION("WorldSelectDialog") @@ -491,41 +585,57 @@ TEST_CASE("Windows tests", "windowmanager") Worlds worlds; WorldSelectDialog *dialog = CREATEWIDGETR(WorldSelectDialog, worlds); + gui->draw(); + mainGraphics->updateScreen(); delete2(dialog); } SECTION("popupMenu") { CREATEWIDGETV0(popupMenu, PopupMenu); + gui->draw(); + mainGraphics->updateScreen(); delete2(popupMenu); } SECTION("beingPopup") { CREATEWIDGETV0(beingPopup, BeingPopup); + gui->draw(); + mainGraphics->updateScreen(); delete2(beingPopup); } SECTION("textPopup") { CREATEWIDGETV0(textPopup, TextPopup); + gui->draw(); + mainGraphics->updateScreen(); delete2(textPopup); } SECTION("textBoxPopup") { CREATEWIDGETV0(textBoxPopup, TextBoxPopup); + gui->draw(); + mainGraphics->updateScreen(); delete2(textBoxPopup); } SECTION("itemPopup") { CREATEWIDGETV0(itemPopup, ItemPopup); + gui->draw(); + mainGraphics->updateScreen(); delete2(itemPopup); } SECTION("spellPopup") { CREATEWIDGETV0(spellPopup, SpellPopup); + gui->draw(); + mainGraphics->updateScreen(); delete2(spellPopup); } SECTION("desktop") { CREATEWIDGETV(desktop, Desktop, nullptr); + gui->draw(); + mainGraphics->updateScreen(); delete2(desktop); } SECTION("connectionDialog") @@ -534,12 +644,11 @@ TEST_CASE("Windows tests", "windowmanager") // TRANSLATORS: connection dialog header _("Logging in"), State::SWITCH_SERVER); + gui->draw(); + mainGraphics->updateScreen(); delete2(connectionDialog); } - gui->draw(); - mainGraphics->updateScreen(); - delete2(userPalette); delete2(client); delete2(serverFeatures); |