This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exit image code if native control is destroyed (#9034)
* Exit image code if native control is destroyed * - add uitest * - ui test * - remove invalidate override * - remove extra invalidate
- Loading branch information
Showing
12 changed files
with
132 additions
and
49 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue8262.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,104 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Text; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
using System.Linq; | ||
|
||
|
||
#if UITEST | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
using Xamarin.Forms.Core.UITests; | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 8262, "[Android] ImageRenderer still being accessed after control destroyed", | ||
PlatformAffected.Android)] | ||
#if UITEST | ||
[NUnit.Framework.Category(UITestCategories.LifeCycle)] | ||
[NUnit.Framework.Category(UITestCategories.CollectionView)] | ||
#endif | ||
public class Issue8262 : TestContentPage | ||
{ | ||
public View WithBounds(View v, double x, double y, double w, double h) | ||
{ | ||
AbsoluteLayout.SetLayoutBounds(v, new Rectangle(x, y, w, h)); | ||
return v; | ||
} | ||
|
||
protected override void Init() | ||
{ | ||
IEnumerable<View> Select((string groupHeader, IEnumerable<int> items) t) | ||
{ | ||
yield return new AbsoluteLayout | ||
{ | ||
Children = { | ||
WithBounds(new Label { | ||
Text = t.groupHeader, HorizontalTextAlignment = TextAlignment.Center, | ||
TextColor = Color.FromUint(0xff5a5a5a), FontSize = 10 | ||
}, 0, 21.1, 310, AbsoluteLayout.AutoSize) }, | ||
HorizontalOptions = LayoutOptions.FillAndExpand, | ||
VerticalOptions = LayoutOptions.Start, | ||
HeightRequest = 46 | ||
}; | ||
foreach (var item in t.items) | ||
{ | ||
yield return new AbsoluteLayout | ||
{ | ||
Children = { | ||
|
||
WithBounds(new Image { Source = ImageSource.FromResource("Xamarin.Forms.Controls.GalleryPages.crimson.jpg", System.Reflection.Assembly.GetCallingAssembly()) }, 23.6, 14.5, 14.9, 20.7), | ||
|
||
WithBounds(new Label { Text = item.ToString(), TextColor = Color.FromUint(0xff5a5a5a), FontSize = 10 }, 58, 18.2, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize) | ||
}, | ||
HorizontalOptions = LayoutOptions.FillAndExpand, | ||
VerticalOptions = LayoutOptions.Start, | ||
HeightRequest = 49.7 | ||
}; | ||
} | ||
} | ||
|
||
Content = new AbsoluteLayout | ||
{ | ||
Children = { | ||
new CollectionView { | ||
ItemsSource = | ||
new (string, Func<int, bool>)[] { | ||
("odd", i => i % 2 == 1), | ||
("even", i => i % 2 == 0), | ||
("triple", i => i % 3 == 0), | ||
("fives", i => i % 5 == 0) } | ||
.Select(t => (t.Item1, Enumerable.Range(1, 100).Where(t.Item2))) | ||
.SelectMany(Select), | ||
ItemTemplate = new DataTemplate(() => { | ||
var template = new ContentView(); | ||
template.SetBinding(ContentView.ContentProperty, "."); | ||
return template; | ||
}), | ||
ItemsLayout = LinearItemsLayout.Vertical, | ||
ItemSizingStrategy = ItemSizingStrategy.MeasureFirstItem, | ||
AutomationId = "ScrollMe" | ||
} | ||
} | ||
}; | ||
} | ||
|
||
#if UITEST | ||
[Test] | ||
public void ScrollingQuicklyOnCollectionViewDoesntCrashOnDestroyedImage() | ||
{ | ||
RunningApp.WaitForElement("ScrollMe"); | ||
RunningApp.ScrollDown("ScrollMe", ScrollStrategy.Gesture, swipeSpeed: 20000); | ||
RunningApp.ScrollUp("ScrollMe", ScrollStrategy.Gesture, swipeSpeed: 20000); | ||
RunningApp.ScrollDown("ScrollMe", ScrollStrategy.Gesture, swipeSpeed: 20000); | ||
RunningApp.ScrollUp("ScrollMe", ScrollStrategy.Gesture, swipeSpeed: 20000); | ||
RunningApp.ScrollDown("ScrollMe", ScrollStrategy.Gesture, swipeSpeed: 20000); | ||
RunningApp.WaitForElement("ScrollMe"); | ||
} | ||
#endif | ||
} | ||
} |
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
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