Skip to content

Commit 6b69a59

Browse files
committed
Add platform check on test
1 parent 894a91f commit 6b69a59

File tree

8 files changed

+30
-10
lines changed

8 files changed

+30
-10
lines changed

AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ await File.ReadAllBytesAsync("Assets/Framebuffer.bin")
368368
Assert.Equal(0u, header.ColorSpace);
369369

370370
#if WINDOWS
371+
if (!OperatingSystem.IsWindows()) { return; }
372+
371373
using Bitmap image = framebuffer.ToImage();
372374
Assert.NotNull(image);
373375
Assert.Equal(PixelFormat.Format32bppArgb, image.PixelFormat);
@@ -900,14 +902,6 @@ public async Task InstallWriteAsyncTest()
900902

901903
byte[] response = AdbClient.Encoding.GetBytes($"Success: streamed {stream.Length} bytes\n");
902904

903-
double temp = 0;
904-
Progress<double> progress = new();
905-
progress.ProgressChanged += (sender, args) =>
906-
{
907-
Assert.True(temp <= args, $"{nameof(args)}: {args} is less than {temp}.");
908-
temp = args;
909-
};
910-
911905
await RunTestAsync(
912906
OkResponses(2),
913907
NoResponseMessages,
@@ -916,7 +910,7 @@ await RunTestAsync(
916910
NoSyncResponses,
917911
[response],
918912
applicationDataChunks,
919-
() => TestClient.InstallWriteAsync(Device, stream, "base", "936013062", progress));
913+
() => TestClient.InstallWriteAsync(Device, stream, "base", "936013062", new InstallProgress()));
920914
}
921915
}
922916

@@ -950,6 +944,8 @@ await RunTestAsync(
950944
[Fact]
951945
public async Task InstallWinRTAsyncTest()
952946
{
947+
if (!OperatingSystem.IsWindowsVersionAtLeast(10)) { return; }
948+
953949
// The app data is sent in chunks of 32 kb
954950
List<byte[]> applicationDataChunks = [];
955951

@@ -999,6 +995,8 @@ await RunTestAsync(
999995
[Fact]
1000996
public async Task InstallMultipleWinRTAsyncTest()
1001997
{
998+
if (!OperatingSystem.IsWindowsVersionAtLeast(10)) { return; }
999+
10021000
// The app data is sent in chunks of 32 kb
10031001
List<byte[]> applicationDataChunks = [];
10041002

@@ -1059,6 +1057,8 @@ await RunTestAsync(
10591057
[Fact]
10601058
public async Task InstallMultipleWinRTWithBaseAsyncTest()
10611059
{
1060+
if (!OperatingSystem.IsWindowsVersionAtLeast(10)) { return; }
1061+
10621062
// The app data is sent in chunks of 32 kb
10631063
List<byte[]> applicationDataChunks = [];
10641064

@@ -1136,6 +1136,8 @@ await RunTestAsync(
11361136
[Fact]
11371137
public async Task InstallWriteWinRTAsyncTest()
11381138
{
1139+
if (!OperatingSystem.IsWindowsVersionAtLeast(10)) { return; }
1140+
11391141
// The app data is sent in chunks of 32 kb
11401142
List<byte[]> applicationDataChunks = [];
11411143

AdvancedSharpAdbClient.Tests/AdbClientTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ public void GetFrameBufferTest()
490490
Assert.Equal(0u, header.ColorSpace);
491491

492492
#if WINDOWS
493+
if (!OperatingSystem.IsWindows()) { return; }
494+
493495
using Bitmap image = framebuffer.ToImage();
494496
Assert.NotNull(image);
495497
Assert.Equal(PixelFormat.Format32bppArgb, image.PixelFormat);

AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<LangVersion>latest</LangVersion>
5-
<NoWarn>CS1591</NoWarn>
5+
<NoWarn>$(NoWarn);CS1591</NoWarn>
66
</PropertyGroup>
77

88
<Choose>

AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.Async.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public async Task DumpScreenAsyncTest()
112112
[Fact]
113113
public async Task DumpScreenWinRTAsyncTest()
114114
{
115+
if (!OperatingSystem.IsWindowsVersionAtLeast(10)) { return; }
116+
115117
DummyAdbClient client = new();
116118
client.Commands["shell:uiautomator dump /dev/tty"] = await File.ReadAllTextAsync(@"Assets/DumpScreen.txt");
117119

AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ public void DumpScreenTest()
198198
[Fact]
199199
public void DumpScreenWinRTTest()
200200
{
201+
if (!OperatingSystem.IsWindowsVersionAtLeast(10)) { return; }
202+
201203
DummyAdbClient client = new();
202204
client.Commands["shell:uiautomator dump /dev/tty"] = File.ReadAllText(@"Assets/DumpScreen.txt");
203205

AdvancedSharpAdbClient.Tests/Models/FramebufferHeaderTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public void ReadFramebufferV2Test()
7575
[Fact]
7676
public void ToImageTest()
7777
{
78+
if (!OperatingSystem.IsWindows()) { return; }
79+
7880
byte[] data = File.ReadAllBytes("Assets/FramebufferHeader.bin");
7981
FramebufferHeader header = FramebufferHeader.Read(data);
8082
byte[] framebuffer = File.ReadAllBytes("Assets/Framebuffer.bin");
@@ -95,6 +97,8 @@ public void ToImageTest()
9597
[Fact]
9698
public void ToImageEmptyTest()
9799
{
100+
if (!OperatingSystem.IsWindows()) { return; }
101+
98102
byte[] data = File.ReadAllBytes("Assets/FramebufferHeader.Empty.bin");
99103
FramebufferHeader header = FramebufferHeader.Read(data);
100104

AdvancedSharpAdbClient.Tests/Models/FramebufferTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public void RefreshTest()
7070
Assert.Equal(0u, header.ColorSpace);
7171

7272
#if WINDOWS
73+
if (!OperatingSystem.IsWindows()) { return; }
74+
7375
using Bitmap image = (Bitmap)framebuffer;
7476
Assert.NotNull(image);
7577
Assert.Equal(PixelFormat.Format32bppArgb, image.PixelFormat);
@@ -131,6 +133,8 @@ public async Task RefreshAsyncTest()
131133
Assert.Equal(0u, header.ColorSpace);
132134

133135
#if WINDOWS
136+
if (!OperatingSystem.IsWindows()) { return; }
137+
134138
using Bitmap image = (Bitmap)framebuffer;
135139
Assert.NotNull(image);
136140
Assert.Equal(PixelFormat.Format32bppArgb, image.PixelFormat);

AdvancedSharpAdbClient.Tests/SyncServiceTests.Async.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ await RunTestAsync(
271271
[Fact]
272272
public async Task PullWinRTAsyncTest()
273273
{
274+
if (!OperatingSystem.IsWindowsVersionAtLeast(10)) { return; }
275+
274276
using InMemoryRandomAccessStream stream = new();
275277
byte[] content = await File.ReadAllBytesAsync("Assets/Fstab.bin");
276278
byte[] contentLength = BitConverter.GetBytes(content.Length);
@@ -309,6 +311,8 @@ await RunTestAsync(
309311
[Fact]
310312
public async Task PushWinRTAsyncTest()
311313
{
314+
if (!OperatingSystem.IsWindowsVersionAtLeast(10)) { return; }
315+
312316
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\Fstab.bin"));
313317
using IRandomAccessStreamWithContentType stream = await storageFile.OpenReadAsync();
314318
byte[] content = await File.ReadAllBytesAsync("Assets/Fstab.bin");

0 commit comments

Comments
 (0)