local a=require("\078\101\120\117\115\085\110\105\116\084\101\115\116\105\110\103")local L=require((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\078\101\120\117\115\080\108\117\103\105\110\070\114\097\109\101\119\111\114\107"))local b=L:GetResource("\085\073\046\083\099\114\111\108\108\046\078\101\120\117\115\083\099\114\111\108\108\066\097\114")a:RegisterUnitTest("\067\111\110\115\116\114\117\099\116\111\114",function(a)local L=b.new("\081\116\053",Enum.Axis.X)a:AssertEquals(L.ClassName,"\078\101\120\117\115\083\099\114\111\108\108\066\097\114","\067\108\097\115\115 \110\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(L.Name,"\078\101\120\117\115\083\099\114\111\108\108\066\097\114","\078\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(tostring(L),"\078\101\120\117\115\083\099\114\111\108\108\066\097\114","\078\097\109\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(#L:GetChildren(),0,"\067\104\105\108\100\114\101\110 \097\114\101\110\'\116 \104\105\100\100\101\110\046")end)a:RegisterUnitTest("\081\116\053\088\065\120\105\115",function(a)local L=b.new("\081\116\053",Enum.Axis.X)L:__SetChangedOverride("\065\098\115\111\108\117\116\101\083\105\122\101",function() end)L.Size=UDim2.new(0,400,0,20)L.AbsoluteSize=Vector2.new(400,20)local Y=L:GetWrappedInstance()local T=Y:FindFirstChild("\083\099\114\111\108\108\066\097\114")local X,R=Y:FindFirstChild("\066\117\116\116\111\110\049"),Y:FindFirstChild("\066\117\116\116\111\110\050")a:AssertEquals(X.AbsoluteSize,Vector2.new(20,20),"\066\117\116\116\111\110 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(X.AbsolutePosition,Vector2.new(0,0),"\066\117\116\116\111\110 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(R.AbsoluteSize,Vector2.new(20,20),"\066\117\116\116\111\110 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(R.AbsolutePosition,Vector2.new(380,0),"\066\117\116\116\111\110 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Size,UDim2.new(0,179,1,0),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,21,0,0),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")L.BorderSizePixel=5 a:AssertEquals(T.Size,UDim2.new(0,175,1,0),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,25,0,0),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")L.BorderSizePixel=0 a:AssertEquals(T.Size,UDim2.new(0,180,1,0),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,20,0,0),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")L.RelativePosition=.33333333333333 a:AssertEquals(T.Size,UDim2.new(0,180,1,0),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,80,0,0),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")L.RelativeSize=.5 a:AssertEquals(T.Size,UDim2.new(0,360,1,0),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,20,0,0),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")L.RelativeSize=4 a:AssertEquals(T.Size,UDim2.new(0,90,1,0),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,110,0,0),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")L.Size=UDim2.new(0,30,0,20)L.AbsoluteSize=Vector2.new(30,20)a:AssertFalse(X.Visible,"\066\117\116\116\111\110 \105\115 \118\105\115\105\098\108\101")a:AssertFalse(R.Visible,"\066\117\116\116\111\110 \105\115 \118\105\115\105\098\108\101")a:AssertEquals(T.Size,UDim2.new(0,7,1,0),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,7,0,0),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")end)a:RegisterUnitTest("\081\116\053\089\065\120\105\115",function(a)local L=b.new("\081\116\053",Enum.Axis.Y)L:__SetChangedOverride("\065\098\115\111\108\117\116\101\083\105\122\101",function() end)L.Size=UDim2.new(0,20,0,400)L.AbsoluteSize=Vector2.new(20,400)local Y=L:GetWrappedInstance()local T=Y:FindFirstChild("\083\099\114\111\108\108\066\097\114")local X,R=Y:FindFirstChild("\066\117\116\116\111\110\049"),Y:FindFirstChild("\066\117\116\116\111\110\050")a:AssertEquals(X.AbsoluteSize,Vector2.new(20,20),"\066\117\116\116\111\110 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(X.AbsolutePosition,Vector2.new(0,0),"\066\117\116\116\111\110 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(R.AbsoluteSize,Vector2.new(20,20),"\066\117\116\116\111\110 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(R.AbsolutePosition,Vector2.new(0,380),"\066\117\116\116\111\110 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Size,UDim2.new(1,0,0,179),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,0,0,21),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")L.BorderSizePixel=5 a:AssertEquals(T.Size,UDim2.new(1,0,0,175),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,0,0,25),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")L.BorderSizePixel=0 a:AssertEquals(T.Size,UDim2.new(1,0,0,180),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,0,0,20),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")L.RelativePosition=.33333333333333 a:AssertEquals(T.Size,UDim2.new(1,0,0,180),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,0,0,80),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")L.RelativeSize=.5 a:AssertEquals(T.Size,UDim2.new(1,0,0,360),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,0,0,20),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")L.RelativeSize=4 a:AssertEquals(T.Size,UDim2.new(1,0,0,90),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,0,0,110),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")L.Size=UDim2.new(0,20,0,30)L.AbsoluteSize=Vector2.new(20,30)a:AssertFalse(X.Visible,"\066\117\116\116\111\110 \105\115 \118\105\115\105\098\108\101")a:AssertFalse(R.Visible,"\066\117\116\116\111\110 \105\115 \118\105\115\105\098\108\101")a:AssertEquals(T.Size,UDim2.new(1,0,0,7),"\083\099\114\111\108\108 \098\097\114 \115\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(T.Position,UDim2.new(0,0,0,7),"\083\099\114\111\108\108 \098\097\114 \112\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")end)return true
--[[
TheNexusAvenger

Tests the NexusScrollBar class.
--]]

local NexusUnitTesting = require("NexusUnitTesting")

local NexusPluginFramework = require(game:GetService("ReplicatedStorage"):WaitForChild("NexusPluginFramework"))
local NexusScrollBar = NexusPluginFramework:GetResource("UI.Scroll.NexusScrollBar")



--[[
Test that the constructor works without failing.
--]]
NexusUnitTesting:RegisterUnitTest("Constructor",function(UnitTest)
	local CuT = NexusScrollBar.new("Qt5",Enum.Axis.X)
	UnitTest:AssertEquals(CuT.ClassName,"NexusScrollBar","Class name is incorrect.")
	UnitTest:AssertEquals(CuT.Name,"NexusScrollBar","Name is incorrect.")
	UnitTest:AssertEquals(tostring(CuT),"NexusScrollBar","Name is incorrect.")
	UnitTest:AssertEquals(#CuT:GetChildren(),0,"Children aren't hidden.")
end)

--[[
Test that the structure is valid for a Qt5 X-axis scroll bar.
--]]
NexusUnitTesting:RegisterUnitTest("Qt5XAxis",function(UnitTest)
	--Create the component under testing.
	local CuT = NexusScrollBar.new("Qt5",Enum.Axis.X)
	CuT:__SetChangedOverride("AbsoluteSize",function() end)
	CuT.Size = UDim2.new(0,400,0,20)
	CuT.AbsoluteSize = Vector2.new(400,20)
	
	local WrappedFrame = CuT:GetWrappedInstance()
	local ScrollFrame = WrappedFrame:FindFirstChild("ScrollBar")
	local LeftButton,RightButton = WrappedFrame:FindFirstChild("Button1"),WrappedFrame:FindFirstChild("Button2")
	
	--Assert the buttons are correct.
	UnitTest:AssertEquals(LeftButton.AbsoluteSize,Vector2.new(20,20),"Button size is incorrect.")
	UnitTest:AssertEquals(LeftButton.AbsolutePosition,Vector2.new(0,0),"Button position is incorrect.")
	UnitTest:AssertEquals(RightButton.AbsoluteSize,Vector2.new(20,20),"Button size is incorrect.")
	UnitTest:AssertEquals(RightButton.AbsolutePosition,Vector2.new(380,0),"Button position is incorrect.")
	
	--Assert the scroll bar is correct.
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(0,179,1,0),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,21,0,0),"Scroll bar position is incorrect.")
	
	--Set the border size pixel and assert the scroll bar is correct.
	CuT.BorderSizePixel = 5
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(0,175,1,0),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,25,0,0),"Scroll bar position is incorrect.")
	CuT.BorderSizePixel = 0
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(0,180,1,0),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,20,0,0),"Scroll bar position is incorrect.")
	
	--Set the relative position and assert the scroll bar is correct.
	CuT.RelativePosition = 1/3
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(0,180,1,0),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,80,0,0),"Scroll bar position is incorrect.")
	
	--Set the relative size and assert the scroll bar is correct.
	CuT.RelativeSize = 0.5
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(0,360,1,0),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,20,0,0),"Scroll bar position is incorrect.")
	CuT.RelativeSize = 4
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(0,90,1,0),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,110,0,0),"Scroll bar position is incorrect.")
	
	--Set the size to be too small.
	CuT.Size = UDim2.new(0,30,0,20)
	CuT.AbsoluteSize = Vector2.new(30,20)
	UnitTest:AssertFalse(LeftButton.Visible,"Button is visible")
	UnitTest:AssertFalse(RightButton.Visible,"Button is visible")
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(0,7,1,0),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,7,0,0),"Scroll bar position is incorrect.")
end)

