Reviewed UI sources from 5df4a4f028581d347411727d0309e5f434b75668. The addon regression tests passed in this checkout.
51 lines
2.3 KiB
Lua
51 lines
2.3 KiB
Lua
-- Exercise the 70334 chat API with a different default and active tab.
|
|
local frame = { RegisterEvent = function() end, SetScript = function() end };
|
|
function CreateFrame() return frame; end
|
|
StaticPopupDialogs, SlashCmdList = {}, {};
|
|
local preview, sendLog, errorText;
|
|
function StaticPopup_Show(_, text) preview = text; end
|
|
UIErrorsFrame = { AddMessage = function(_, text) errorText = text; end };
|
|
local function editBox(chatType, target, language)
|
|
local attributes = { chatType = chatType, tellTarget = target, channelTarget = target };
|
|
return { languageID = language, GetAttribute = function(_, key) return attributes[key]; end };
|
|
end
|
|
local active, last;
|
|
ChatFrameUtil = {
|
|
GetActiveWindow = function() return active; end,
|
|
GetLastActiveWindow = function() return last; end,
|
|
};
|
|
DEFAULT_CHAT_FRAME = { editBox = editBox("SAY", nil, 1) };
|
|
function GetChannelName(target)
|
|
if target == "Trade" then return 2, "Trade"; end
|
|
return 0, nil;
|
|
end
|
|
C_ChatInfo = { SendChatMessage = function(...)
|
|
sendLog[#sendLog + 1] = { ... };
|
|
end };
|
|
dofile("client_addons/WoWHybridUI/NativeProfessionMaterialsChat.lua");
|
|
local ui = WoWHybridUI;
|
|
ui.BuildMaterialsMessage = function() return { "header", "material" }; end
|
|
local dialog = StaticPopupDialogs.WOWHYBRID_SAY_REAGENTS;
|
|
|
|
local function expectDelivery(box, lastBox, chatType, target, language)
|
|
active, last, sendLog, preview = box, lastBox, {}, nil;
|
|
ui.SayMaterials(1);
|
|
assert(preview and #sendLog == 0, "confirmation required");
|
|
active = DEFAULT_CHAT_FRAME.editBox;
|
|
dialog.OnAccept();
|
|
assert(#sendLog == 2);
|
|
for _, entry in ipairs(sendLog) do
|
|
assert(entry[2] == chatType and entry[3] == language and entry[4] == target,
|
|
"must use the confirmed destination and language");
|
|
end
|
|
end
|
|
expectDelivery(editBox("GUILD", nil, 7), nil, "GUILD", nil, 7);
|
|
expectDelivery(nil, editBox("WHISPER", "Fixture", 1), "WHISPER", "Fixture", 1);
|
|
expectDelivery(editBox("CHANNEL", "Trade", 7), nil, "CHANNEL", 2, 7);
|
|
for _, box in ipairs({editBox("CHANNEL", "Missing"), editBox("WHISPER", ""), editBox("BN_WHISPER", "Fixture")}) do
|
|
active, preview, errorText, sendLog = box, nil, nil, {};
|
|
ui.SayMaterials(1);
|
|
assert(errorText and not preview and #sendLog == 0, "unusable target must not send");
|
|
end
|
|
print("PASS: active guild, last whisper, named channel, language and unavailable destinations");
|