Browse Source

Revert "fix tests"

This reverts commit 584e18f78d29480890711b1149d946f61e0d8447.
pull/9652/head
Emmanuel Hansen 3 years ago
parent
commit
f61c7f6cd9
  1. 10
      tests/Avalonia.Base.UnitTests/Input/GesturesTests.cs
  2. 2
      tests/Avalonia.Base.UnitTests/Input/TouchDeviceTests.cs
  3. 3
      tests/Avalonia.Controls.UnitTests/ButtonTests.cs
  4. 4
      tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs
  5. 13
      tests/Avalonia.Controls.UnitTests/ListBoxTests_Single.cs
  6. 3
      tests/Avalonia.Controls.UnitTests/Mixins/PressedMixinTests.cs
  7. 8
      tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs
  8. 29
      tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests_Multiple.cs
  9. 3
      tests/Avalonia.Controls.UnitTests/TreeViewTests.cs
  10. 3
      tests/Avalonia.UnitTests/TestServices.cs

10
tests/Avalonia.Base.UnitTests/Input/GesturesTests.cs

@ -5,7 +5,6 @@ using Avalonia.Input.GestureRecognizers;
using Avalonia.Media;
using Avalonia.Platform;
using Avalonia.UnitTests;
using Moq;
using Xunit;
namespace Avalonia.Base.UnitTests.Input
@ -17,7 +16,6 @@ namespace Avalonia.Base.UnitTests.Input
[Fact]
public void Tapped_Should_Follow_Pointer_Pressed_Released()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
Border border = new Border();
var decorator = new Decorator
{
@ -35,7 +33,6 @@ namespace Avalonia.Base.UnitTests.Input
[Fact]
public void Tapped_Should_Be_Raised_Even_When_Pressed_Released_Handled()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
Border border = new Border();
var decorator = new Decorator
{
@ -53,7 +50,6 @@ namespace Avalonia.Base.UnitTests.Input
[Fact]
public void Tapped_Should_Not_Be_Raised_For_Middle_Button()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
Border border = new Border();
var decorator = new Decorator
{
@ -71,7 +67,6 @@ namespace Avalonia.Base.UnitTests.Input
[Fact]
public void Tapped_Should_Not_Be_Raised_For_Right_Button()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
Border border = new Border();
var decorator = new Decorator
{
@ -89,7 +84,6 @@ namespace Avalonia.Base.UnitTests.Input
[Fact]
public void RightTapped_Should_Be_Raised_For_Right_Button()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
Border border = new Border();
var decorator = new Decorator
{
@ -107,7 +101,6 @@ namespace Avalonia.Base.UnitTests.Input
[Fact]
public void DoubleTapped_Should_Follow_Pointer_Pressed_Released_Pressed()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
Border border = new Border();
var decorator = new Decorator
{
@ -126,7 +119,6 @@ namespace Avalonia.Base.UnitTests.Input
[Fact]
public void DoubleTapped_Should_Be_Raised_Even_When_Pressed_Released_Handled()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
Border border = new Border();
var decorator = new Decorator
{
@ -145,7 +137,6 @@ namespace Avalonia.Base.UnitTests.Input
[Fact]
public void DoubleTapped_Should_Not_Be_Raised_For_Middle_Button()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
Border border = new Border();
var decorator = new Decorator
{
@ -164,7 +155,6 @@ namespace Avalonia.Base.UnitTests.Input
[Fact]
public void DoubleTapped_Should_Not_Be_Raised_For_Right_Button()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
Border border = new Border();
var decorator = new Decorator
{

2
tests/Avalonia.Base.UnitTests/Input/TouchDeviceTests.cs

@ -207,7 +207,7 @@ namespace Avalonia.Input.UnitTests
private IDisposable UnitTestApp(TimeSpan doubleClickTime = new TimeSpan())
{
var unitTestApp = UnitTestApplication.Start(
new TestServices(inputManager: new InputManager(), threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
new TestServices(inputManager: new InputManager()));
var iSettingsMock = new Mock<IPlatformSettings>();
iSettingsMock.Setup(x => x.GetDoubleTapTime(It.IsAny<PointerType>())).Returns(doubleClickTime);
iSettingsMock.Setup(x => x.GetDoubleTapSize(It.IsAny<PointerType>())).Returns(new Size(16, 16));

3
tests/Avalonia.Controls.UnitTests/ButtonTests.cs

@ -134,7 +134,6 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Button_Raises_Click()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
var renderer = Mock.Of<IRenderer>();
var pt = new Point(50, 50);
Mock.Get(renderer).Setup(r => r.HitTest(It.IsAny<Point>(), It.IsAny<Visual>(), It.IsAny<Func<Visual, bool>>()))
@ -167,7 +166,6 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Button_Does_Not_Raise_Click_When_PointerReleased_Outside()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
var renderer = Mock.Of<IRenderer>();
Mock.Get(renderer).Setup(r => r.HitTest(It.IsAny<Point>(), It.IsAny<Visual>(), It.IsAny<Func<Visual, bool>>()))
@ -201,7 +199,6 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Button_With_RenderTransform_Raises_Click()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
var renderer = Mock.Of<IRenderer>();
var pt = new Point(150, 50);
Mock.Get(renderer).Setup(r => r.HitTest(It.IsAny<Point>(), It.IsAny<Visual>(), It.IsAny<Func<Visual, bool>>()))

4
tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs

@ -11,8 +11,6 @@ using Avalonia.Media;
using Avalonia.VisualTree;
using Avalonia.UnitTests;
using Xunit;
using Moq;
using Avalonia.Platform;
namespace Avalonia.Controls.UnitTests
{
@ -23,7 +21,6 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Clicking_On_Control_Toggles_IsDropDownOpen()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
var target = new ComboBox
{
Items = new[] { "Foo", "Bar" },
@ -44,7 +41,6 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Clicking_On_Control_PseudoClass()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
var target = new ComboBox
{
Items = new[] { "Foo", "Bar" },

13
tests/Avalonia.Controls.UnitTests/ListBoxTests_Single.cs

@ -8,7 +8,6 @@ using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.LogicalTree;
using Avalonia.Platform;
using Avalonia.Styling;
using Avalonia.UnitTests;
using Avalonia.VisualTree;
@ -116,7 +115,7 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Clicking_Item_Should_Select_It()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -134,7 +133,7 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Clicking_Selected_Item_Should_Not_Deselect_It()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -154,7 +153,7 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Clicking_Item_Should_Select_It_When_SelectionMode_Toggle()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -174,7 +173,7 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Clicking_Selected_Item_Should_Deselect_It_When_SelectionMode_Toggle()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -196,7 +195,7 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Clicking_Selected_Item_Should_Not_Deselect_It_When_SelectionMode_ToggleAlwaysSelected()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -217,7 +216,7 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Clicking_Another_Item_Should_Select_It_When_SelectionMode_Toggle()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{

3
tests/Avalonia.Controls.UnitTests/Mixins/PressedMixinTests.cs

@ -1,7 +1,5 @@
using Avalonia.Controls.Mixins;
using Avalonia.Platform;
using Avalonia.UnitTests;
using Moq;
using Xunit;
namespace Avalonia.Controls.UnitTests.Mixins
@ -21,7 +19,6 @@ namespace Avalonia.Controls.UnitTests.Mixins
[Fact]
public void Setting_IsSelected_Should_Add_Selected_Class()
{
using var app = UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)));
var target = new TestControl();
_mouse.Down(target);

8
tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs

@ -1118,7 +1118,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Setting_SelectedItem_With_Pointer_Should_Set_TabOnceActiveElement()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -1140,7 +1140,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Removing_SelectedItem_Should_Clear_TabOnceActiveElement()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var items = new ObservableCollection<string>(new[] { "Foo", "Bar", "Baz " });
@ -1239,7 +1239,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Should_Select_Correct_Item_When_Duplicate_Items_Are_Present()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -1257,7 +1257,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Should_Apply_Selected_Pseudoclass_To_Correct_Item_When_Duplicate_Items_Are_Present()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{

29
tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests_Multiple.cs

@ -12,7 +12,6 @@ using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.Interactivity;
using Avalonia.Platform;
using Avalonia.UnitTests;
using Moq;
using Xunit;
@ -704,7 +703,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Shift_Selecting_From_No_Selection_Selects_From_Start()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -727,7 +726,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Ctrl_Selecting_Raises_SelectionChanged_Events()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -781,7 +780,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Ctrl_Selecting_SelectedItem_With_Multiple_Selection_Active_Sets_SelectedItem_To_Next_Selection()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -811,7 +810,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Ctrl_Selecting_Non_SelectedItem_With_Multiple_Selection_Active_Leaves_SelectedItem_The_Same()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -839,7 +838,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Should_Ctrl_Select_Correct_Item_When_Duplicate_Items_Are_Present()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -863,7 +862,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Should_Shift_Select_Correct_Item_When_Duplicates_Are_Present()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -887,7 +886,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Can_Shift_Select_All_Items_When_Duplicates_Are_Present()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -911,7 +910,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Shift_Selecting_Raises_SelectionChanged_Events()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -960,7 +959,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Duplicate_Items_Are_Added_To_SelectedItems_In_Order()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -1190,7 +1189,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Left_Click_On_SelectedItem_Should_Clear_Existing_Selection()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -1217,7 +1216,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Right_Click_On_SelectedItem_Should_Not_Clear_Existing_Selection()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -1242,7 +1241,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Right_Click_On_UnselectedItem_Should_Clear_Existing_Selection()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -1294,7 +1293,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Shift_Right_Click_Should_Not_Select_Multiple()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{
@ -1317,7 +1316,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
[Fact]
public void Ctrl_Right_Click_Should_Not_Select_Multiple()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var target = new ListBox
{

3
tests/Avalonia.Controls.UnitTests/TreeViewTests.cs

@ -15,7 +15,6 @@ using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.Interactivity;
using Avalonia.LogicalTree;
using Avalonia.Platform;
using Avalonia.Styling;
using Avalonia.UnitTests;
using Moq;
@ -1467,7 +1466,7 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Right_Click_On_SelectedItem_Should_Not_Clear_Existing_Selection()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true))))
using (UnitTestApplication.Start())
{
var tree = CreateTestTreeData();
var target = new TreeView

3
tests/Avalonia.UnitTests/TestServices.cs

@ -51,8 +51,7 @@ namespace Avalonia.UnitTests
inputManager: new InputManager(),
assetLoader: new AssetLoader(),
renderInterface: new MockPlatformRenderInterface(),
fontManagerImpl: new MockFontManagerImpl(),
threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true),
fontManagerImpl: new MockFontManagerImpl(),
textShaperImpl: new MockTextShaperImpl());
public static readonly TestServices TextServices = new TestServices(

Loading…
Cancel
Save