--[[
Test that the structure is valid for a Qt5 Y-axis scroll bar.
--]]
NexusUnitTesting:RegisterUnitTest("Qt5YAxis",function(UnitTest)
	--Create the component under testing.
	local CuT = NexusScrollBar.new("Qt5",Enum.Axis.Y)
	CuT:__SetChangedOverride("AbsoluteSize",function() end)
	CuT.Size = UDim2.new(0,20,0,400)
	CuT.AbsoluteSize = Vector2.new(20,400)
	
	local WrappedFrame = CuT:GetWrappedInstance()
	local ScrollFrame = WrappedFrame:FindFirstChild("ScrollBar")
	local LeftButton,RightButton = WrappedFrame:FindFirstChild("Button1"),WrappedFrame:FindFirstChild("Button2")
	
	--Assert the buttons are correct.
	UnitTest:AssertEquals(LeftButton.AbsoluteSize,Vector2.new(20,20),"Button size is incorrect.")
	UnitTest:AssertEquals(LeftButton.AbsolutePosition,Vector2.new(0,0),"Button position is incorrect.")
	UnitTest:AssertEquals(RightButton.AbsoluteSize,Vector2.new(20,20),"Button size is incorrect.")
	UnitTest:AssertEquals(RightButton.AbsolutePosition,Vector2.new(0,380),"Button position is incorrect.")
	
	--Assert the scroll bar is correct.
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(1,0,0,179),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,0,0,21),"Scroll bar position is incorrect.")
	
	--Set the border size pixel and assert the scroll bar is correct.
	CuT.BorderSizePixel = 5
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(1,0,0,175),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,0,0,25),"Scroll bar position is incorrect.")
	CuT.BorderSizePixel = 0
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(1,0,0,180),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,0,0,20),"Scroll bar position is incorrect.")
	
	--Set the relative position and assert the scroll bar is correct.
	CuT.RelativePosition = 1/3
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(1,0,0,180),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,0,0,80),"Scroll bar position is incorrect.")
	
	--Set the relative size and assert the scroll bar is correct.
	CuT.RelativeSize = 0.5
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(1,0,0,360),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,0,0,20),"Scroll bar position is incorrect.")
	CuT.RelativeSize = 4
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(1,0,0,90),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,0,0,110),"Scroll bar position is incorrect.")
	
	--Set the size to be too small.
	CuT.Size = UDim2.new(0,20,0,30)
	CuT.AbsoluteSize = Vector2.new(20,30)
	UnitTest:AssertFalse(LeftButton.Visible,"Button is visible")
	UnitTest:AssertFalse(RightButton.Visible,"Button is visible")
	UnitTest:AssertEquals(ScrollFrame.Size,UDim2.new(1,0,0,7),"Scroll bar size is incorrect.")
	UnitTest:AssertEquals(ScrollFrame.Position,UDim2.new(0,0,0,7),"Scroll bar position is incorrect.")
