170 lines
9.6 KiB
Lua
170 lines
9.6 KiB
Lua
-- Run by camelot_change_realm_test.py inside the existing Source picker fixture.
|
|
-- Native entry points record calls only. Each native login state is a test input.
|
|
return function(picker)
|
|
local root = assert(arg[3])
|
|
local function loadUI(path) assert(loadfile(root .. "/" .. path))() end
|
|
local function noop() end
|
|
local function no() return false end
|
|
|
|
CharacterSelectUtil, StaticPopupDialogs = {}, {}
|
|
CallbackRegistryMixin = {GenerateCallbackEvents = noop}
|
|
GetCVarBool, CreateColor, setprinthandler = no, noop, noop
|
|
FrameUtil = { RegisterFrameForEvents = noop }
|
|
function CreateFrame() return { SetScript = noop } end
|
|
SmartNavigation_UseVerticalCursorForFrame = noop
|
|
function GenerateFlatClosure(f, ...)
|
|
local args = {...}
|
|
return function() return f(unpack(args)) end
|
|
end
|
|
loadUI("blizzard_gluexml/mainline/characterselect/characterselectutil.lua")
|
|
loadUI("blizzard_gluexml/camelot/characterselect/characterselectutil.lua")
|
|
loadUI("blizzard_characterselectnavbar/characterselectnavbar.lua")
|
|
loadUI("blizzard_characterselectnavbar/camelot/characterselectnavbar.lua")
|
|
loadUI("blizzard_glueparent/mainline/glueparent.lua")
|
|
loadUI("blizzard_gluexml/mainline/characterselect.lua")
|
|
loadUI("blizzard_gluexml/mainline/characterselect/characterselectui.lua")
|
|
|
|
local oldState = C_Login.GetState
|
|
local state = {connectedToWoW = true, hasSelectedExperiencePreset = true,
|
|
auroraState = 0, hasRealmList = false, superDistrictChoicePending = false, waitingForRuleSets = false}
|
|
C_Login.GetState = function() return state end
|
|
LE_AURORA_STATE_NONE, LE_WOW_CONNECTION_STATE_CONNECTING = 0, 1
|
|
Kiosk = { IsEnabled = no, IsCompetitiveModeEnabled = no }
|
|
C_GameRules = { GetGameModeGlueScreenName = noop }
|
|
IsRetrievingCharacters = no
|
|
C_Log = { LogMessage = noop }
|
|
GlueParent = {currentScreen = "charselect"}
|
|
local transitions = {}
|
|
-- Observe the chosen screen at the native rendering boundary.
|
|
function GlueParent_SetScreen(screen)
|
|
table.insert(transitions, screen)
|
|
GlueParent.currentScreen = screen
|
|
end
|
|
local calls = {}
|
|
function StartSuperDistrictSelection() table.insert(calls, "start") end
|
|
function SelectSuperDistrict(id) table.insert(calls, "select " .. id) end
|
|
function ConnectToSuperDistrictRealm() table.insert(calls, "connect") end
|
|
function ExitSuperDistrictSelection() table.insert(calls, "exit") end
|
|
local showRealmsControl = false
|
|
C_RealmList = {
|
|
ShouldShowRealmsAsCheatButton = function() return showRealmsControl end,
|
|
RequestChangeRealmList = function() table.insert(calls, "realms") end,
|
|
}
|
|
CharacterSelectListUtil = { SaveCharacterOrder = noop }
|
|
CharacterSelectCharacterFrame = { ClearSearch = noop }
|
|
CHARACTER_SELECT_NAV_BAR_SUPER_DISTRICTS, CHARACTER_SELECT_NAV_BAR_REALMS = "Districts", "Realms"
|
|
|
|
local nav = CreateFromMixins(CharacterSelectNavBarMixin)
|
|
nav.realmsButtonAvailable, nav.superDistrictsButtonAvailable = arg[4] == "true", arg[5] == "true"
|
|
-- Exercise actual OnLoad, button setup, AddButton and generated OnClick.
|
|
-- Only the two realm buttons and their callbacks are relevant here.
|
|
nav.SetButtonVisuals, nav.ResetButtonVisuals = noop, noop
|
|
nav.ButtonTray = {
|
|
SetButtonSetup = function(self, setup) self.setup = setup end,
|
|
AddControl = function(self, ...)
|
|
local button = {
|
|
SetWidth = noop, GetTextWidth = function() return 8 end,
|
|
SetEnabled = function(b, enabled) b.enabled = enabled end,
|
|
SetText = function(b, label) b.label = label end,
|
|
SetScript = function(b, event, handler) b[event] = handler end,
|
|
}
|
|
self.setup(button, ...)
|
|
return button
|
|
end,
|
|
}
|
|
nav:OnLoad()
|
|
assert(nav.SuperDistrictsButton and not nav.RealmsButton, "ordinary Camelot layout must expose only Districts")
|
|
assert(nav.SuperDistrictsButton.label == CHARACTER_SELECT_NAV_BAR_SUPER_DISTRICTS)
|
|
-- Drive the real per-frame enable decision. Other controls only consume
|
|
-- output from this handler; their rendering is outside the fixture.
|
|
local view = setmetatable({}, {__index = function() return noop end})
|
|
local gates = {}
|
|
GetNumCharacters, GetMaxWarbandGroupCount = function() return 1 end, function() return 8 end
|
|
GetCharacterUndeleteStatus, GetCharacterGUID, GetCharacterSelection = no, noop, noop
|
|
CharacterSelect = {}
|
|
CharSelectServicesFlowFrame = {ShouldDisableButtons = function() return gates.service end}
|
|
AccountReactivationInProgressDialog = {IsShown = function() return gates.redemption end}
|
|
GoldReactivateConfirmationDialog, TokenReactivateConfirmationDialog = {IsShown = no}, {IsShown = no}
|
|
C_AccountServices, C_StorePublic = {IsAccountLockedPostSave = no}, {IsEnabled = no}
|
|
CharacterSelect_AllowedToEnterWorld, CharacterSelect_IsRetrievingCharacterList = no, no
|
|
CharacterSelectListUtil.GetTotalGroupCount = function() return 0 end
|
|
CharacterSelectCharacterFrame, CharSelectEnterWorldButton, CharacterSelectBackButton = view, view, view
|
|
CharSelectAccountUpgradePanel, CharacterTemplatesFrame = {UpgradeButton = view}, {CreateTemplateButton = view}
|
|
CharSelectUndeleteCharacterButton, CopyCharacterButton, ActivateFactionChange = view, view, {SetEnabled = noop, texture = view}
|
|
C_GameRules.GetActiveGameMode, GameRulesUtil = noop, {GetActiveAccountStore = noop}
|
|
Enum = {GameMode = {}}
|
|
nav.UpdateButtonDividerState = noop
|
|
CharacterSelectUI = setmetatable({
|
|
SetChangeSuperDistrictEnabled = CharacterSelectUIMixin.SetChangeSuperDistrictEnabled,
|
|
SetChangeRealmEnabled = CharacterSelectUIMixin.SetChangeRealmEnabled,
|
|
IsCollectionsActive = function() return gates.collections end,
|
|
GetConfig = function() return {} end,
|
|
VisibilityToggleButton = view,
|
|
VisibilityFramesContainer = {NavBar = nav, InfoButton = view, RewardsButton = view},
|
|
}, {__index = view})
|
|
for _, field in ipairs({"service", "redemption", "collections", "undeleting"}) do
|
|
gates[field] = true
|
|
CharacterSelect.undeleting = gates.undeleting
|
|
CharacterSelect_UpdateButtonState()
|
|
assert(nav.SuperDistrictsButton.enabled == false, field .. " must disable the ordinary district button")
|
|
gates[field] = nil
|
|
CharacterSelect.undeleting = nil
|
|
end
|
|
CharacterSelect_UpdateButtonState()
|
|
assert(nav.SuperDistrictsButton.enabled, "ordinary character-select state must enable the district button")
|
|
GlueParent_EnsureValidScreen()
|
|
nav.SuperDistrictsButton:OnClick()
|
|
assert(table.concat(calls, ",") == "start", "ordinary button must start stock district selection exactly once")
|
|
GlueParent_EnsureValidScreen()
|
|
assert(GlueParent.currentScreen == "charselect" and #transitions == 0)
|
|
|
|
-- Independent native state observations, not consequences inferred from Start.
|
|
state.superDistrictChoicePending, state.waitingForRuleSets = true, true
|
|
assert(GlueParent_GetBestScreen() == "charselect", "district list still waiting for rulesets")
|
|
state.waitingForRuleSets = false
|
|
GlueParent_EnsureValidScreen()
|
|
assert(table.concat(transitions, ",") == "superdistrict" and GlueParent_IsScreenValid("superdistrict"))
|
|
|
|
local districts = {
|
|
{superDistrictID = 41, displayName = "First", description = "Open"},
|
|
{superDistrictID = 92, displayName = "Second", description = "Open"},
|
|
{superDistrictID = 73, displayName = "Unavailable", description = "Closed", disallowLogin = true},
|
|
}
|
|
C_DistrictUtils.GetAvailableSuperDistricts = function() return districts end
|
|
C_DistrictUtils.GetSuperDistrictInfo = function(id)
|
|
for _, entry in ipairs(districts) do
|
|
if entry.superDistrictID == id then return entry end
|
|
end
|
|
error("unadvertised stock district ID " .. tostring(id))
|
|
end
|
|
picker:OnEvent("SUPER_DISTRICT_LIST_UPDATED")
|
|
assert(#picker.districtButtons == 3, "stock provider owns the connected district list")
|
|
for index, row in ipairs(picker.districtButtons) do
|
|
local entry = districts[index]
|
|
assert(row.layoutIndex == index and row.superDistrictID == entry.superDistrictID)
|
|
assert(row.Title:GetText() == entry.displayName and row.enabled == (not entry.disallowLogin))
|
|
end
|
|
picker.districtButtons[2]:OnClick()
|
|
assert(picker.SelectButton.enabled and picker.selectedSuperDistrictID == 92 and picker.districtButtons[2].checked)
|
|
EventRegistry:TriggerEvent("SuperDistrict.ConfirmSuperDistrict")
|
|
assert(table.concat(calls, ",") == "start,select 92,connect", "stock confirmation must forward the selected district ID")
|
|
EventRegistry:TriggerEvent("SuperDistrict.CancelSelection")
|
|
assert(table.concat(calls, ",") == "start,select 92,connect,exit", "connected cancel must use the native exit")
|
|
|
|
state.superDistrictChoicePending = false
|
|
GlueParent_EnsureValidScreen()
|
|
assert(table.concat(transitions, ",") == "superdistrict,charselect")
|
|
state.hasRealmList = true
|
|
assert(GlueParent_GetBestScreen() == "realmlist" and GlueParent_IsScreenValid("realmlist"))
|
|
|
|
-- The separate Realms control uses the global stock API when explicitly enabled.
|
|
showRealmsControl = true
|
|
nav:OnEvent("CLIENT_FEATURE_STATUS_CHANGED")
|
|
assert(nav.RealmsButton and nav.RealmsButton.label == CHARACTER_SELECT_NAV_BAR_REALMS)
|
|
nav.RealmsButton:OnClick()
|
|
assert(table.concat(calls, ",") == "start,select 92,connect,exit,realms")
|
|
C_Login.GetState = oldState
|
|
C_DistrictUtils.GetAvailableSuperDistricts = function() return {} end
|
|
print("PASS Camelot ordinary/optional clicks, native screen inputs, populated stock selection and connected cancel")
|
|
end
|