Skip to content

Commit a3aa07e

Browse files
committed
None input action
1 parent 588e358 commit a3aa07e

File tree

4 files changed

+107
-80
lines changed

4 files changed

+107
-80
lines changed

dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/InputSourceActionsConverter.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ public override void Write(Utf8JsonWriter writer, SourceActions value, JsonSeria
4545
writer.WritePropertyName("actions");
4646
JsonSerializer.Serialize(writer, wheels.Actions, options);
4747

48+
break;
49+
case SourceActions.None none:
50+
writer.WriteString("type", "none");
51+
writer.WritePropertyName("actions");
52+
JsonSerializer.Serialize(writer, none.Actions, options);
53+
4854
break;
4955
}
5056

dotnet/src/webdriver/BiDi/Modules/Input/SourceActions.cs

Lines changed: 83 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -46,79 +46,100 @@ public record Wheels : SourceActions, IEnumerable<Wheel>
4646
IEnumerator IEnumerable.GetEnumerator() => Actions.GetEnumerator();
4747
}
4848

49-
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
50-
[JsonDerivedType(typeof(Pause), "pause")]
51-
[JsonDerivedType(typeof(Down), "keyDown")]
52-
[JsonDerivedType(typeof(Up), "keyUp")]
53-
public abstract record Key
49+
public record None : SourceActions, IEnumerable<Input.None>
5450
{
55-
public record Pause : Key
56-
{
57-
public long? Duration { get; set; }
58-
}
51+
public IList<Input.None> Actions { get; set; } = [];
5952

60-
public record Down(string Value) : Key;
53+
public void Add(Input.None none) => Actions.Add(none);
6154

62-
public record Up(string Value) : Key;
55+
public IEnumerator<Input.None> GetEnumerator() => Actions.GetEnumerator();
56+
57+
IEnumerator IEnumerable.GetEnumerator() => Actions.GetEnumerator();
6358
}
59+
}
6460

65-
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
66-
[JsonDerivedType(typeof(Pause), "pause")]
67-
[JsonDerivedType(typeof(Down), "pointerDown")]
68-
[JsonDerivedType(typeof(Up), "pointerUp")]
69-
[JsonDerivedType(typeof(Move), "pointerMove")]
70-
public abstract record Pointer
61+
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
62+
[JsonDerivedType(typeof(Pause), "pause")]
63+
[JsonDerivedType(typeof(Down), "keyDown")]
64+
[JsonDerivedType(typeof(Up), "keyUp")]
65+
public abstract record Key
66+
{
67+
public record Pause : Key
7168
{
72-
public record Pause : Pointer
73-
{
74-
public long? Duration { get; set; }
75-
}
76-
77-
public record Down(int Button) : Pointer, IPointerCommonProperties
78-
{
79-
public int? Width { get; set; }
80-
public int? Height { get; set; }
81-
public double? Pressure { get; set; }
82-
public double? TangentialPressure { get; set; }
83-
public int? Twist { get; set; }
84-
public double? AltitudeAngle { get; set; }
85-
public double? AzimuthAngle { get; set; }
86-
}
87-
88-
public record Up(int Button) : Pointer;
89-
90-
public record Move(int X, int Y) : Pointer, IPointerCommonProperties
91-
{
92-
public int? Duration { get; set; }
93-
94-
public Origin? Origin { get; set; }
95-
96-
public int? Width { get; set; }
97-
public int? Height { get; set; }
98-
public double? Pressure { get; set; }
99-
public double? TangentialPressure { get; set; }
100-
public int? Twist { get; set; }
101-
public double? AltitudeAngle { get; set; }
102-
public double? AzimuthAngle { get; set; }
103-
}
69+
public long? Duration { get; set; }
10470
}
10571

106-
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
107-
[JsonDerivedType(typeof(Pause), "pause")]
108-
[JsonDerivedType(typeof(Scroll), "scroll")]
109-
public abstract record Wheel
72+
public record Down(string Value) : Key;
73+
74+
public record Up(string Value) : Key;
75+
}
76+
77+
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
78+
[JsonDerivedType(typeof(Pause), "pause")]
79+
[JsonDerivedType(typeof(Down), "pointerDown")]
80+
[JsonDerivedType(typeof(Up), "pointerUp")]
81+
[JsonDerivedType(typeof(Move), "pointerMove")]
82+
public abstract record Pointer
83+
{
84+
public record Pause : Pointer
85+
{
86+
public long? Duration { get; set; }
87+
}
88+
89+
public record Down(int Button) : Pointer, IPointerCommonProperties
90+
{
91+
public int? Width { get; set; }
92+
public int? Height { get; set; }
93+
public double? Pressure { get; set; }
94+
public double? TangentialPressure { get; set; }
95+
public int? Twist { get; set; }
96+
public double? AltitudeAngle { get; set; }
97+
public double? AzimuthAngle { get; set; }
98+
}
99+
100+
public record Up(int Button) : Pointer;
101+
102+
public record Move(int X, int Y) : Pointer, IPointerCommonProperties
110103
{
111-
public record Pause : Wheel
112-
{
113-
public long? Duration { get; set; }
114-
}
104+
public int? Duration { get; set; }
115105

116-
public record Scroll(int X, int Y, int DeltaX, int DeltaY) : Wheel
117-
{
118-
public int? Duration { get; set; }
106+
public Origin? Origin { get; set; }
119107

120-
public Origin? Origin { get; set; }
121-
}
108+
public int? Width { get; set; }
109+
public int? Height { get; set; }
110+
public double? Pressure { get; set; }
111+
public double? TangentialPressure { get; set; }
112+
public int? Twist { get; set; }
113+
public double? AltitudeAngle { get; set; }
114+
public double? AzimuthAngle { get; set; }
115+
}
116+
}
117+
118+
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
119+
[JsonDerivedType(typeof(Pause), "pause")]
120+
[JsonDerivedType(typeof(Scroll), "scroll")]
121+
public abstract record Wheel
122+
{
123+
public record Pause : Wheel
124+
{
125+
public long? Duration { get; set; }
126+
}
127+
128+
public record Scroll(int X, int Y, int DeltaX, int DeltaY) : Wheel
129+
{
130+
public int? Duration { get; set; }
131+
132+
public Origin? Origin { get; set; }
133+
}
134+
}
135+
136+
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
137+
[JsonDerivedType(typeof(Pause), "pause")]
138+
public abstract record None
139+
{
140+
public record Pause : None
141+
{
142+
public long? Duration { get; set; }
122143
}
123144
}
124145

dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ public async Task Paint()
1515
await Task.Delay(3000);
1616

1717
await context.Input.PerformActionsAsync([new SourceActions.Pointers {
18-
new SourceActions.Pointer.Move(300, 300),
19-
new SourceActions.Pointer.Down(0),
20-
new SourceActions.Pointer.Move(400, 400) { Duration = 2000, Width = 1, Twist = 1 },
21-
new SourceActions.Pointer.Up(0),
18+
new Pointer.Move(300, 300),
19+
new Pointer.Down(0),
20+
new Pointer.Move(400, 400) { Duration = 2000, Width = 1, Twist = 1 },
21+
new Pointer.Up(0),
2222
}]);
2323

2424
await context.Input.PerformActionsAsync([new SourceActions.Keys {
25-
new SourceActions.Key.Down("U"),
26-
new SourceActions.Key.Up("U")
25+
new Key.Down("U"),
26+
new Key.Up("U")
2727
}]);
2828

2929
await context.Input.PerformActionsAsync([new SourceActions.Pointers {
30-
new SourceActions.Pointer.Move(300, 300),
31-
new SourceActions.Pointer.Down(0),
32-
new SourceActions.Pointer.Move(400, 400) { Duration = 2000 },
33-
new SourceActions.Pointer.Up(0),
30+
new Pointer.Move(300, 300),
31+
new Pointer.Down(0),
32+
new Pointer.Move(400, 400) { Duration = 2000 },
33+
new Pointer.Up(0),
3434
}]);
3535

3636
await Task.Delay(3000);
@@ -46,8 +46,8 @@ public async Task TestShiftClickingOnMultiSelectionList()
4646
await context.Input.PerformActionsAsync([
4747
new SourceActions.Pointers
4848
{
49-
new SourceActions.Pointer.Down(1),
50-
new SourceActions.Pointer.Up(1),
49+
new Pointer.Down(1),
50+
new Pointer.Up(1),
5151
}
5252
]);
5353
}

dotnet/test/common/BiDi/Input/DefaultMouseTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ await context.Input.PerformActionsAsync([
1616
{
1717
Actions =
1818
{
19-
new SourceActions.Key.Down("A")
19+
new Key.Down("A")
2020
}
2121
}
2222
]);
2323

2424
await context.Input.PerformActionsAsync([new SourceActions.Keys
2525
{
26-
new SourceActions.Key.Down("A"),
27-
new SourceActions.Key.Down("B"),
28-
new SourceActions.Key.Pause()
26+
new Key.Down("A"),
27+
new Key.Down("B"),
28+
new Key.Pause()
2929
}]);
3030

3131
await context.Input.PerformActionsAsync([new SourceActions.Pointers
3232
{
33-
new SourceActions.Pointer.Down(0),
34-
new SourceActions.Pointer.Up(0),
33+
new Pointer.Down(0),
34+
new Pointer.Up(0),
3535
}]);
3636
}
3737
}

0 commit comments

Comments
 (0)