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\105\110\103\070\114\097\109\101")a:RegisterUnitTest("\067\111\110\115\116\114\117\099\116\111\114",function(a)local L=b.new("\078\097\116\105\118\101")a:AssertEquals(L.ClassName,"\078\101\120\117\115\083\099\114\111\108\108\105\110\103\070\114\097\109\101","\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\105\110\103\070\114\097\109\101","\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\105\110\103\070\114\097\109\101","\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\084\104\101\109\101\083\101\116\117\112",function(a)local Y=Instance.new("\070\114\097\109\101")local T=L.new(Y)local X=b.new("\081\116\053")X.Size=UDim2.new(0,200,0,200)X.Parent=T a:AssertEquals(#Y:GetChildren(),2,"\083\099\114\111\108\108 \098\097\114 \097\100\111\114\110 \100\111\101\115\110\'\116 \101\120\105\115\116\046")a:AssertEquals(#T:GetChildren(),1,"\083\099\114\111\108\108 \098\097\114 \097\100\111\114\110 \105\115\110\'\116 \104\105\100\100\101\110\046")local R=Y:FindFirstChild("\083\099\114\111\108\108\066\097\114\065\100\111\114\110")local A=R:FindFirstChild("\072\111\114\105\122\111\110\116\097\108\083\099\114\111\108\108\066\097\114")local N=R:FindFirstChild("\086\101\114\116\105\099\097\108\083\099\114\111\108\108\066\097\114")X.CanvasSize=UDim2.new(0,150,0,150)a:AssertFalse(A.Visible,"\083\099\114\111\108\108 \098\097\114 \105\115 \118\105\115\105\098\108\101\046")a:AssertFalse(N.Visible,"\083\099\114\111\108\108 \098\097\114 \105\115 \118\105\115\105\098\108\101\046")X.CanvasSize=UDim2.new(0,300,0,150)a:AssertTrue(A.Visible,"\083\099\114\111\108\108 \098\097\114 \105\115\110\'\116 \118\105\115\105\098\108\101\046")a:AssertFalse(N.Visible,"\083\099\114\111\108\108 \098\097\114 \105\115 \118\105\115\105\098\108\101\046")a:AssertEquals(A.AbsoluteSize,Vector2.new(198,16),"\083\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(A.AbsolutePosition,Vector2.new(1,184),"\080\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")X.CanvasSize=UDim2.new(0,150,0,300)X.VerticalScrollBarPosition=Enum.VerticalScrollBarPosition.Right a:AssertFalse(A.Visible,"\083\099\114\111\108\108 \098\097\114 \105\115 \118\105\115\105\098\108\101\046")a:AssertTrue(N.Visible,"\083\099\114\111\108\108 \098\097\114 \105\115\110\'\116 \118\105\115\105\098\108\101\046")a:AssertEquals(N.AbsoluteSize,Vector2.new(16,198),"\083\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(N.AbsolutePosition,Vector2.new(184,1),"\080\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")X.CanvasSize=UDim2.new(0,150,0,300)X.VerticalScrollBarPosition=Enum.VerticalScrollBarPosition.Left a:AssertFalse(A.Visible,"\083\099\114\111\108\108 \098\097\114 \105\115 \118\105\115\105\098\108\101\046")a:AssertTrue(N.Visible,"\083\099\114\111\108\108 \098\097\114 \105\115\110\'\116 \118\105\115\105\098\108\101\046")a:AssertEquals(N.AbsoluteSize,Vector2.new(16,198),"\083\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(N.AbsolutePosition,Vector2.new(0,1),"\080\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")X.CanvasSize=UDim2.new(0,300,0,300)X.VerticalScrollBarPosition=Enum.VerticalScrollBarPosition.Right a:AssertTrue(A.Visible,"\083\099\114\111\108\108 \098\097\114 \105\115\110\'\116 \118\105\115\105\098\108\101\046")a:AssertTrue(N.Visible,"\083\099\114\111\108\108 \098\097\114 \105\115\110\'\116 \118\105\115\105\098\108\101\046")a:AssertEquals(A.AbsoluteSize,Vector2.new(182,16),"\083\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(A.AbsolutePosition,Vector2.new(1,184),"\080\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(N.AbsoluteSize,Vector2.new(16,182),"\083\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(N.AbsolutePosition,Vector2.new(184,1),"\080\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")X.CanvasSize=UDim2.new(0,300,0,300)X.VerticalScrollBarPosition=Enum.VerticalScrollBarPosition.Left a:AssertTrue(A.Visible,"\083\099\114\111\108\108 \098\097\114 \105\115\110\'\116 \118\105\115\105\098\108\101\046")a:AssertTrue(N.Visible,"\083\099\114\111\108\108 \098\097\114 \105\115\110\'\116 \118\105\115\105\098\108\101\046")a:AssertEquals(A.AbsoluteSize,Vector2.new(182,16),"\083\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(A.AbsolutePosition,Vector2.new(17,184),"\080\111\115\105\116\105\111\110 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(N.AbsoluteSize,Vector2.new(16,182),"\083\105\122\101 \105\115 \105\110\099\111\114\114\101\099\116\046")a:AssertEquals(N.AbsolutePosition,Vector2.new(0,1),"\080\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 NexusScrollingFrame = NexusPluginFramework:GetResource("UI.Scroll.NexusScrollingFrame")



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

