-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dotnet] [bidi] Support getting of client windows in browser module (#…
- Loading branch information
1 parent
0721800
commit e19d069
Showing
14 changed files
with
228 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
dotnet/src/webdriver/BiDi/Communication/Json/Converters/BrowserClientWindowConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// <copyright file="BrowserClientWindowConverter.cs" company="Selenium 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 | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// </copyright> | ||
|
||
using OpenQA.Selenium.BiDi.Modules.Browser; | ||
using System; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
#nullable enable | ||
|
||
namespace OpenQA.Selenium.BiDi.Communication.Json.Converters; | ||
|
||
internal class BrowserClientWindowConverter : JsonConverter<ClientWindow> | ||
{ | ||
public override ClientWindow? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
var id = reader.GetString(); | ||
|
||
return new ClientWindow(id!); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, ClientWindow value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.Id); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...ebdriver/BiDi/Communication/Json/Converters/Enumerable/GetClientWindowsResultConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// <copyright file="GetClientWindowsResultConverter.cs" company="Selenium 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 | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// </copyright> | ||
|
||
using OpenQA.Selenium.BiDi.Modules.Browser; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
#nullable enable | ||
|
||
namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; | ||
|
||
internal class GetClientWindowsResultConverter : JsonConverter<GetClientWindowsResult> | ||
{ | ||
public override GetClientWindowsResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
using var doc = JsonDocument.ParseValue(ref reader); | ||
var clientWindows = doc.RootElement.GetProperty("clientWindows").Deserialize<IReadOnlyList<ClientWindowInfo>>(options); | ||
|
||
return new GetClientWindowsResult(clientWindows!); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, GetClientWindowsResult value, JsonSerializerOptions options) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// <copyright file="ClientWindow.cs" company="Selenium 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 | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// </copyright> | ||
|
||
#nullable enable | ||
|
||
namespace OpenQA.Selenium.BiDi.Modules.Browser; | ||
|
||
public record ClientWindow | ||
{ | ||
internal ClientWindow(string id) | ||
{ | ||
Id = id; | ||
} | ||
|
||
internal string Id { get; } | ||
} |
34 changes: 34 additions & 0 deletions
34
dotnet/src/webdriver/BiDi/Modules/Browser/ClientWindowInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// <copyright file="ClientWindowInfo.cs" company="Selenium 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 | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// </copyright> | ||
|
||
#nullable enable | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace OpenQA.Selenium.BiDi.Modules.Browser; | ||
|
||
public record ClientWindowInfo([property: JsonPropertyName("active")] bool IsActive, ClientWindow ClientWindow, ClientWindowState State, int Height, int Width, int X, int Y); | ||
|
||
public enum ClientWindowState | ||
{ | ||
Fullscreen, | ||
Maximized, | ||
Minimized, | ||
Normal | ||
} |
49 changes: 49 additions & 0 deletions
49
dotnet/src/webdriver/BiDi/Modules/Browser/GetClientWindowsCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// <copyright file="GetClientWindowsCommand.cs" company="Selenium 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 | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// </copyright> | ||
|
||
using OpenQA.Selenium.BiDi.Communication; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
#nullable enable | ||
|
||
namespace OpenQA.Selenium.BiDi.Modules.Browser; | ||
|
||
internal class GetClientWindowsCommand() | ||
: Command<CommandParameters>(CommandParameters.Empty, "browser.getClientWindows"); | ||
|
||
public record GetClientWindowsOptions : CommandOptions; | ||
|
||
public record GetClientWindowsResult : IReadOnlyList<ClientWindowInfo> | ||
{ | ||
private readonly IReadOnlyList<ClientWindowInfo> _clientWindows; | ||
|
||
internal GetClientWindowsResult(IReadOnlyList<ClientWindowInfo> clientWindows) | ||
{ | ||
_clientWindows = clientWindows; | ||
} | ||
|
||
public ClientWindowInfo this[int index] => _clientWindows[index]; | ||
|
||
public int Count => _clientWindows.Count; | ||
|
||
public IEnumerator<ClientWindowInfo> GetEnumerator() => _clientWindows.GetEnumerator(); | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => (_clientWindows as IEnumerable).GetEnumerator(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters