13
13
#elif IOS || MACCATALYST
14
14
using UIKit ;
15
15
using PlatformImageType = UIKit . UIImage ;
16
+ #elif WINDOWS
17
+ using PlatformImageType = Microsoft . UI . Xaml . Controls . Image ;
16
18
#endif
17
19
18
20
namespace Microsoft . Maui . DeviceTests
@@ -32,11 +34,14 @@ public abstract partial class ImageHandlerTests<TImageHandler, TStub> : CoreHand
32
34
#elif IOS || MACCATALYST
33
35
const string ImageEventAppResourceMemberName = "Image" ;
34
36
const string ImageEventCustomMemberName = "Image" ;
37
+ #elif WINDOWS
38
+ const string ImageEventAppResourceMemberName = "Source" ;
39
+ const string ImageEventCustomMemberName = "Source" ;
35
40
#endif
36
41
37
42
[ Theory (
38
- #if IOS || MACCATALYST
39
- Skip = "Test failing on iOS"
43
+ #if IOS || MACCATALYST || WINDOWS
44
+ Skip = "Test failing on iOS and WINDOWS "
40
45
#endif
41
46
) ]
42
47
[ InlineData ( "#FF0000" ) ]
@@ -55,28 +60,28 @@ await InvokeOnMainThreadAsync(async () =>
55
60
var handler = CreateHandler ( image ) ;
56
61
var platformView = GetPlatformImageView ( handler ) ;
57
62
58
- await platformView . AttachAndRun ( async ( ) =>
63
+ await AttachAndRun ( platformView , async ( ) =>
59
64
{
60
65
// the first one works
61
66
image . Source = new FileImageSourceStub ( firstPath ) ;
62
67
handler . UpdateValue ( nameof ( IImage . Source ) ) ;
63
68
await image . WaitUntilLoaded ( ) ;
64
69
65
- await platformView . AssertContainsColor ( Colors . Blue . ToPlatform ( ) , MauiContext ) ;
70
+ await platformView . AssertContainsColor ( Colors . Blue , MauiContext ) ;
66
71
67
72
// the second one does not
68
73
image . Source = new FileImageSourceStub ( secondPath ) ;
69
74
handler . UpdateValue ( nameof ( IImage . Source ) ) ;
70
75
await image . WaitUntilLoaded ( ) ;
71
76
72
- await platformView . AssertContainsColor ( expectedColor . ToPlatform ( ) , MauiContext ) ;
77
+ await platformView . AssertContainsColor ( expectedColor , MauiContext ) ;
73
78
} ) ;
74
79
} ) ;
75
80
}
76
81
77
82
[ Theory (
78
- #if _ANDROID__
79
- Skip = "Test failing on ANDROID"
83
+ #if ANDROID || WINDOWS
84
+ Skip = "Test failing on ANDROID and WINDOWS "
80
85
#endif
81
86
) ]
82
87
[ InlineData ( "red.png" , "#FF0000" ) ]
@@ -116,7 +121,9 @@ await InvokeOnMainThreadAsync(async () =>
116
121
#endif
117
122
) ]
118
123
[ InlineData ( "animated_heart.gif" , true ) ]
124
+ #if ! WINDOWS
119
125
[ InlineData ( "animated_heart.gif" , false ) ]
126
+ #endif
120
127
public async virtual Task AnimatedSourceInitializesCorrectly ( string filename , bool isAnimating )
121
128
{
122
129
var image = new TStub
@@ -131,7 +138,7 @@ await InvokeOnMainThreadAsync(async () =>
131
138
132
139
await image . WaitUntilLoaded ( ) ;
133
140
134
- await GetPlatformImageView ( handler ) . AttachAndRun ( ( ) =>
141
+ await AttachAndRun ( GetPlatformImageView ( handler ) , ( ) =>
135
142
{
136
143
Assert . Equal ( isAnimating , GetNativeIsAnimationPlaying ( handler ) ) ;
137
144
} ) ;
@@ -196,7 +203,11 @@ await InvokeOnMainThreadAsync(async () =>
196
203
Assert . NotNull ( exception ) ;
197
204
}
198
205
199
- [ Fact ]
206
+ [ Fact (
207
+ #if WINDOWS
208
+ Skip = "Hanging on Windows."
209
+ #endif
210
+ ) ]
200
211
public async Task ImageLoadSequenceIsCorrect ( )
201
212
{
202
213
await ImageLoadSequenceIsCorrectImplementation ( ) ;
@@ -259,12 +270,15 @@ public async Task ImageLoadSequenceIsCorrect()
259
270
} ) ;
260
271
}
261
272
262
- [ Fact ]
273
+ [ Fact (
274
+ #if WINDOWS
275
+ Skip = "Hanging on Windows."
276
+ #endif
277
+ ) ]
263
278
public async Task InterruptingLoadCancelsAndStartsOver ( )
264
279
{
265
280
await InterruptingLoadCancelsAndStartsOverImplementation ( ) ;
266
281
}
267
-
268
282
async Task < List < ( string Member , object Value ) > > InterruptingLoadCancelsAndStartsOverImplementation ( )
269
283
{
270
284
var image = new TStub
@@ -325,7 +339,11 @@ await InvokeOnMainThreadAsync(async () =>
325
339
return events ;
326
340
}
327
341
328
- [ Theory ]
342
+ [ Theory (
343
+ #if WINDOWS
344
+ Skip = "To be implemented on Windows."
345
+ #endif
346
+ ) ]
329
347
[ InlineData ( "#FF0000" ) ]
330
348
[ InlineData ( "#00FF00" ) ]
331
349
[ InlineData ( "#000000" ) ]
@@ -353,7 +371,11 @@ await InvokeOnMainThreadAsync(async () =>
353
371
} ) ;
354
372
}
355
373
356
- [ Fact ]
374
+ [ Fact (
375
+ #if WINDOWS
376
+ Skip = "To be implemented on Windows."
377
+ #endif
378
+ ) ]
357
379
public async Task InitializingSourceOnlyUpdatesImageOnce ( )
358
380
{
359
381
var image = new TStub
@@ -382,7 +404,11 @@ await InvokeOnMainThreadAsync(async () =>
382
404
} ) ;
383
405
}
384
406
385
- [ Fact ]
407
+ [ Fact (
408
+ #if WINDOWS
409
+ Skip = "To be implemented on Windows."
410
+ #endif
411
+ ) ]
386
412
public async Task UpdatingSourceOnlyUpdatesImageOnce ( )
387
413
{
388
414
var image = new TStub
@@ -420,7 +446,11 @@ await InvokeOnMainThreadAsync(async () =>
420
446
} ) ;
421
447
}
422
448
423
- [ Fact ]
449
+ [ Fact (
450
+ #if WINDOWS
451
+ Skip = "Hanging on Windows."
452
+ #endif
453
+ ) ]
424
454
public async Task ImageLoadSequenceIsCorrectWithChecks ( )
425
455
{
426
456
var events = await ImageLoadSequenceIsCorrectImplementation ( ) ;
@@ -437,7 +467,11 @@ public async Task ImageLoadSequenceIsCorrectWithChecks()
437
467
#endif
438
468
}
439
469
440
- [ Fact ]
470
+ [ Fact (
471
+ #if WINDOWS
472
+ Skip = "Hanging on Windows."
473
+ #endif
474
+ ) ]
441
475
public async Task InterruptingLoadCancelsAndStartsOverWithChecks ( )
442
476
{
443
477
var events = await InterruptingLoadCancelsAndStartsOverImplementation ( ) ;
@@ -475,7 +509,11 @@ static int GetDrawableId(string image) =>
475
509
MauiProgram . DefaultContext . Resources . GetDrawableId ( MauiProgram . DefaultContext . PackageName , image ) ;
476
510
#endif
477
511
478
- [ Fact ]
512
+ [ Fact (
513
+ #if WINDOWS
514
+ Skip = "To be implemented on Windows."
515
+ #endif
516
+ ) ]
479
517
public async Task UpdatingSourceToNullClearsImage ( )
480
518
{
481
519
var image = new TStub
@@ -503,7 +541,11 @@ await InvokeOnMainThreadAsync(async () =>
503
541
} ) ;
504
542
}
505
543
506
- [ Fact ]
544
+ [ Fact (
545
+ #if WINDOWS
546
+ Skip = "To be implemented on Windows."
547
+ #endif
548
+ ) ]
507
549
public async Task UpdatingSourceToNonexistentSourceClearsImage ( )
508
550
{
509
551
var image = new TStub
@@ -520,7 +562,7 @@ await InvokeOnMainThreadAsync(async () =>
520
562
521
563
image . Source = new FileImageSourceStub ( "fail.png" ) ;
522
564
handler . UpdateValue ( nameof ( IImage . Source ) ) ;
523
- await handler . PlatformView . AttachAndRun ( ( ) => { } ) ;
565
+ await AttachAndRun ( handler . PlatformView , ( ) => { } ) ;
524
566
525
567
await image . WaitUntilLoaded ( 5000 ) ;
526
568
await handler . PlatformView . AssertDoesNotContainColor ( Colors . Red , MauiContext ) ;
0 commit comments