--[[
Tests that the scrollbars are set up correctly for the Qt5 theme.
--]]
NexusUnitTesting:RegisterUnitTest("Qt5ThemeSetup",function(UnitTest)
	--Create a container frame and the component under testing.
	local Frame = Instance.new("Frame")
	local WrappedFrame = NexusPluginFramework.new(Frame)
	local CuT = NexusScrollingFrame.new("Qt5")
	CuT.Size = UDim2.new(0,200,0,200)
	CuT.Parent = WrappedFrame
	
	--Assert the scroll bar adorn is hidden.
	UnitTest:AssertEquals(#Frame:GetChildren(),2,"Scroll bar adorn doesn't exist.")
	UnitTest:AssertEquals(#WrappedFrame:GetChildren(),1,"Scroll bar adorn isn't hidden.")
	
	--Get the scroll bars.
	local ScrollBarAdorn = Frame:FindFirstChild("ScrollBarAdorn")
	local HorizontalScrollBar = ScrollBarAdorn:FindFirstChild("HorizontalScrollBar")
	local VerticalScrollBar = ScrollBarAdorn:FindFirstChild("VerticalScrollBar")
	
	--Assert the scroll bars are not shown for a canvas size less than frame size.
	CuT.CanvasSize = UDim2.new(0,150,0,150)
	UnitTest:AssertFalse(HorizontalScrollBar.Visible,"Scroll bar is visible.")
	UnitTest:AssertFalse(VerticalScrollBar.Visible,"Scroll bar is visible.")
	
	--Assert the scroll bars are correct for only the horizontal scroll bar.
	CuT.CanvasSize = UDim2.new(0,300,0,150)
	UnitTest:AssertTrue(HorizontalScrollBar.Visible,"Scroll bar isn't visible.")
	UnitTest:AssertFalse(VerticalScrollBar.Visible,"Scroll bar is visible.")
	UnitTest:AssertEquals(HorizontalScrollBar.AbsoluteSize,Vector2.new(198,16),"Size is incorrect.")
	UnitTest:AssertEquals(HorizontalScrollBar.AbsolutePosition,Vector2.new(1,184),"Position is incorrect.")
	
	--Assert the scroll bars are correct for only the vertical scroll bar on the right.
	CuT.CanvasSize = UDim2.new(0,150,0,300)
	CuT.VerticalScrollBarPosition = Enum.VerticalScrollBarPosition.Right
	UnitTest:AssertFalse(HorizontalScrollBar.Visible,"Scroll bar is visible.")
	UnitTest:AssertTrue(VerticalScrollBar.Visible,"Scroll bar isn't visible.")
	UnitTest:AssertEquals(VerticalScrollBar.AbsoluteSize,Vector2.new(16,198),"Size is incorrect.")
	UnitTest:AssertEquals(VerticalScrollBar.AbsolutePosition,Vector2.new(184,1),"Position is incorrect.")
	
	--Assert the scroll bars are correct for only the vertical scroll bar on the left.
	CuT.CanvasSize = UDim2.new(0,150,0,300)
	CuT.VerticalScrollBarPosition = Enum.VerticalScrollBarPosition.Left
	UnitTest:AssertFalse(HorizontalScrollBar.Visible,"Scroll bar is visible.")
	UnitTest:AssertTrue(VerticalScrollBar.Visible,"Scroll bar isn't visible.")
	UnitTest:AssertEquals(VerticalScrollBar.AbsoluteSize,Vector2.new(16,198),"Size is incorrect.")
	UnitTest:AssertEquals(VerticalScrollBar.AbsolutePosition,Vector2.new(0,1),"Position is incorrect.")
	
	--Assert that both scroll bars are correct for both with vertical on the right.
	CuT.CanvasSize = UDim2.new(0,300,0,300)
	CuT.VerticalScrollBarPosition = Enum.VerticalScrollBarPosition.Right
	UnitTest:AssertTrue(HorizontalScrollBar.Visible,"Scroll bar isn't visible.")
	UnitTest:AssertTrue(VerticalScrollBar.Visible,"Scroll bar isn't visible.")
	UnitTest:AssertEquals(HorizontalScrollBar.AbsoluteSize,Vector2.new(182,16),"Size is incorrect.")
	UnitTest:AssertEquals(HorizontalScrollBar.AbsolutePosition,Vector2.new(1,184),"Position is incorrect.")
	UnitTest:AssertEquals(VerticalScrollBar.AbsoluteSize,Vector2.new(16,182),"Size is incorrect.")
	UnitTest:AssertEquals(VerticalScrollBar.AbsolutePosition,Vector2.new(184,1),"Position is incorrect.")
	
	--Assert that both scroll bars are correct for both with vertical on the left.
	CuT.CanvasSize = UDim2.new(0,300,0,300)
	CuT.VerticalScrollBarPosition = Enum.VerticalScrollBarPosition.Left
	UnitTest:AssertTrue(HorizontalScrollBar.Visible,"Scroll bar isn't visible.")
	UnitTest:AssertTrue(VerticalScrollBar.Visible,"Scroll bar isn't visible.")
	UnitTest:AssertEquals(HorizontalScrollBar.AbsoluteSize,Vector2.new(182,16),"Size is incorrect.")
	UnitTest:AssertEquals(HorizontalScrollBar.AbsolutePosition,Vector2.new(17,184),"Position is incorrect.")
	UnitTest:AssertEquals(VerticalScrollBar.AbsoluteSize,Vector2.new(16,182),"Size is incorrect.")
	UnitTest:AssertEquals(VerticalScrollBar.AbsolutePosition,Vector2.new(0,1),"Position is incorrect.")
end)

--[[
Creates a scrolling frame 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 ScrollingFrame = NexusScrollingFrame.new("Qt5")
	ScrollingFrame.CanvasSize = UDim2.new(0,800,0,800)
	ScrollingFrame.Size = UDim2.new(0,420,0,420)
	ScrollingFrame.Parent = ScreenGui
	
	--Create a grid.
	for i = 0,7 do
		for j = 0,7 do
			local Frame = NexusPluginFramework.new("Frame")
			Frame.BackgroundColor3 = Color3.new(math.random(),math.random(),math.random())
			Frame.Size = UDim2.new(0,80,0,80)
			Frame.Position = UDim2.new(0,(i * 100) + 10,0,(j * 100) + 10)
			Frame.Parent = ScrollingFrame
		end
	end
	
	--Wait for the screen gui to be deleted.
	while ScreenGui.Parent do wait() end
end)
--]]



return true