end)

--[[
Creates 2 scroll bars in StarterGui.
Disabled unless needed.
--]]
--[[
NexusUnitTesting:RegisterUnitTest("ManualTesting",function(UnitTest)
	--Create the screen gui.
	local ScreenGui = Instance.new("ScreenGui")
	ScreenGui.Parent = game:GetService("StarterGui")
	
	--Create the frame.
	local Frame = NexusPluginFramework.new("Frame")
	Frame.Size = UDim2.new(0,420,0,420)
	Frame.Parent = ScreenGui
	
	--Create the scroll bars.
	local CuT1 = NexusScrollBar.new("Qt5",Enum.Axis.X)
	CuT1.Size = UDim2.new(0,400,0,20)
	CuT1.Position = UDim2.new(0,0,0,400)
	CuT1.Parent = Frame
	
	local CuT2 = NexusScrollBar.new("Qt5",Enum.Axis.Y)
	CuT2.Size = UDim2.new(0,20,0,400)
	CuT2.Position = UDim2.new(0,400,0,0)
	CuT2.Parent = Frame
	
	--Print the events.
	CuT1.Button1Pressed:Connect(function() print("Left invoked.") end)
	CuT1.Button2Pressed:Connect(function() print("Right invoked.") end)
	CuT2.Button1Pressed:Connect(function() print("Up invoked.") end)
	CuT2.Button2Pressed:Connect(function() print("Down invoked.") end)
	
	--Wait for the screen gui to be deleted.
	while ScreenGui.Parent do wait() end
end)
--]]


return true