This commit is contained in:
Lluis Sanchez 2013-06-06 20:23:09 +02:00
Родитель a04e50ddd6
Коммит 28f5bffa84
21 изменённых файлов: 518 добавлений и 12 удалений

Просмотреть файл

@ -9,7 +9,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>GtkTestRunner</RootNamespace>
<AssemblyName>GtkTestRunner</AssemblyName>
<TestRunnerExe>bin\GtkTestRunner.exe</TestRunnerExe>
<TestRunnerCommand>bin\GtkTestRunner.exe</TestRunnerCommand>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@ -60,6 +60,16 @@
<Compile Include="GtkTestRunner\Main.cs" />
<Compile Include="GtkTestRunner\AssemblyInfo.cs" />
<Compile Include="Tests\**\*.cs" />
<Compile Include="Tests\ContainerTests.cs" />
<Compile Include="Tests\PanedTests.cs" />
<Compile Include="Tests\DatePickerTests.cs" />
<Compile Include="Tests\ExpanderTests.cs" />
<Compile Include="Tests\ScrollbarTests.cs" />
<Compile Include="Tests\SliderTests.cs" />
<Compile Include="Tests\SegmentedButtonTests.cs" />
<Compile Include="Tests\SpinnerTests.cs" />
<Compile Include="Tests\ToggleButtonTests.cs" />
<Compile Include="Tests\TreeViewTests.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>

Просмотреть файл

@ -13,7 +13,7 @@
<AssemblyName>MacTestRunner</AssemblyName>
<SuppressXamMacMigration>True</SuppressXamMacMigration>
<SuppressXamMacUpsell>True</SuppressXamMacUpsell>
<TestRunnerExe>bin\MacTestRunner.app</TestRunnerExe>
<TestRunnerCommand>bin\MacTestRunner.app</TestRunnerCommand>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>

Просмотреть файл

