diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7b0801aab..5229bdaf8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,7 @@ on: [push, pull_request] jobs: linux-os: runs-on: ubuntu-20.04 + timeout-minutes: 60 steps: - name: Update APT run: sudo apt-get update @@ -50,9 +51,12 @@ jobs: name: love-x86_64-AppImage-debug path: love-${{ github.sha }}.AppImage-debug.tar.gz - name: Make Runnable - run: chmod a+x love-${{ github.sha }}.AppImage + run: | + chmod a+x love-${{ github.sha }}.AppImage + echo "ready to run" + ls - name: Run All Tests - run: xvfb-run ./love-${{ github.sha }}.AppImage testing + run: xvfb-run ./love-${{ github.sha }}.AppImage ./testing/main.lua - name: Love Test Report uses: ellraiser/love-test-report@main with: @@ -61,6 +65,7 @@ jobs: path: testing/output/lovetest_runAllTests.md windows-os: runs-on: windows-latest + timeout-minutes: 60 strategy: matrix: platform: [Win32, x64, ARM64] @@ -214,9 +219,21 @@ jobs: uses: actions/upload-artifact@v3 with: name: love-windows-${{ steps.vars.outputs.arch }}${{ steps.vars.outputs.compatname }}-dbg - path: pdb/Release/*.pdb + path: pdb/Release/*.pdb + - name: Install Scream + shell: powershell + run: | + Start-Service audio* + Invoke-WebRequest https://github.com/duncanthrax/scream/releases/download/3.6/Scream3.6.zip -OutFile C:\Scream3.6.zip + Extract-7Zip -Path C:\Scream3.6.zip -DestinationPath C:\Scream + $cert = (Get-AuthenticodeSignature C:\Scream\Install\driver\Scream.sys).SignerCertificate + $store = [System.Security.Cryptography.X509Certificates.X509Store]::new("TrustedPublisher", "LocalMachine") + $store.Open("ReadWrite") + $store.Add($cert) + $store.Close() + cd C:\Scream\Install\driver + C:\Scream\Install\helpers\devcon install Scream.inf *Scream - name: Install Mesa - if: steps.vars.outputs.arch != 'ARM64' run: | curl -L --output mesa.7z --url https://github.com/pal1000/mesa-dist-win/releases/download/23.2.1/mesa3d-23.2.1-release-msvc.7z 7z x mesa.7z -o* @@ -226,7 +243,9 @@ jobs: run: cmake --build build --config Release --target install - name: Run All Tests if: steps.vars.outputs.arch != 'ARM64' - run: powershell.exe install/lovec.exe testing + run: | + dir + powershell.exe ./install/lovec.exe ./testing/main.lua - name: Love Test Report if: steps.vars.outputs.arch != 'ARM64' uses: ellraiser/love-test-report@main @@ -236,6 +255,7 @@ jobs: path: testing/output/lovetest_runAllTests.md macOS: runs-on: macos-latest + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v3 @@ -263,7 +283,7 @@ jobs: name: love-macos path: love-macos.zip - name: Run All Tests - run: love-macos/love.app/Contents/MacOS/love testing + run: love-macos/love.app/Contents/MacOS/love testing/main.lua - name: Love Test Report uses: ellraiser/love-test-report@main with: @@ -272,6 +292,7 @@ jobs: path: testing/output/lovetest_runAllTests.md iOS-Simulator: runs-on: macos-latest + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index f84038cd7..3f5288d45 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,4 @@ stamp-h1 /testing/output/*.xml /testing/output/*.html /testing/output/*.md +/testing/output/actual/*.png diff --git a/testing/classes/TestMethod.lua b/testing/classes/TestMethod.lua index 9b355a6bb..ad3a742e6 100644 --- a/testing/classes/TestMethod.lua +++ b/testing/classes/TestMethod.lua @@ -33,9 +33,13 @@ TestMethod = { blue = {0, 0, 1, 1}, bluefade = {0, 0, 1, 0.5}, yellow = {1, 1, 0, 1}, + pink = {1, 0, 1, 1}, black = {0, 0, 0, 1}, - white = {1, 1, 1, 1} + white = {1, 1, 1, 1}, + lovepink = {214/255, 86/255, 151/255, 1}, + loveblue = {83/255, 168/255, 220/255, 1} }, + imgs = 1, delay = 0, delayed = false } @@ -82,6 +86,10 @@ TestMethod = { tg = math.floor((tg*10)+0.5)/10 tb = math.floor((tb*10)+0.5)/10 ta = math.floor((ta*10)+0.5)/10 + col[1] = math.floor((col[1]*10)+0.5)/10 + col[2] = math.floor((col[2]*10)+0.5)/10 + col[3] = math.floor((col[3]*10)+0.5)/10 + col[4] = math.floor((col[4]*10)+0.5)/10 -- @TODO add some sort pixel tolerance to the coords self:assertEquals(col[1], tr, 'check pixel r for ' .. i .. ' at ' .. compare_id .. '(' .. label .. ')') self:assertEquals(col[2], tg, 'check pixel g for ' .. i .. ' at ' .. compare_id .. '(' .. label .. ')') @@ -227,6 +235,14 @@ TestMethod = { end, + exportImg = function(self, imgdata) + local path = 'tempoutput/actual/love.test.graphics.' .. + self.method .. '-' .. tostring(self.imgs) .. '.png' + imgdata:encode('png', path) + self.imgs = self.imgs + 1 + end, + + -- @method - TestMethod:skipTest() -- @desc - used to mark this test as skipped for a specific reason -- @param {string} reason - reason why method is being skipped @@ -356,11 +372,21 @@ TestMethod = { -- unused currently, adds a preview image for certain graphics methods to the output local preview = '' - -- if self.testmodule.module == 'graphics' then - -- local filename = 'love_test_graphics_rectangle' - -- preview = '
' .. '

Expected

' .. - -- '

Actual

' - -- end + if self.testmodule.module == 'graphics' then + local filename = 'love.test.graphics.' .. self.method + if love.filesystem.openFile('tempoutput/actual/' .. filename .. '-1.png', 'r') then + preview = '
' .. '

Expected

' .. + '
' .. '

Actual

' + end + if love.filesystem.openFile('tempoutput/actual/' .. filename .. '-2.png', 'r') then + preview = preview .. '
' .. '

Expected

' .. + '
' .. '

Actual

' + end + if love.filesystem.openFile('tempoutput/actual/' .. filename .. '-3.png', 'r') then + preview = preview .. '
' .. '

Expected

' .. + '
' .. '

Actual

' + end + end -- append HTML for the test class result local status = '🔴' diff --git a/testing/classes/TestModule.lua b/testing/classes/TestModule.lua index 89fd1f7fa..dae7d82ed 100644 --- a/testing/classes/TestModule.lua +++ b/testing/classes/TestModule.lua @@ -88,7 +88,7 @@ TestModule = { if self.failed == 0 then status = '🟢' end -- add md row to main output love.test.mdrows = love.test.mdrows .. '| ' .. status .. - ' love.' .. self.module .. + ' ' .. self.module .. ' | ' .. tostring(self.passed) .. ' | ' .. tostring(self.failed) .. ' | ' .. tostring(self.skipped) .. diff --git a/testing/classes/TestSuite.lua b/testing/classes/TestSuite.lua index 8d9ce368c..cbe171c31 100644 --- a/testing/classes/TestSuite.lua +++ b/testing/classes/TestSuite.lua @@ -187,8 +187,6 @@ TestSuite = { '
  • 🟡 ' .. tostring(self.totals[3]) .. ' Skipped
  • ' .. '
  • ' .. finaltime .. 's


  • ' - -- @TODO use mountFullPath to write output to src? - love.filesystem.mountFullPath(love.filesystem.getSource() .. "/output", "tempoutput", "readwrite") love.filesystem.write('tempoutput/' .. self.output .. '.xml', xml .. self.xml .. '') love.filesystem.write('tempoutput/' .. self.output .. '.html', html .. self.html .. '') love.filesystem.write('tempoutput/' .. self.output .. '.md', md) diff --git a/testing/main.lua b/testing/main.lua index 292ad82c6..523d536d6 100644 --- a/testing/main.lua +++ b/testing/main.lua @@ -53,6 +53,9 @@ love.load = function(args) end end + -- mount for output later + love.filesystem.mountFullPath(love.filesystem.getSource() .. "/output", "tempoutput", "readwrite") + -- get all args with any comma lists split out as seperate local arglist = {} for a=1,#args do diff --git a/testing/output/actual/notes.txt b/testing/output/actual/notes.txt new file mode 100644 index 000000000..2716b1df8 --- /dev/null +++ b/testing/output/actual/notes.txt @@ -0,0 +1,2 @@ +# Actual Graphics Output +The images generated by the tests \ No newline at end of file diff --git a/testing/output/expected/love.test.graphics.applyTransform-1.png b/testing/output/expected/love.test.graphics.applyTransform-1.png new file mode 100644 index 000000000..f80ad8f85 Binary files /dev/null and b/testing/output/expected/love.test.graphics.applyTransform-1.png differ diff --git a/testing/output/expected/love.test.graphics.arc-1.png b/testing/output/expected/love.test.graphics.arc-1.png new file mode 100644 index 000000000..f95e65bb3 Binary files /dev/null and b/testing/output/expected/love.test.graphics.arc-1.png differ diff --git a/testing/output/expected/love.test.graphics.arc-2.png b/testing/output/expected/love.test.graphics.arc-2.png new file mode 100644 index 000000000..f0ae7e649 Binary files /dev/null and b/testing/output/expected/love.test.graphics.arc-2.png differ diff --git a/testing/output/expected/love.test.graphics.arc-3.png b/testing/output/expected/love.test.graphics.arc-3.png new file mode 100644 index 000000000..19354b37a Binary files /dev/null and b/testing/output/expected/love.test.graphics.arc-3.png differ diff --git a/testing/output/expected/love.test.graphics.circle-1.png b/testing/output/expected/love.test.graphics.circle-1.png new file mode 100644 index 000000000..dbc130407 Binary files /dev/null and b/testing/output/expected/love.test.graphics.circle-1.png differ diff --git a/testing/output/expected/love.test.graphics.clear-1.png b/testing/output/expected/love.test.graphics.clear-1.png new file mode 100644 index 000000000..315c7a936 Binary files /dev/null and b/testing/output/expected/love.test.graphics.clear-1.png differ diff --git a/testing/output/expected/love.test.graphics.draw-1.png b/testing/output/expected/love.test.graphics.draw-1.png new file mode 100644 index 000000000..6318b14a4 Binary files /dev/null and b/testing/output/expected/love.test.graphics.draw-1.png differ diff --git a/testing/output/expected/love.test.graphics.drawLayer-1.png b/testing/output/expected/love.test.graphics.drawLayer-1.png new file mode 100644 index 000000000..876bb6f77 Binary files /dev/null and b/testing/output/expected/love.test.graphics.drawLayer-1.png differ diff --git a/testing/output/expected/love.test.graphics.ellipse-1.png b/testing/output/expected/love.test.graphics.ellipse-1.png new file mode 100644 index 000000000..3fd46b709 Binary files /dev/null and b/testing/output/expected/love.test.graphics.ellipse-1.png differ diff --git a/testing/output/expected/love.test.graphics.intersectScissor-1.png b/testing/output/expected/love.test.graphics.intersectScissor-1.png new file mode 100644 index 000000000..7c40b8c9e Binary files /dev/null and b/testing/output/expected/love.test.graphics.intersectScissor-1.png differ diff --git a/testing/output/expected/love.test.graphics.line-1.png b/testing/output/expected/love.test.graphics.line-1.png new file mode 100644 index 000000000..6fa77e263 Binary files /dev/null and b/testing/output/expected/love.test.graphics.line-1.png differ diff --git a/testing/output/expected/love.test.graphics.origin-1.png b/testing/output/expected/love.test.graphics.origin-1.png new file mode 100644 index 000000000..e018bbfbc Binary files /dev/null and b/testing/output/expected/love.test.graphics.origin-1.png differ diff --git a/testing/output/expected/love.test.graphics.points-1.png b/testing/output/expected/love.test.graphics.points-1.png new file mode 100644 index 000000000..93cc0fa41 Binary files /dev/null and b/testing/output/expected/love.test.graphics.points-1.png differ diff --git a/testing/output/expected/love.test.graphics.polygon-1.png b/testing/output/expected/love.test.graphics.polygon-1.png new file mode 100644 index 000000000..8107330d3 Binary files /dev/null and b/testing/output/expected/love.test.graphics.polygon-1.png differ diff --git a/testing/output/expected/love.test.graphics.pop-1.png b/testing/output/expected/love.test.graphics.pop-1.png new file mode 100644 index 000000000..e018bbfbc Binary files /dev/null and b/testing/output/expected/love.test.graphics.pop-1.png differ diff --git a/testing/output/expected/love.test.graphics.print-1.png b/testing/output/expected/love.test.graphics.print-1.png new file mode 100644 index 000000000..93380064d Binary files /dev/null and b/testing/output/expected/love.test.graphics.print-1.png differ diff --git a/testing/output/expected/love.test.graphics.printf-1.png b/testing/output/expected/love.test.graphics.printf-1.png new file mode 100644 index 000000000..b37a1ac89 Binary files /dev/null and b/testing/output/expected/love.test.graphics.printf-1.png differ diff --git a/testing/output/expected/love.test.graphics.push-1.png b/testing/output/expected/love.test.graphics.push-1.png new file mode 100644 index 000000000..58ace03b3 Binary files /dev/null and b/testing/output/expected/love.test.graphics.push-1.png differ diff --git a/testing/output/expected/love.test.graphics.rectangle-1.png b/testing/output/expected/love.test.graphics.rectangle-1.png new file mode 100644 index 000000000..1f0e94a4e Binary files /dev/null and b/testing/output/expected/love.test.graphics.rectangle-1.png differ diff --git a/testing/output/expected/love.test.graphics.rectangle-2.png b/testing/output/expected/love.test.graphics.rectangle-2.png new file mode 100644 index 000000000..355c64e43 Binary files /dev/null and b/testing/output/expected/love.test.graphics.rectangle-2.png differ diff --git a/testing/output/expected/love.test.graphics.replaceTransform-1.png b/testing/output/expected/love.test.graphics.replaceTransform-1.png new file mode 100644 index 000000000..f80ad8f85 Binary files /dev/null and b/testing/output/expected/love.test.graphics.replaceTransform-1.png differ diff --git a/testing/output/expected/love.test.graphics.rotate-1.png b/testing/output/expected/love.test.graphics.rotate-1.png new file mode 100644 index 000000000..7c40b8c9e Binary files /dev/null and b/testing/output/expected/love.test.graphics.rotate-1.png differ diff --git a/testing/output/expected/love.test.graphics.setBlendMode-1.png b/testing/output/expected/love.test.graphics.setBlendMode-1.png new file mode 100644 index 000000000..71ad3bdd9 Binary files /dev/null and b/testing/output/expected/love.test.graphics.setBlendMode-1.png differ diff --git a/testing/output/expected/love.test.graphics.setCanvas-1.png b/testing/output/expected/love.test.graphics.setCanvas-1.png new file mode 100644 index 000000000..a97348e50 Binary files /dev/null and b/testing/output/expected/love.test.graphics.setCanvas-1.png differ diff --git a/testing/output/expected/love.test.graphics.setColor-1.png b/testing/output/expected/love.test.graphics.setColor-1.png new file mode 100644 index 000000000..4b1036b29 Binary files /dev/null and b/testing/output/expected/love.test.graphics.setColor-1.png differ diff --git a/testing/output/expected/love.test.graphics.setColorMask-1.png b/testing/output/expected/love.test.graphics.setColorMask-1.png new file mode 100644 index 000000000..254f834f8 Binary files /dev/null and b/testing/output/expected/love.test.graphics.setColorMask-1.png differ diff --git a/testing/output/expected/love.test.graphics.setFont-1.png b/testing/output/expected/love.test.graphics.setFont-1.png new file mode 100644 index 000000000..31773fcf9 Binary files /dev/null and b/testing/output/expected/love.test.graphics.setFont-1.png differ diff --git a/testing/output/expected/love.test.graphics.setLineJoin-1.png b/testing/output/expected/love.test.graphics.setLineJoin-1.png new file mode 100644 index 000000000..76397bdbe Binary files /dev/null and b/testing/output/expected/love.test.graphics.setLineJoin-1.png differ diff --git a/testing/output/expected/love.test.graphics.setLineStyle-1.png b/testing/output/expected/love.test.graphics.setLineStyle-1.png new file mode 100644 index 000000000..9df1b3817 Binary files /dev/null and b/testing/output/expected/love.test.graphics.setLineStyle-1.png differ diff --git a/testing/output/expected/love.test.graphics.setLineWidth-1.png b/testing/output/expected/love.test.graphics.setLineWidth-1.png new file mode 100644 index 000000000..ce30d2cfe Binary files /dev/null and b/testing/output/expected/love.test.graphics.setLineWidth-1.png differ diff --git a/testing/output/expected/love.test.graphics.setScissor-1.png b/testing/output/expected/love.test.graphics.setScissor-1.png new file mode 100644 index 000000000..202f26d04 Binary files /dev/null and b/testing/output/expected/love.test.graphics.setScissor-1.png differ diff --git a/testing/output/expected/love.test.graphics.setShader-1.png b/testing/output/expected/love.test.graphics.setShader-1.png new file mode 100644 index 000000000..315c7a936 Binary files /dev/null and b/testing/output/expected/love.test.graphics.setShader-1.png differ diff --git a/testing/output/expected/love.test.graphics.setStencilTest-1.png b/testing/output/expected/love.test.graphics.setStencilTest-1.png new file mode 100644 index 000000000..773650483 Binary files /dev/null and b/testing/output/expected/love.test.graphics.setStencilTest-1.png differ diff --git a/testing/output/expected/love.test.graphics.setWireframe-1.png b/testing/output/expected/love.test.graphics.setWireframe-1.png new file mode 100644 index 000000000..ceea66531 Binary files /dev/null and b/testing/output/expected/love.test.graphics.setWireframe-1.png differ diff --git a/testing/output/expected/love.test.graphics.shear-1.png b/testing/output/expected/love.test.graphics.shear-1.png new file mode 100644 index 000000000..36a779c57 Binary files /dev/null and b/testing/output/expected/love.test.graphics.shear-1.png differ diff --git a/testing/output/expected/love.test.graphics.shear-2.png b/testing/output/expected/love.test.graphics.shear-2.png new file mode 100644 index 000000000..3d1873ea5 Binary files /dev/null and b/testing/output/expected/love.test.graphics.shear-2.png differ diff --git a/testing/output/expected/love.test.graphics.translate-1.png b/testing/output/expected/love.test.graphics.translate-1.png new file mode 100644 index 000000000..bcb6eb159 Binary files /dev/null and b/testing/output/expected/love.test.graphics.translate-1.png differ diff --git a/testing/output/expected/notes.txt b/testing/output/expected/notes.txt new file mode 100644 index 000000000..25b54bba5 --- /dev/null +++ b/testing/output/expected/notes.txt @@ -0,0 +1,2 @@ +# Expected Graphics Output +The images expected by the tests \ No newline at end of file diff --git a/testing/output/readme.md b/testing/output/notes.txt similarity index 100% rename from testing/output/readme.md rename to testing/output/notes.txt diff --git a/testing/resources/loveinv.png b/testing/resources/loveinv.png new file mode 100644 index 000000000..7be943a20 Binary files /dev/null and b/testing/resources/loveinv.png differ diff --git a/testing/tests/graphics.lua b/testing/tests/graphics.lua index 8ace6eaea..203c22aa0 100644 --- a/testing/tests/graphics.lua +++ b/testing/tests/graphics.lua @@ -10,31 +10,159 @@ -- love.graphics.arc love.test.graphics.arc = function(test) - test:skipTest('test class needs writing') + -- draw some arcs using pi format + local canvas = love.graphics.newCanvas(32, 32) + love.graphics.setCanvas(canvas) + love.graphics.clear(0, 0, 0, 1) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.arc('line', "pie", 16, 16, 16, 0 * (math.pi/180), 360 * (math.pi/180), 10) + love.graphics.arc('fill', "pie", 16, 16, 16, 270 * (math.pi/180), 45 * (math.pi/180), 10) + love.graphics.setColor(1, 0, 0, 1) + love.graphics.arc('line', "pie", 16, 16, 16, 0 * (math.pi/180), 90 * (math.pi/180), 10) + love.graphics.setColor(1, 1, 0, 1) + love.graphics.arc('line', "pie", 16, 16, 16, 180 * (math.pi/180), 135 * (math.pi/180), 10) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.setCanvas() + local imgdata1 = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata1, { + white = {{11,0},{20,0},{0,13},{0,14},{31,13},{31,14},{15,14}}, + black = {{16,14},{16,16},{30,14},{30,16}}, + yellow = {{15,15},{15,16},{16,15},{0,15},{4,27},{5,26},{14,17}}, + red = {{15,17},{15,31},{17,15},{31,15},{28,26},{27,27}} + }, 'arc pi') + -- draw some arcs with open format + love.graphics.setCanvas(canvas) + love.graphics.clear(0, 0, 0, 1) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.arc('line', "open", 16, 16, 16, 0 * (math.pi/180), 315 * (math.pi/180), 10) + love.graphics.setColor(1, 0, 0, 1) + love.graphics.arc('fill', "open", 16, 16, 16, 0 * (math.pi/180), 180 * (math.pi/180), 10) + love.graphics.setColor(1, 1, 0, 1) + love.graphics.arc('fill', "open", 16, 16, 16, 180 * (math.pi/180), 90 * (math.pi/180), 10) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.setCanvas() + local imgdata2 = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata2, { + white = {{11,0},{20,0},{26,4},{5,4},{0,15},{19,31},{31,19}}, + black = {{27,5},{27,4},{26,5},{1,15},{31,15}}, + yellow = {{0,17},{0,19},{12,31},{14,31},{6,23},{7,24}}, + red = {{0,16},{31,16},{31,18},{30,21},{18,31},{15,16},{16,16}} + }, 'arc open') + -- draw some arcs with closed format + love.graphics.setCanvas(canvas) + love.graphics.clear(0, 0, 0, 1) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.arc('line', "closed", 16, 16, 16, 0 * (math.pi/180), 315 * (math.pi/180), 10) + love.graphics.setColor(1, 0, 0, 1) + love.graphics.arc('fill', "closed", 16, 16, 16, 0 * (math.pi/180), 180 * (math.pi/180), 10) + love.graphics.setColor(1, 1, 0, 1) + love.graphics.arc('line', "closed", 16, 16, 16, 180 * (math.pi/180), 90 * (math.pi/180), 10) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.setCanvas() + local imgdata3 = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata3, { + white = {{11,0},{20,0},{26,4},{5,4},{0,15},{19,31},{31,19}}, + yellow = {{0,17},{0,19},{12,31},{14,31}}, + red = {{31,16},{31,18},{30,21},{18,31},{15,16},{16,16}} + }, 'arc open') + test:exportImg(imgdata1) + test:exportImg(imgdata2) + test:exportImg(imgdata3) end -- love.graphics.circle love.test.graphics.circle = function(test) - test:skipTest('test class needs writing') + -- draw some circles + local canvas = love.graphics.newCanvas(32, 32) + love.graphics.setCanvas(canvas) + love.graphics.clear(0, 0, 0, 1) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.circle('fill', 16, 16, 16) + love.graphics.setColor(1, 0, 0, 1) + love.graphics.circle('line', 16, 16, 16) + love.graphics.setColor(1, 1, 0, 1) + love.graphics.circle('fill', 16, 16, 8) + love.graphics.setColor(0, 1, 0, 1) + love.graphics.circle('fill', 16, 16, 4) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.setCanvas() + local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata, { + white = {{13,8},{18,8},{23,13},{23,18}}, + green = { + {15,12},{16,12},{13,13},{18,13},{12,15},{12,16},{13,18},{18,18}, + {15,19},{16,19},{19,15},{19,16} + }, + black = {{10,0},{21,0},{0,10},{0,21},{31,10},{31,21},{10,31},{21,31}}, + yellow = { + {11,10},{10,11},{8,14},{8,17},{10,20},{11,21},{14,23},{17,23},{20,21}, + {21,20},{23,17},{23,14},{20,10},{21,11},{17,8},{14,8} + }, + red = {{11,0},{20,0},{11,31},{20,31},{0,11},{0,20},{31,20},{31,11}} + }, 'circle') + test:exportImg(imgdata) end + -- love.graphics.clear love.test.graphics.clear = function(test) - test:skipTest('test class needs writing') + local canvas = love.graphics.newCanvas(16, 16) + love.graphics.setCanvas(canvas) + love.graphics.clear(0, 0, 0, 1) + love.graphics.clear(1, 1, 0, 1) + love.graphics.setCanvas() + local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata, { + yellow = {{0,0},{15,0},{0,15},{15,15},{8,8}} + }, 'clear') + test:exportImg(imgdata) end -- love.graphics.discard love.test.graphics.discard = function(test) - test:skipTest('test class needs writing') + test:skipTest('cant test this worked') + -- wrote all this before seeing "on some desktops this may do nothing" + -- leaving in case we need it in future + --local canvas = love.graphics.newCanvas(32, 32) + --love.graphics.setCanvas(canvas) + -- love.graphics.clear(0, 0, 0, 1) + -- love.graphics.draw(Logo.texture, Logo.img, 0, 0) + -- love.graphics.discard(true, true) + --love.graphics.setCanvas() end -- love.graphics.draw love.test.graphics.draw = function(test) - test:skipTest('test class needs writing') + local canvas1 = love.graphics.newCanvas(32, 32) + local canvas2 = love.graphics.newCanvas(32, 32) + local transform = love.math.newTransform( ) + transform:translate(16, 0) + transform:scale(0.5, 0.5) + love.graphics.setCanvas(canvas1) + love.graphics.clear(0, 0, 0, 1) + -- img, offset + love.graphics.draw(Logo.texture, Logo.img, 0, 0, 0, 1, 1, 16, 16) + love.graphics.setCanvas() + love.graphics.setCanvas(canvas2) + love.graphics.clear(1, 0, 0, 1) + -- canvas, scale, shear, transform obj + love.graphics.draw(canvas1, 0, 0, 0, 0.5, 0.5, 0, 0, 2, 2) + love.graphics.draw(canvas1, 0, 16, 0, 0.5, 0.5) + love.graphics.draw(canvas1, 16, 16, 0, 0.5, 0.5) + love.graphics.draw(canvas1, transform) + love.graphics.setCanvas() + local imgdata = love.graphics.readbackTexture(canvas2, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata, { + lovepink = {{23,3},{23,19},{7,19},{0,0},{16,0},{0,16},{16,16}}, + loveblue = {{0,31},{15,17},{15,31},{16,31},{31,17},{31,31},{16,15},{31,15}}, + white = {{15, 15},{6,19},{8,19},{22,19},{24,19},{22,3},{24,3}}, + red = {{0,1},{1,0},{15,0},{15,7},{0,15},{7,15}} + }, 'drawing') + test:exportImg(imgdata) end @@ -46,37 +174,115 @@ end -- love.graphics.drawLayer love.test.graphics.drawLayer = function(test) - test:skipTest('test class needs writing') + local image = love.graphics.newArrayImage({ + 'resources/love.png', 'resources/loveinv.png', + 'resources/love.png', 'resources/loveinv.png' + }) + local canvas = love.graphics.newCanvas(64, 64) + love.graphics.setCanvas(canvas) + love.graphics.clear(0, 0, 0, 1) + love.graphics.drawLayer(image, 1, 0, 0, 0, 1, 1) + love.graphics.drawLayer(image, 2, 32, 0, 0, 0.5, 0.5) + love.graphics.drawLayer(image, 4, 0, 32, 0, 0.5, 0.5) + love.graphics.drawLayer(image, 3, 32, 32, 0, 2, 2, 16, 16) + love.graphics.setCanvas() + local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata, { + lovepink = {{30,2},{33,2},{2,30},{2,33},{4,60},{4,63},{60,4},{63,4},{31,23},{32,23}}, + loveblue = {{14,33},{17,33},{46,1},{49,1},{1,46},{1,49},{33,14},{33,17}}, + black = {{0,0},{63,0},{0,63},{39,6},{40,6},{6,39},{6,40},{6,55},{55,6}}, + white = {{46,11},{48,11},{14,43},{16,43},{30,23},{33,23},{34,54},{53,40},{63,63}} + }, 'draw layer') + test:exportImg(imgdata) end -- love.graphics.ellipse love.test.graphics.ellipse = function(test) - test:skipTest('test class needs writing') + local canvas = love.graphics.newCanvas(32, 32) + love.graphics.setCanvas(canvas) + love.graphics.clear(0, 0, 0, 1) + love.graphics.setColor(1, 0, 0, 1) + love.graphics.ellipse('fill', 16, 16, 16, 8) + love.graphics.setColor(1, 1, 0, 1) + love.graphics.ellipse('fill', 24, 24, 10, 24) + love.graphics.setColor(1, 0, 1, 1) + love.graphics.ellipse('fill', 16, 0, 8, 16) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.setCanvas() + local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata, { + red = {{0,14},{0,17},{7,9},{7,22},{14,15},{14,16}}, + pink = {{15,15},{16,15},{8,0},{8,4},{23,0},{23,4},{13,14},{18,14}}, + yellow = {{24,0},{25,0},{14,17},{14,30},{15,31},{31,8}} + }, 'ellipses') + test:exportImg(imgdata) end -- love.graphics.flushBatch love.test.graphics.flushBatch = function(test) - test:skipTest('test class needs writing') + test:skipTest('not sure can be tested as used internally') end -- love.graphics.line love.test.graphics.line = function(test) - test:skipTest('test class needs writing') + local canvas = love.graphics.newCanvas(16, 16) + love.graphics.setCanvas(canvas) + love.graphics.clear(0, 0, 0, 1) + love.graphics.setColor(1, 0, 0, 1) + love.graphics.line(1,1,16,1,16,16,1,16,1,1) + love.graphics.setColor(1, 1, 0, 1) + love.graphics.line({0,0,8,8,16,0,8,8,16,16,8,8,0,16}) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.setCanvas() + local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata, { + yellow = {{0,0},{15,0},{0,15},{15,15},{7,7},{8,7},{8,7},{8,8}}, + red = {{1,0},{14,0},{0,1},{0,14},{15,1},{15,14},{1,15},{14,15}} + }, 'lines') + test:exportImg(imgdata) end -- love.graphics.points love.test.graphics.points = function(test) - test:skipTest('test class needs writing') + local canvas = love.graphics.newCanvas(16, 16) + love.graphics.setCanvas(canvas) + love.graphics.clear(0, 0, 0, 1) + love.graphics.setColor(1, 0, 0, 1) + love.graphics.points(1,1,16,1,16,16,1,16,1,1) + love.graphics.setColor(1, 1, 0, 1) + love.graphics.points({2,2,8,8,15,2,8,9,15,15,9,9,2,15,9,8}) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.setCanvas() + local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata, { + yellow = {{1,1},{14,1},{1,14},{14,14},{7,7},{8,7},{8,7},{8,8}}, + red = {{0,0},{15,0},{15,15},{0,15}} + }, 'points') + test:exportImg(imgdata) end -- love.graphics.polygon love.test.graphics.polygon = function(test) - test:skipTest('test class needs writing') + local canvas = love.graphics.newCanvas(16, 16) + love.graphics.setCanvas(canvas) + love.graphics.clear(0, 0, 0, 1) + love.graphics.setColor(1, 0, 0, 1) + love.graphics.polygon("fill", 1, 1, 4, 5, 8, 10, 16, 2, 7, 3, 5, 16, 16, 16, 1, 8) + love.graphics.setColor(1, 1, 0, 1) + love.graphics.polygon("line", {2, 2, 4, 5, 3, 7, 8, 15, 12, 4, 5, 10}) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.setCanvas() + local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata, { + yellow = {{1,0},{1,1},{5,9},{7,14},{8,14},{12,3}}, + red = {{2,1},{1,2},{1,7},{5,15},{14,15},{8,8},{14,2},{7,1}} + }, 'polygon') + test:exportImg(imgdata) end @@ -88,13 +294,61 @@ end -- love.graphics.print love.test.graphics.print = function(test) - test:skipTest('test class needs writing') + love.graphics.setFont(Font) + local canvas = love.graphics.newCanvas(16, 16) + love.graphics.setCanvas(canvas) + love.graphics.clear(0, 0, 0, 1) + love.graphics.setColor(1, 0, 0, 1) + love.graphics.print('love', 0, 3, 0, 1, 1, 0, 0) + love.graphics.setColor(0, 1, 0, 1) + love.graphics.print('ooo', 0, 3, 0, 2, 2, 0, 0) + love.graphics.setColor(0, 0, 1, 1) + love.graphics.print('hello', 0, 3, 90*(math.pi/180), 1, 1, 0, 8) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.setCanvas() + local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata, { + red = {{0,0},{1,0},{1,1},{2,6},{4,4},{7,6},{10,2},{11,5},{14,3},{14,4}}, + green = { + {2,1},{2,2},{0,3},{1,3},{1,8},{2,9},{7,10},{8,8},{9,4},{13,3},{14,2}, + {13,8},{14,9} + }, + blue = { + {4,15},{10,15},{4,12},{6,12},{8,12},{5,9},{7,9},{4,3},{10,3},{8,6},{7,7}, + {4,7},{7,13},{8,12} + } + }, 'print') + test:exportImg(imgdata) end -- love.graphics.printf love.test.graphics.printf = function(test) - test:skipTest('test class needs writing') + love.graphics.setFont(Font) + local canvas = love.graphics.newCanvas(32, 32) + love.graphics.setCanvas(canvas) + love.graphics.clear(0, 0, 0, 1) + love.graphics.setColor(1, 0, 0, 1) + love.graphics.printf('love', 0, 0, 8, "left") + love.graphics.setColor(0, 1, 0, 1) + love.graphics.printf('love', 0, 5, 16, "right") + love.graphics.setColor(0, 0, 1, 1) + love.graphics.printf('love', 0, 7, 32, "center") + love.graphics.setColor(1, 1, 1, 1) + love.graphics.setCanvas() + local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) + test:assertPixels(imgdata, { + red = { + {1,0},{1,1},{0,3},{2,3},{2,7},{0,9},{3,11},{4,10},{0,15},{4,15},{2,19}, + {0,24},{1,23},{3,23},{4,24},{0,26},{1,27},{2,27},{3,27} + }, + green = { + {1,2},{0,8},{1,8},{2,8},{4,7},{5,8},{7,8},{8,7},{10,4},{14,4},{11,7}, + {12,8},{10,13},{11,12},{13,12},{14,13},{10,15},{11,16} + }, + blue = {{6,4},{6,10},{9,7},{10,6},{16,9},{18,9},{21,8},{25,8}} + }, 'printf') + test:exportImg(imgdata) end @@ -138,6 +392,8 @@ love.test.graphics.rectangle = function(test) {9,14},{11,1},{14,1},{11,14},{14,14} } }, 'line') + test:exportImg(imgdata1) + test:exportImg(imgdata2) end @@ -557,7 +813,8 @@ love.test.graphics.intersectScissor = function(test) love.graphics.origin() love.graphics.setScissor(0, 0, 8, 16) love.graphics.intersectScissor(0, 0, 4, 4) - love.graphics.clear(1, 0, 0, 1) + love.graphics.setColor(1, 0, 0, 1) + love.graphics.rectangle('fill', 0, 0, 16, 16) love.graphics.setColor(1, 1, 1, 1) love.graphics.setScissor() love.graphics.setCanvas() @@ -566,6 +823,7 @@ love.test.graphics.intersectScissor = function(test) red = {{0,0},{3,3}}, black ={{4,0},{0,4},{4,4}} }, 'intersect scissor') + test:exportImg(imgdata) end @@ -651,6 +909,7 @@ love.test.graphics.setBlendMode = function(test) bluefade = {{0,15}} }, 'blend mode') love.graphics.setBlendMode('alpha', 'alphamultiply') -- reset + test:exportImg(imgdata) end @@ -673,6 +932,7 @@ love.test.graphics.setCanvas = function(test) test:assertPixels(imgdata, { red = {{0,0},{15,0},{15,15},{0,15}} }, 'set canvas') + test:exportImg(imgdata) end @@ -704,6 +964,7 @@ love.test.graphics.setColor = function(test) greenhalf = {{0,2},{5,2},{10,2},{15,2}}, blue = {{0,3},{5,3},{10,3},{15,3}} }, 'set color') + test:exportImg(imgdata) end @@ -729,6 +990,7 @@ love.test.graphics.setColorMask = function(test) test:assertPixels(imgdata, { yellow = {{0,0},{0,15},{15,15},{15,0}} }, 'set color mask') + test:exportImg(imgdata) end @@ -780,6 +1042,7 @@ love.test.graphics.setFont = function(test) {14,2},{12,6} } }, 'set font for print') + test:exportImg(imgdata) end @@ -827,6 +1090,7 @@ love.test.graphics.setLineJoin = function(test) yellow = {{8,7}}, blue = {{8,8}} }, 'set line join') + test:exportImg(imgdata) end @@ -852,6 +1116,7 @@ love.test.graphics.setLineStyle = function(test) red = {{0,0},{7,0},{15,0}}, red07 = {{0,4},{7,4},{15,4}} }, 'set line style') + test:exportImg(imgdata) end @@ -884,6 +1149,7 @@ love.test.graphics.setLineWidth = function(test) yellow = {{0,3},{0,5},{6,6},{8,6}}, blue = {{0,7},{0,10},{6,15},{9,15}} }, 'set line width') + test:exportImg(imgdata) end @@ -910,7 +1176,8 @@ love.test.graphics.setScissor = function(test) love.graphics.clear(0, 0, 0, 1) love.graphics.origin() love.graphics.setScissor(0, 0, 8, 16) - love.graphics.clear(1, 0, 0, 1) + love.graphics.setColor(1, 0, 0, 1) + love.graphics.rectangle('fill', 0, 0, 16, 16) love.graphics.setColor(1, 1, 1, 1) love.graphics.setScissor() love.graphics.setCanvas() @@ -919,6 +1186,7 @@ love.test.graphics.setScissor = function(test) red = {{0,0},{7,0},{0,15},{7,15}}, black ={{8,0},{8,15},{15,0},{15,15}} }, 'set scissor') + test:exportImg(imgdata) end @@ -942,6 +1210,7 @@ love.test.graphics.setShader = function(test) test:assertPixels(imgdata, { yellow = {{0,0},{15,0},{0,15},{15,15}}, }, 'check shader set to yellow') + test:exportImg(imgdata) end @@ -963,6 +1232,7 @@ love.test.graphics.setStencilTest = function(test) test:assertPixels(imgdata, { red = {{6,2},{9,2},{2,6},{2,9},{13,6},{9,6},{6,13},{9,13}} }, 'check stencil test') + test:exportImg(imgdata) end @@ -983,6 +1253,7 @@ love.test.graphics.setWireframe = function(test) yellow = {{1,14},{14,1},{14,14},{2,2},{13,13}}, black = {{2,13},{13,2}} }, 'set wireframe') + test:exportImg(imgdata) end @@ -1008,6 +1279,7 @@ love.test.graphics.applyTransform = function(test) love.graphics.setCanvas() local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) test:assertPixels(imgdata, { red = {{10, 0}} }, 'apply transform 10') + test:exportImg(imgdata) end @@ -1044,6 +1316,7 @@ love.test.graphics.origin = function(test) love.graphics.setCanvas() local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) test:assertPixels(imgdata, { red = {{0, 0}} }, 'origin check') + test:exportImg(imgdata) end @@ -1065,6 +1338,7 @@ love.test.graphics.pop = function(test) love.graphics.setCanvas() local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) test:assertPixels(imgdata, { red = {{0, 0}} }, 'pop 1') + test:exportImg(imgdata) end @@ -1087,6 +1361,7 @@ love.test.graphics.push = function(test) love.graphics.setCanvas() local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) test:assertPixels(imgdata, { red = {{1, 1}} }, 'push 1') + test:exportImg(imgdata) end @@ -1108,6 +1383,7 @@ love.test.graphics.replaceTransform = function(test) love.graphics.setCanvas() local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) test:assertPixels(imgdata, { red = {{10, 0}} }, 'replace transform 10') + test:exportImg(imgdata) end @@ -1126,6 +1402,7 @@ love.test.graphics.rotate = function(test) love.graphics.setCanvas() local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) test:assertPixels(imgdata, { red = {{0,0},{3,0},{3,3},{0,3}} }, 'rotate 90') + test:exportImg(imgdata) end @@ -1173,6 +1450,8 @@ love.test.graphics.shear = function(test) love.graphics.setCanvas() local imgdata2 = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) test:assertPixels(imgdata2, { red = { {0,1},{0,4},{3,7},{3,10}} }, 'shear y') + test:exportImg(imgdata1) + test:exportImg(imgdata2) end @@ -1210,6 +1489,7 @@ love.test.graphics.translate = function(test) love.graphics.setCanvas() local imgdata = love.graphics.readbackTexture(canvas, {16, 0, 0, 0, 16, 16}) test:assertPixels(imgdata, { red = {{5,0},{0,5},{5,5},{0,0}} }, 'translate 4x') + test:exportImg(imgdata) end diff --git a/testing/todo.md b/testing/todo.md index 5634cbca7..a212b2ab1 100644 --- a/testing/todo.md +++ b/testing/todo.md @@ -1,16 +1,17 @@ `/Applications/love_12.app/Contents/MacOS/love ./testing` ## TESTSUITE -- [ ] setStencilMode to replace setStencilTest -- [ ] start graphics drawing methods - [ ] move object methods to respective modules - [ ] start object methods +- [ ] setStencilMode to replace setStencilTest ## GRAPHICS Methods that need a actual graphic pixel checks if possible: - [ ] setDepthMode - [ ] setFrontFaceWinding - [ ] setMeshCullMode +- [ ] present +- [ ] drawInstanced ## FUTURE - [ ] need a platform: format table somewhere for compressed formats (i.e. DXT not supported)