Skip to content

Commit

Permalink
[dotnet] Add infratructure for previously unsupported interaction types
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Oct 12, 2021
1 parent 5632da3 commit e6cd2a8
Show file tree
Hide file tree
Showing 3 changed files with 370 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dotnet/src/webdriver/Interactions/InputDeviceKind.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="InputDeviceKind.cs" company="WebDriver Committers">
// <copyright file="InputDeviceKind.cs" company="WebDriver Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
Expand Down Expand Up @@ -36,6 +36,11 @@ public enum InputDeviceKind
/// <summary>
/// Represents a pointer-based device, such as a mouse, pen, or stylus.
/// </summary>
Pointer
Pointer,

/// <summary>
/// Represents a wheel device.
/// </summary>
Wheel
}
}
162 changes: 162 additions & 0 deletions dotnet/src/webdriver/Interactions/PointerInputDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,15 @@ public Interaction CreatePointerCancel()
private class PointerDownInteraction : Interaction
{
private MouseButton button;
private double? width;
private double? height;
private double? pressure;
private double? tangentialPressure;
private int? tiltX;
private int? tiltY;
private int? twist;
private double? altitudeAngle;
private double? azimuthAngle;

public PointerDownInteraction(InputDevice sourceDevice, MouseButton button)
: base(sourceDevice)
Expand All @@ -234,6 +243,51 @@ public override Dictionary<string, object> ToDictionary()
toReturn["type"] = "pointerDown";
toReturn["button"] = Convert.ToInt32(this.button, CultureInfo.InvariantCulture);

if (this.width.HasValue)
{
toReturn["width"] = this.width.Value;
}

if (this.height.HasValue)
{
toReturn["height"] = this.width.Value;
}

if (this.pressure.HasValue)
{
toReturn["pressure"] = this.width.Value;
}

if (this.tangentialPressure.HasValue)
{
toReturn["tangentialPressure"] = this.width.Value;
}

if (this.tiltX.HasValue)
{
toReturn["tiltX"] = this.width.Value;
}

if (this.tiltY.HasValue)
{
toReturn["tiltY"] = this.width.Value;
}

if (this.twist.HasValue)
{
toReturn["twist"] = this.width.Value;
}

if (this.altitudeAngle.HasValue)
{
toReturn["altitudeAngle"] = this.width.Value;
}

if (this.azimuthAngle.HasValue)
{
toReturn["azimuthAngle"] = this.width.Value;
}

return toReturn;
}

Expand All @@ -246,6 +300,15 @@ public override string ToString()
private class PointerUpInteraction : Interaction
{
private MouseButton button;
private double? width;
private double? height;
private double? pressure;
private double? tangentialPressure;
private int? tiltX;
private int? tiltY;
private int? twist;
private double? altitudeAngle;
private double? azimuthAngle;

public PointerUpInteraction(InputDevice sourceDevice, MouseButton button)
: base(sourceDevice)
Expand All @@ -259,6 +322,51 @@ public override Dictionary<string, object> ToDictionary()
toReturn["type"] = "pointerUp";
toReturn["button"] = Convert.ToInt32(this.button, CultureInfo.InvariantCulture);

if (this.width.HasValue)
{
toReturn["width"] = this.width.Value;
}

if (this.height.HasValue)
{
toReturn["height"] = this.width.Value;
}

if (this.pressure.HasValue)
{
toReturn["pressure"] = this.width.Value;
}

if (this.tangentialPressure.HasValue)
{
toReturn["tangentialPressure"] = this.width.Value;
}

if (this.tiltX.HasValue)
{
toReturn["tiltX"] = this.width.Value;
}

if (this.tiltY.HasValue)
{
toReturn["tiltY"] = this.width.Value;
}

if (this.twist.HasValue)
{
toReturn["twist"] = this.width.Value;
}

if (this.altitudeAngle.HasValue)
{
toReturn["altitudeAngle"] = this.width.Value;
}

if (this.azimuthAngle.HasValue)
{
toReturn["azimuthAngle"] = this.width.Value;
}

return toReturn;
}

Expand Down Expand Up @@ -295,6 +403,15 @@ private class PointerMoveInteraction : Interaction
private int y = 0;
private TimeSpan duration = TimeSpan.MinValue;
private CoordinateOrigin origin = CoordinateOrigin.Pointer;
private double? width;
private double? height;
private double? pressure;
private double? tangentialPressure;
private int? tiltX;
private int? tiltY;
private int? twist;
private double? altitudeAngle;
private double? azimuthAngle;

public PointerMoveInteraction(InputDevice sourceDevice, IWebElement target, CoordinateOrigin origin, int x, int y, TimeSpan duration)
: base(sourceDevice)
Expand Down Expand Up @@ -343,6 +460,51 @@ public override Dictionary<string, object> ToDictionary()
toReturn["x"] = this.x;
toReturn["y"] = this.y;

if (this.width.HasValue)
{
toReturn["width"] = this.width.Value;
}

if (this.height.HasValue)
{
toReturn["height"] = this.width.Value;
}

if (this.pressure.HasValue)
{
toReturn["pressure"] = this.width.Value;
}

if (this.tangentialPressure.HasValue)
{
toReturn["tangentialPressure"] = this.width.Value;
}

if (this.tiltX.HasValue)
{
toReturn["tiltX"] = this.width.Value;
}

if (this.tiltY.HasValue)
{
toReturn["tiltY"] = this.width.Value;
}

if (this.twist.HasValue)
{
toReturn["twist"] = this.width.Value;
}

if (this.altitudeAngle.HasValue)
{
toReturn["altitudeAngle"] = this.width.Value;
}

if (this.azimuthAngle.HasValue)
{
toReturn["azimuthAngle"] = this.width.Value;
}

return toReturn;
}

Expand Down
Loading

0 comments on commit e6cd2a8

Please sign in to comment.