@ -27,7 +27,7 @@ using System;
namespace Xwt
{
public abstract class BoxTests: WidgetTests
public abstract class BoxTests: ContainerTests
{
public override Widget CreateWidget ()
{
@ -35,6 +35,12 @@ namespace Xwt
box.PackStart (new Label ("Hello Worlds"));
return box;
}
protected override void AddChild (Widget parent, Widget child)
{
((Box)parent).Clear ();
((Box)parent).PackStart (child, true);
}
public abstract Box CreateBox ();
}

Просмотреть файл

@ -0,0 +1,58 @@
//
// ContainerTests.cs
//
// Author:
// Lluis Sanchez <lluis@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using NUnit.Framework;
namespace Xwt
{
public abstract class ContainerTests: WidgetTests
{
protected abstract void AddChild (Widget parent, Widget child);
[Test]
public void AddChildMargin ()
{
using (var win = new Window ()) {
var c = CreateWidget ();
win.Content = c;
win.Size = new Size (100, 100);
var box = new SquareBox (10);
AddChild (c, box);
ShowWindow (win);
var r1 = box.ScreenBounds;
box.Margin = new WidgetSpacing (5, 10, 15, 20);
WaitForEvents ();
var r2 = box.ScreenBounds;
Assert.AreEqual (r1.Left + 5, r2.Left);
Assert.AreEqual (r1.Top + 10, r2.Top);
Assert.AreEqual (r1.Width - 20, r2.Width);
Assert.AreEqual (r1.Height - 30, r2.Height);
}
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
//
// DatePickerTests.cs
//
// Author:
// Lluis Sanchez <lluis@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Xwt
{
public class DatePickerTests: WidgetTests
{
public override Widget CreateWidget ()
{
return new DatePicker ();
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
//
// ExpanderTests.cs
//
// Author:
// Lluis Sanchez <lluis@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Xwt
{
public class ExpanderTests: WidgetTests
{
public override Widget CreateWidget ()
{
return new Expander ();
}
}
}

Просмотреть файл

@ -28,12 +28,17 @@ using NUnit.Framework;
namespace Xwt
{
public class FrameTests: WidgetTests
public class FrameTests: ContainerTests
{
public override Widget CreateWidget ()
{
return new Frame () { Label = "Hi there" };
}
protected override void AddChild (Widget parent, Widget child)
{
((Frame)parent).Content = child;
}
}
}

Просмотреть файл

@ -27,9 +27,9 @@ using System;
namespace Xwt
{
public class HPanedTests: WidgetTests
public class HPanedTests: PanedTests
{
public override Widget CreateWidget ()
public override Paned CreatePaned ()
{
return new HPaned ();
}

Просмотреть файл

@ -27,12 +27,17 @@ using System;
namespace Xwt
{
public class NotebookTests: WidgetTests
public class NotebookTests: ContainerTests
{
public override Widget CreateWidget ()
{
return new Notebook ();
}
protected override void AddChild (Widget parent, Widget child)
{
((Notebook)parent).Add (child, "Test");
}
}
}

Просмотреть файл

@ -0,0 +1,45 @@
//
// PanedTests.cs
//
// Author:
// Lluis Sanchez <lluis@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Xwt
{
public abstract class PanedTests: ContainerTests
{
public override Widget CreateWidget ()
{
return CreatePaned ();
}
protected override void AddChild (Widget parent, Widget child)
{
((Paned)parent).Panel1.Content = child;
}
public abstract Paned CreatePaned ();
}
}

Просмотреть файл

@ -27,12 +27,17 @@ using System;
namespace Xwt
{
public class ScrollViewTests: WidgetTests
public class ScrollViewTests: ContainerTests
{
public override Widget CreateWidget ()
{
return new ScrollView ();
}
protected override void AddChild (Widget parent, Widget child)
{
((ScrollView)parent).Content = child;
}
}
}

Просмотреть файл

@ -0,0 +1,56 @@
//
// ScrollbarTests.cs
//
// Author:
// Lluis Sanchez <lluis@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Xwt
{
public abstract class ScrollbarTests: WidgetTests
{
public override Widget CreateWidget ()
{
return CreateScrollbar ();
}
public abstract Scrollbar CreateScrollbar ();
}
public class HScrollbarTests: ScrollbarTests
{
public override Scrollbar CreateScrollbar ()
{
return new HScrollbar ();
}
}
public class VScrollbarTests: ScrollbarTests
{
public override Scrollbar CreateScrollbar ()
{
return new VScrollbar ();
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
//
// SegmentedButtonTests.cs
//
// Author:
// Lluis Sanchez <lluis@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Xwt
{
public class SegmentedButtonTests: WidgetTests
{
public override Widget CreateWidget ()
{
return new SegmentedButton ();
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
//
// SliderTests.cs
//
// Author:
// Lluis Sanchez <lluis@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Xwt
{
public class SliderTests: WidgetTests
{
public override Widget CreateWidget ()
{
return new Slider ();
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
//
// SpinnerTests.cs
//
// Author:
// Lluis Sanchez <lluis@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Xwt
{
public class SpinnerTests: WidgetTests
{
public override Widget CreateWidget ()
{
return new Spinner ();
}
}
}

Просмотреть файл

@ -27,7 +27,7 @@ using System;
namespace Xwt
{
public class TableTests: WidgetTests
public class TableTests: ContainerTests
{
public override Widget CreateWidget ()
{
@ -35,6 +35,12 @@ namespace Xwt
t.Add (new Label ("Hello Worlds"), 0, 0);
return t;
}
protected override void AddChild (Widget parent, Widget child)
{
((Table)parent).Clear ();
((Table)parent).Add (child, 0, 0, hexpand: true, vexpand: true);
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
//
// ToggleButtonTests.cs
//
// Author:
// Lluis Sanchez <lluis@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Xwt
{
public class ToggleButtonTests: WidgetTests
{
public override Widget CreateWidget ()
{
return new ToggleButton ();
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
//
// TreeViewTests.cs
//
// Author:
// Lluis Sanchez <lluis@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Xwt
{
public class TreeViewTests: WidgetTests
{
public override Widget CreateWidget ()
{
return new TreeView ();
}
}
}

Просмотреть файл

@ -27,9 +27,9 @@ using System;
namespace Xwt
{
public class VPanedTests: WidgetTests
public class VPanedTests: PanedTests
{
public override Widget CreateWidget ()
public override Paned CreatePaned ()
{
return new VPaned ();
}

Просмотреть файл

@ -0,0 +1,37 @@
//
// VScrollbar.cs
//
// Author:
// Lluis Sanchez <lluis@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace GtkTestRunner
{
public class VScrollbar
{
public VScrollbar ()
{
}
}
}

Просмотреть файл

@ -189,9 +189,16 @@ namespace Xwt
class SquareBox: Canvas
{
double size;
public SquareBox (double size = 10)
{
this.size = size;
}
protected override Size OnGetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
{
return new Size (10, 10);
return new Size (size, size);
}
protected override void OnDraw (Context ctx, Rectangle dirtyRect)