Skip to content

Commit

Permalink
Touchscreen tests improvements (#1012)
Browse files Browse the repository at this point in the history
* Touchscreen tests improvements

* update test
  • Loading branch information
kblok authored Mar 14, 2019
1 parent d74605d commit ea7fc34
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
20 changes: 0 additions & 20 deletions lib/PuppeteerSharp.Tests/InputTests/InputTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,26 +587,6 @@ await Page.EvaluateFunctionAsync(@"() => {
}, await Page.EvaluateExpressionAsync<DomPointInternal>("result"));
}

[Fact]
public async Task ShouldTapTheButton()
{
await Page.GoToAsync(TestConstants.ServerUrl + "/input/button.html");
await Page.TapAsync("button");
Assert.Equal("Clicked", await Page.EvaluateExpressionAsync<string>("result"));
}

[Fact(Skip = "test is ignored")]
public async Task ShouldReportTouches()
{
await Page.GoToAsync(TestConstants.ServerUrl + "/input/touches.html");
var button = await Page.QuerySelectorAsync("button");
await button.TapAsync();
Assert.Equal(new object[] {
new { Touchstart = 0 },
new { Touchend = 0 }
}, await Page.EvaluateExpressionAsync("getResult()"));
}

[Fact]
public async Task ShouldClickTheButtonInsideAnIframe()
{
Expand Down
39 changes: 39 additions & 0 deletions lib/PuppeteerSharp.Tests/InputTests/TouchScreenTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Threading.Tasks;
using PuppeteerSharp.Mobile;
using Xunit;
using Xunit.Abstractions;

namespace PuppeteerSharp.Tests.InputTests
{
[Collection("PuppeteerLoaderFixture collection")]
public class TouchScreenTests : PuppeteerPageBaseTest
{
private readonly DeviceDescriptor _iPhone = DeviceDescriptors.Get(DeviceDescriptorName.IPhone6);

public TouchScreenTests(ITestOutputHelper output) : base(output)
{
}

[Fact]
public async Task ShouldTapTheButton()
{
await Page.EmulateAsync(_iPhone);
await Page.GoToAsync(TestConstants.ServerUrl + "/input/button.html");
await Page.TapAsync("button");
Assert.Equal("Clicked", await Page.EvaluateExpressionAsync<string>("result"));
}

[Fact]
public async Task ShouldReportTouches()
{
await Page.EmulateAsync(_iPhone);
await Page.GoToAsync(TestConstants.ServerUrl + "/input/touches.html");
var button = await Page.QuerySelectorAsync("button");
await button.TapAsync();
Assert.Equal(new string[] {
"Touchstart: 0",
"Touchend: 0"
}, await Page.EvaluateExpressionAsync<string[]>("getResult()"));
}
}
}

0 comments on commit ea7fc34

Please sign in to comment.