diff --git a/AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs b/AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs index 00717090..d637fbbd 100644 --- a/AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs +++ b/AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs @@ -20,6 +20,9 @@ namespace AdvancedSharpAdbClient.Tests { public partial class AdbClientTests { + /// + /// Tests the method. + /// [Fact] public async void GetAdbVersionAsyncTest() { @@ -45,6 +48,9 @@ await RunTestAsync( Assert.Equal(32, version); } + /// + /// Tests the method. + /// [Fact] public async void KillAdbAsyncTest() { @@ -60,6 +66,9 @@ await RunTestAsync( () => TestClient.KillAdbAsync()); } + /// + /// Tests the method. + /// [Fact] public async void GetDevicesAsyncTest() { @@ -93,31 +102,45 @@ await RunTestAsync( Assert.Equal("donatello", device.Name); } + /// + /// Tests the method. + /// [Fact] public async void CreateForwardAsyncTest() => await RunCreateForwardAsyncTest( (device) => TestClient.CreateForwardAsync(device, "tcp:1", "tcp:2", true), "tcp:1;tcp:2"); - + /// + /// Tests the method. + /// [Fact] public async void CreateReverseAsyncTest() => await RunCreateReverseAsyncTest( (device) => TestClient.CreateReverseForwardAsync(device, "tcp:1", "tcp:2", true), "tcp:1;tcp:2"); + /// + /// Tests the method. + /// [Fact] public async void CreateTcpForwardAsyncTest() => await RunCreateForwardAsyncTest( (device) => TestClient.CreateForwardAsync(device, 3, 4), "tcp:3;tcp:4"); + /// + /// Tests the method. + /// [Fact] public async void CreateSocketForwardAsyncTest() => await RunCreateForwardAsyncTest( (device) => TestClient.CreateForwardAsync(device, 5, "/socket/1"), "tcp:5;local:/socket/1"); + /// + /// Tests the method. + /// [Fact] public async void CreateDuplicateForwardAsyncTest() { @@ -139,6 +162,9 @@ public async void CreateDuplicateForwardAsyncTest() () => TestClient.CreateForwardAsync(Device, "tcp:1", "tcp:2", false))); } + /// + /// Tests the method. + /// [Fact] public async void RemoveForwardAsyncTest() { @@ -154,6 +180,9 @@ await RunTestAsync( () => TestClient.RemoveForwardAsync(Device, 1)); } + /// + /// Tests the method. + /// [Fact] public async void RemoveReverseForwardAsyncTest() { @@ -176,6 +205,9 @@ await RunTestAsync( () => TestClient.RemoveReverseForwardAsync(Device, "localabstract:test")); } + /// + /// Tests the method. + /// [Fact] public async void RemoveAllForwardsAsyncTest() { @@ -191,6 +223,9 @@ await RunTestAsync( () => TestClient.RemoveAllForwardsAsync(Device)); } + /// + /// Tests the method. + /// [Fact] public async void RemoveAllReversesAsyncTest() { @@ -213,6 +248,9 @@ await RunTestAsync( () => TestClient.RemoveAllReverseForwardsAsync(Device)); } + /// + /// Tests the method. + /// [Fact] public async void ListForwardAsyncTest() { @@ -241,6 +279,9 @@ await RunTestAsync( Assert.Equal("tcp:2", forwards[0].Remote); } + /// + /// Tests the method. + /// [Fact] public async void ListReverseForwardAsyncTest() { @@ -275,6 +316,9 @@ await RunTestAsync( Assert.Equal("tcp:100", forwards[0].Remote); } + /// + /// Tests the method. + /// [Fact] public async void ExecuteRemoteCommandAsyncTest() { @@ -313,6 +357,9 @@ await RunTestAsync( Assert.Equal("Hello, World\r\n", receiver.ToString(), ignoreLineEndingDifferences: true); } + /// + /// Tests the method. + /// [Fact] public async void ExecuteRemoteCommandAsyncUnresponsiveTest() { @@ -347,6 +394,9 @@ public async void ExecuteRemoteCommandAsyncUnresponsiveTest() () => TestClient.ExecuteRemoteCommandAsync("echo Hello, World", device, receiver, CancellationToken.None))); } + /// + /// Tests the method. + /// [Fact] public void GetFrameBufferAsyncTest() { @@ -415,6 +465,9 @@ public void GetFrameBufferAsyncTest() framebuffer.Dispose(); } + /// + /// Tests the method. + /// [Fact] public async void RunLogServiceAsyncTest() { @@ -455,6 +508,9 @@ await RunTestAsync( Assert.Equal(3, logs.Count); } + /// + /// Tests the method. + /// [Fact] public async void RebootAsyncTest() { @@ -471,6 +527,9 @@ await RunTestAsync( () => TestClient.RebootAsync(Device)); } + /// + /// Tests the method. + /// [Fact] public async void PairAsyncIPAddressTest() => await RunPairAsyncTest( @@ -478,6 +537,9 @@ await RunPairAsyncTest( "127.0.0.1:5555", "114514"); + /// + /// Tests the method. + /// [Fact] public async void PairAsyncDnsEndpointTest() => await RunPairAsyncTest( @@ -485,6 +547,9 @@ await RunPairAsyncTest( "localhost:1234", "114514"); + /// + /// Tests the method. + /// [Fact] public async void PairAsyncIPEndpointTest() => await RunPairAsyncTest( @@ -492,6 +557,9 @@ await RunPairAsyncTest( "127.0.0.1:4321", "114514"); + /// + /// Tests the method. + /// [Fact] public async void PairAsyncHostEndpointTest() => await RunPairAsyncTest( @@ -499,62 +567,101 @@ await RunPairAsyncTest( "localhost:9926", "114514"); + /// + /// Tests the method. + /// [Fact] public async void PairAsyncIPAddressNullTest() => _ = await Assert.ThrowsAsync(() => TestClient.PairAsync((IPAddress)null, "114514")); + /// + /// Tests the method. + /// [Fact] public async void PairAsyncDnsEndpointNullTest() => _ = await Assert.ThrowsAsync(() => TestClient.PairAsync(null, "114514")); + /// + /// Tests the method. + /// [Fact] public async void PairAsyncIPEndpointNullTest() => _ = await Assert.ThrowsAsync(() => TestClient.PairAsync((IPEndPoint)null, "114514")); + /// + /// Tests the method. + /// [Fact] public async void PairAsyncHostEndpointNullTest() => _ = await Assert.ThrowsAsync(() => TestClient.PairAsync((string)null, "114514")); + /// + /// Tests the method. + /// [Fact] public async void ConnectAsyncIPAddressTest() => await RunConnectAsyncTest( () => TestClient.ConnectAsync(IPAddress.Loopback), "127.0.0.1:5555"); + /// + /// Tests the method. + /// [Fact] public async void ConnectAsyncDnsEndpointTest() => await RunConnectAsyncTest( () => TestClient.ConnectAsync(new DnsEndPoint("localhost", 1234)), "localhost:1234"); + /// + /// Tests the method. + /// [Fact] public async void ConnectAsyncIPEndpointTest() => await RunConnectAsyncTest( () => TestClient.ConnectAsync(new IPEndPoint(IPAddress.Loopback, 4321)), "127.0.0.1:4321"); + /// + /// Tests the method. + /// [Fact] public async void ConnectAsyncHostEndpointTest() => await RunConnectAsyncTest( () => TestClient.ConnectAsync("localhost:9926"), "localhost:9926"); + /// + /// Tests the method. + /// [Fact] public async void ConnectAsyncIPAddressNullTest() => _ = await Assert.ThrowsAsync(() => TestClient.ConnectAsync((IPAddress)null)); + /// + /// Tests the method. + /// [Fact] public async void ConnectAsyncDnsEndpointNullTest() => _ = await Assert.ThrowsAsync(() => TestClient.ConnectAsync(null)); + /// + /// Tests the method. + /// [Fact] public async void ConnectAsyncIPEndpointNullTest() => _ = await Assert.ThrowsAsync(() => TestClient.ConnectAsync((IPEndPoint)null)); + /// + /// Tests the method. + /// [Fact] public async void ConnectAsyncHostEndpointNullTest() => _ = await Assert.ThrowsAsync(() => TestClient.ConnectAsync((string)null)); + /// + /// Tests the method. + /// [Fact] public async void DisconnectAsyncTest() { @@ -568,6 +675,9 @@ await RunTestAsync( () => TestClient.DisconnectAsync(new DnsEndPoint("localhost", 5555))); } + /// + /// Tests the method. + /// [Fact] public async void RootAsyncTest() { @@ -599,6 +709,9 @@ public async void RootAsyncTest() () => TestClient.RootAsync(device))); } + /// + /// Tests the method. + /// [Fact] public async void UnrootAsyncTest() { @@ -630,6 +743,9 @@ public async void UnrootAsyncTest() () => TestClient.UnrootAsync(device))); } + /// + /// Tests the method. + /// [Fact] public async void InstallAsyncTest() { @@ -687,6 +803,9 @@ await RunTestAsync( } } + /// + /// Tests the method. + /// [Fact] public async void InstallCreateAsyncTest() { @@ -721,6 +840,9 @@ await RunTestAsync( Assert.Equal("936013062", session); } + /// + /// Tests the method. + /// [Fact] public async void InstallWriteAsyncTest() { @@ -778,6 +900,9 @@ await RunTestAsync( } } + /// + /// Tests the method. + /// [Fact] public async void InstallCommitAsyncTest() { @@ -808,6 +933,9 @@ await RunTestAsync( () => TestClient.InstallCommitAsync(device, "936013062")); } + /// + /// Tests the method. + /// [Fact] public async void GetFeatureSetAsyncTest() { @@ -843,6 +971,9 @@ await RunTestAsync( Assert.Equal("stat_v2", features.Last()); } + /// + /// Tests the method. + /// [Fact] public async void DumpScreenStringAsyncTest() { @@ -878,6 +1009,9 @@ await RunTestAsync( Assert.Equal(dump.Replace("Events injected: 1\r\n", "").Replace("UI hierchary dumped to: /dev/tty", "").Trim(), xml); } + /// + /// Tests the method. + /// [Fact] public async void DumpScreenAsyncTest() { @@ -916,6 +1050,9 @@ await RunTestAsync( Assert.Equal(doc, xml); } + /// + /// Tests the method. + /// [Fact] public async void ClickAsyncTest() { @@ -992,6 +1129,9 @@ at android.os.Binder.execTransactInternal(Binder.java:1165) at android.os.Binder.execTransact(Binder.java:1134)", exception.JavaStackTrace); } + /// + /// Tests the method. + /// [Fact] public async void ClickCordsAsyncTest() { @@ -1006,32 +1146,11 @@ public async void ClickCordsAsyncTest() "host:transport:009d1cd696d5194a", "shell:input tap 100 100" }; - - byte[] streamData = Encoding.UTF8.GetBytes(@"java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission - at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) - at android.os.Parcel.createException(Parcel.java:2357) - at android.os.Parcel.readException(Parcel.java:2340) - at android.os.Parcel.readException(Parcel.java:2282) - at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:946) - at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907) - at com.android.commands.input.Input.injectMotionEvent(Input.java:397) - at com.android.commands.input.Input.access$200(Input.java:41) - at com.android.commands.input.Input$InputTap.sendTap(Input.java:223) - at com.android.commands.input.Input$InputTap.run(Input.java:217) - at com.android.commands.input.Input.onRun(Input.java:107) - at com.android.internal.os.BaseCommand.run(BaseCommand.java:60) - at com.android.commands.input.Input.main(Input.java:71) - at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) - at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:438) -Caused by: android.os.RemoteException: Remote stack trace: - at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:677) - at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:651) - at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:430) - at android.os.Binder.execTransactInternal(Binder.java:1165) - at android.os.Binder.execTransact(Binder.java:1134)"); + + byte[] streamData = Encoding.UTF8.GetBytes(@"Error: Injecting to another application requires INJECT_EVENTS permission"); using MemoryStream shellStream = new(streamData); - JavaException exception = await Assert.ThrowsAsync(() => + _ = await Assert.ThrowsAsync(() => RunTestAsync( new AdbResponse[] { @@ -1042,32 +1161,11 @@ at android.os.Binder.execTransactInternal(Binder.java:1165) requests, shellStream, () => TestClient.ClickAsync(device, new Cords(100, 100)))); - - Assert.Equal("SecurityException", exception.JavaName); - Assert.Equal("Injecting to another application requires INJECT_EVENTS permission", exception.Message); - Assert.Equal(@" at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) - at android.os.Parcel.createException(Parcel.java:2357) - at android.os.Parcel.readException(Parcel.java:2340) - at android.os.Parcel.readException(Parcel.java:2282) - at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:946) - at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907) - at com.android.commands.input.Input.injectMotionEvent(Input.java:397) - at com.android.commands.input.Input.access$200(Input.java:41) - at com.android.commands.input.Input$InputTap.sendTap(Input.java:223) - at com.android.commands.input.Input$InputTap.run(Input.java:217) - at com.android.commands.input.Input.onRun(Input.java:107) - at com.android.internal.os.BaseCommand.run(BaseCommand.java:60) - at com.android.commands.input.Input.main(Input.java:71) - at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) - at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:438) -Caused by: android.os.RemoteException: Remote stack trace: - at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:677) - at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:651) - at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:430) - at android.os.Binder.execTransactInternal(Binder.java:1165) - at android.os.Binder.execTransact(Binder.java:1134)", exception.JavaStackTrace); } + /// + /// Tests the method. + /// [Fact] public async void FindElementAsyncTest() { @@ -1106,6 +1204,9 @@ await RunTestAsync( }); } + /// + /// Tests the method. + /// [Fact] public async void FindElementsAsyncTest() { diff --git a/AdvancedSharpAdbClient.Tests/AdbClientTests.cs b/AdvancedSharpAdbClient.Tests/AdbClientTests.cs index 10f94fd0..b11ddbb5 100644 --- a/AdvancedSharpAdbClient.Tests/AdbClientTests.cs +++ b/AdvancedSharpAdbClient.Tests/AdbClientTests.cs @@ -1269,31 +1269,10 @@ public void ClickCordsTest() "shell:input tap 100 100" }; - byte[] streamData = Encoding.UTF8.GetBytes(@"java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission - at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) - at android.os.Parcel.createException(Parcel.java:2357) - at android.os.Parcel.readException(Parcel.java:2340) - at android.os.Parcel.readException(Parcel.java:2282) - at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:946) - at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907) - at com.android.commands.input.Input.injectMotionEvent(Input.java:397) - at com.android.commands.input.Input.access$200(Input.java:41) - at com.android.commands.input.Input$InputTap.sendTap(Input.java:223) - at com.android.commands.input.Input$InputTap.run(Input.java:217) - at com.android.commands.input.Input.onRun(Input.java:107) - at com.android.internal.os.BaseCommand.run(BaseCommand.java:60) - at com.android.commands.input.Input.main(Input.java:71) - at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) - at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:438) -Caused by: android.os.RemoteException: Remote stack trace: - at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:677) - at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:651) - at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:430) - at android.os.Binder.execTransactInternal(Binder.java:1165) - at android.os.Binder.execTransact(Binder.java:1134)"); + byte[] streamData = Encoding.UTF8.GetBytes(@"Error: Injecting to another application requires INJECT_EVENTS permission"); using MemoryStream shellStream = new(streamData); - JavaException exception = Assert.Throws(() => + _ = Assert.Throws(() => RunTest( new AdbResponse[] { @@ -1304,30 +1283,6 @@ at android.os.Binder.execTransactInternal(Binder.java:1165) requests, shellStream, () => TestClient.Click(device, new Cords(100, 100)))); - - Assert.Equal("SecurityException", exception.JavaName); - Assert.Equal("Injecting to another application requires INJECT_EVENTS permission", exception.Message); - Assert.Equal(@" at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) - at android.os.Parcel.createException(Parcel.java:2357) - at android.os.Parcel.readException(Parcel.java:2340) - at android.os.Parcel.readException(Parcel.java:2282) - at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:946) - at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907) - at com.android.commands.input.Input.injectMotionEvent(Input.java:397) - at com.android.commands.input.Input.access$200(Input.java:41) - at com.android.commands.input.Input$InputTap.sendTap(Input.java:223) - at com.android.commands.input.Input$InputTap.run(Input.java:217) - at com.android.commands.input.Input.onRun(Input.java:107) - at com.android.internal.os.BaseCommand.run(BaseCommand.java:60) - at com.android.commands.input.Input.main(Input.java:71) - at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) - at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:438) -Caused by: android.os.RemoteException: Remote stack trace: - at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:677) - at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:651) - at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:430) - at android.os.Binder.execTransactInternal(Binder.java:1165) - at android.os.Binder.execTransact(Binder.java:1134)", exception.JavaStackTrace); } /// diff --git a/AdvancedSharpAdbClient/Models/Framebuffer.cs b/AdvancedSharpAdbClient/Models/Framebuffer.cs index 14c3759b..22231062 100644 --- a/AdvancedSharpAdbClient/Models/Framebuffer.cs +++ b/AdvancedSharpAdbClient/Models/Framebuffer.cs @@ -31,12 +31,16 @@ public Framebuffer(DeviceData device, EndPoint endPoint) EndPoint = endPoint ?? throw new ArgumentNullException(nameof(endPoint)); // Initialize the headerData buffer +#if WINDOWS_UWP + headerData = new byte[56]; +#else #if !NETFRAMEWORK || NET451_OR_GREATER int size = Marshal.SizeOf(); #else int size = Marshal.SizeOf(default(FramebufferHeader)); #endif headerData = new byte[size]; +#endif } ///