mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-05 14:16:00 +00:00
Add GameWindow tests
This commit is contained in:
parent
662d6f14f5
commit
83429da3b4
|
@ -38,6 +38,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{5EEE
|
||||||
EndProject
|
EndProject
|
||||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OpenTK.Tests", "tests\OpenTK.Tests\OpenTK.Tests.fsproj", "{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}"
|
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OpenTK.Tests", "tests\OpenTK.Tests\OpenTK.Tests.fsproj", "{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OpenTK.Tests.Integration", "tests\OpenTK.Tests.Integration\OpenTK.Tests.Integration.fsproj", "{522D9279-3ED6-475F-867A-6AE69A53C24A}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -84,6 +86,10 @@ Global
|
||||||
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}.Release|Any CPU.Build.0 = Release|Any CPU
|
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{522D9279-3ED6-475F-867A-6AE69A53C24A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{522D9279-3ED6-475F-867A-6AE69A53C24A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{522D9279-3ED6-475F-867A-6AE69A53C24A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{522D9279-3ED6-475F-867A-6AE69A53C24A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -91,5 +97,6 @@ Global
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{C4DDD20F-CB4E-43F4-A75C-4A3D668E1F99} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
|
{C4DDD20F-CB4E-43F4-A75C-4A3D668E1F99} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
|
||||||
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
|
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
|
||||||
|
{522D9279-3ED6-475F-867A-6AE69A53C24A} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -88,7 +88,7 @@ let activeProjects =
|
||||||
-- "**/OpenTK.iOS.csproj"
|
-- "**/OpenTK.iOS.csproj"
|
||||||
|
|
||||||
!! "src/**/*.??proj"
|
!! "src/**/*.??proj"
|
||||||
++ "tests/**/OpenTK.Tests.fsproj"
|
++ "tests/**/OpenTK.Tests*.fsproj"
|
||||||
|> xamarinFilter
|
|> xamarinFilter
|
||||||
|
|
||||||
// Generate assembly info files with the right version & up-to-date information
|
// Generate assembly info files with the right version & up-to-date information
|
||||||
|
|
17
tests/OpenTK.Tests.Integration/App.config
Normal file
17
tests/OpenTK.Tests.Integration/App.config
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.4.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
<!--<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||||
|
</startup>-->
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
41
tests/OpenTK.Tests.Integration/AssemblyInfo.fs
Normal file
41
tests/OpenTK.Tests.Integration/AssemblyInfo.fs
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
namespace OpenTK.Tests.Integration.AssemblyInfo
|
||||||
|
|
||||||
|
open System.Reflection
|
||||||
|
open System.Runtime.CompilerServices
|
||||||
|
open System.Runtime.InteropServices
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[<assembly: AssemblyTitle("OpenTK.Tests.Integration")>]
|
||||||
|
[<assembly: AssemblyDescription("")>]
|
||||||
|
[<assembly: AssemblyConfiguration("")>]
|
||||||
|
[<assembly: AssemblyCompany("")>]
|
||||||
|
[<assembly: AssemblyProduct("OpenTK.Tests.Integration")>]
|
||||||
|
[<assembly: AssemblyCopyright("Copyright © 2017")>]
|
||||||
|
[<assembly: AssemblyTrademark("")>]
|
||||||
|
[<assembly: AssemblyCulture("")>]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[<assembly: ComVisible(false)>]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[<assembly: Guid("522d9279-3ed6-475f-867a-6ae69a53c24a")>]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [<assembly: AssemblyVersion("1.0.*")>]
|
||||||
|
[<assembly: AssemblyVersion("1.0.0.0")>]
|
||||||
|
[<assembly: AssemblyFileVersion("1.0.0.0")>]
|
||||||
|
|
||||||
|
do
|
||||||
|
()
|
194
tests/OpenTK.Tests.Integration/GameWindowTests.fs
Normal file
194
tests/OpenTK.Tests.Integration/GameWindowTests.fs
Normal file
|
@ -0,0 +1,194 @@
|
||||||
|
namespace OpenTK.Tests.Integration
|
||||||
|
|
||||||
|
open Xunit
|
||||||
|
open FsCheck
|
||||||
|
open FsCheck.Xunit
|
||||||
|
open System
|
||||||
|
open System.Runtime.InteropServices
|
||||||
|
open OpenTK
|
||||||
|
|
||||||
|
module GameWindow =
|
||||||
|
module General =
|
||||||
|
[<Fact>]
|
||||||
|
let ``Can create and close GameWindow`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
gw.Close()
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Exit works like Close`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
gw.Exit()
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``GameWindow exists after creation`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
Assert.True(gw.Exists)
|
||||||
|
gw.Exit()
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Can close GameWindow on UpdateFrame`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
gw.UpdateFrame.Add(fun _ -> gw.Close())
|
||||||
|
gw.Run()
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Closing event is sent before closed`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
let signals = System.Collections.Generic.List<string>()
|
||||||
|
gw.Closing.Add(fun _ -> signals.Add("Closing"))
|
||||||
|
gw.Closed.Add(fun _ -> signals.Add("Closed"))
|
||||||
|
gw.Close()
|
||||||
|
Assert.Equal([], signals)
|
||||||
|
gw.ProcessEvents()
|
||||||
|
Assert.Equal(["Closing"; "Closed"], signals)
|
||||||
|
|
||||||
|
module Constructors =
|
||||||
|
[<Fact>]
|
||||||
|
let ``Width and Height can be set via constructor`` () =
|
||||||
|
use gw = new OpenTK.GameWindow(200, 100)
|
||||||
|
Assert.Equal(200, gw.Width)
|
||||||
|
Assert.Equal(100, gw.Height)
|
||||||
|
|
||||||
|
module Sizes =
|
||||||
|
[<Fact>]
|
||||||
|
let ``Updates to Width take effect`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
let oldWidth = gw.Width
|
||||||
|
let newWidth = oldWidth + 1
|
||||||
|
gw.Width <- newWidth
|
||||||
|
Assert.Equal(newWidth, gw.Width)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Updates to Height take effect`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
let oldHeight = gw.Height
|
||||||
|
let newHeight = oldHeight + 1
|
||||||
|
gw.Height <- newHeight
|
||||||
|
Assert.Equal(newHeight, gw.Height)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Updates to Size take effect`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
let oldSize = gw.Size
|
||||||
|
let newSize = System.Drawing.Size(oldSize.Width + 1, oldSize.Height + 1)
|
||||||
|
gw.Size <- newSize
|
||||||
|
Assert.Equal(newSize, gw.Size)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Updates to ClientSize take effect`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
let oldSize = gw.ClientSize
|
||||||
|
let newSize = System.Drawing.Size(oldSize.Width + 1, oldSize.Height + 1)
|
||||||
|
gw.ClientSize <- newSize
|
||||||
|
Assert.Equal(newSize, gw.ClientSize)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Updates to ClientRectangle.Size take effect`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
let oldSize = gw.ClientRectangle.Size
|
||||||
|
let newSize = System.Drawing.Size(oldSize.Width + 1, oldSize.Height + 1)
|
||||||
|
let newRect = System.Drawing.Rectangle(gw.ClientRectangle.Location, newSize)
|
||||||
|
gw.ClientRectangle <- newRect
|
||||||
|
Assert.Equal(newRect, gw.ClientRectangle)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Updates to Bounds.Size take effect`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
let oldSize = gw.Bounds.Size
|
||||||
|
let newSize = System.Drawing.Size(oldSize.Width + 1, oldSize.Height + 1)
|
||||||
|
let newRect = System.Drawing.Rectangle(gw.Bounds.Location, newSize)
|
||||||
|
gw.Bounds <- newRect
|
||||||
|
Assert.Equal(newRect, gw.Bounds)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``ClientSize equals ClientRectangle.Size`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
Assert.Equal(gw.ClientSize, gw.ClientRectangle.Size)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Size equals Bounds.Size`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
Assert.Equal(gw.Size, gw.Bounds.Size)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Width and Height equals ClientSize`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
Assert.Equal(System.Drawing.Size(gw.Width, gw.Height), gw.ClientSize)
|
||||||
|
|
||||||
|
module Locations =
|
||||||
|
[<Fact>]
|
||||||
|
let ``Updates to X take effect`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
let oldX = gw.X
|
||||||
|
let newX = oldX + 1
|
||||||
|
gw.X <- newX
|
||||||
|
Assert.Equal(newX, gw.X)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Updates to Y take effect`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
let oldY = gw.Y
|
||||||
|
let newY = oldY + 1
|
||||||
|
gw.Y <- newY
|
||||||
|
Assert.Equal(newY, gw.Y)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Updates to Location take effect`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
let oldLocation = gw.Location
|
||||||
|
let newLocation = System.Drawing.Point(oldLocation.X + 1, oldLocation.Y + 1)
|
||||||
|
gw.Location <- newLocation
|
||||||
|
Assert.Equal(newLocation, gw.Location)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Updates to Bounds.Location take effect`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
let oldLocation = gw.Bounds.Location
|
||||||
|
let newLocation = System.Drawing.Point(oldLocation.X + 1, oldLocation.Y + 1)
|
||||||
|
let newRect = System.Drawing.Rectangle(newLocation, gw.ClientRectangle.Size)
|
||||||
|
gw.Bounds <- newRect
|
||||||
|
Assert.Equal(newRect, gw.Bounds)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Location equals Bounds.Location`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
Assert.Equal(gw.Location, gw.Bounds.Location)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``X and Y equals Location`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
Assert.Equal(System.Drawing.Point(gw.X, gw.Y), gw.Location)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``ClientRectangle.Location is zero`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
Assert.Equal(System.Drawing.Point.Empty, gw.ClientRectangle.Location)
|
||||||
|
|
||||||
|
module Borders =
|
||||||
|
[<Fact>]
|
||||||
|
let ``Updates to BorderStyle take effect`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
gw.WindowBorder <- WindowBorder.Fixed
|
||||||
|
Assert.Equal(WindowBorder.Fixed, gw.WindowBorder)
|
||||||
|
gw.WindowBorder <- WindowBorder.Hidden
|
||||||
|
Assert.Equal(WindowBorder.Hidden, gw.WindowBorder)
|
||||||
|
gw.WindowBorder <- WindowBorder.Resizable
|
||||||
|
Assert.Equal(WindowBorder.Resizable, gw.WindowBorder)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Can resize fixed borders`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
gw.WindowBorder <- WindowBorder.Fixed
|
||||||
|
let oldSize = gw.Size
|
||||||
|
let newSize = System.Drawing.Size(oldSize.Width + 1, oldSize.Height + 1)
|
||||||
|
gw.Size <- newSize
|
||||||
|
Assert.Equal(newSize, gw.Size)
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Can resize hidden borders`` () =
|
||||||
|
use gw = new OpenTK.GameWindow()
|
||||||
|
gw.WindowBorder <- WindowBorder.Hidden
|
||||||
|
let oldSize = gw.Size
|
||||||
|
let newSize = System.Drawing.Size(oldSize.Width + 1, oldSize.Height + 1)
|
||||||
|
gw.Size <- newSize
|
||||||
|
Assert.Equal(newSize, gw.Size)
|
1678
tests/OpenTK.Tests.Integration/OpenTK.Tests.Integration.fsproj
Normal file
1678
tests/OpenTK.Tests.Integration/OpenTK.Tests.Integration.fsproj
Normal file
File diff suppressed because it is too large
Load diff
2
tests/OpenTK.Tests.Integration/paket.references
Normal file
2
tests/OpenTK.Tests.Integration/paket.references
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
FsCheck.Xunit
|
||||||
|
xunit.assert
|
Loading…
Reference in a new issue