diff options
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32691.cs')
-rw-r--r-- | Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32691.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32691.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32691.cs new file mode 100644 index 00000000..7277f606 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32691.cs @@ -0,0 +1,60 @@ +using System; +using Xamarin.Forms.CustomAttributes; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +#endif + +namespace Xamarin.Forms.Controls +{ + public interface ICacheService + { + void ClearImageCache (); + } + + [Preserve (AllMembers = true)] + [Issue (IssueTracker.Bugzilla, 32691, "Clearing an image by setting Image.Source to null, while Image.IsLoading is true, doesn't work.")] + public class Bugzilla32691 : TestContentPage + { + const string KSetImageSource = "SET IMAGE SOURCE"; + const string KClearImageSource = "CLEAR IMAGE SOURCE"; + + protected override void Init () + { + var label = new Label () { XAlign = TextAlignment.Center }; + var image = new Image (); + + image.PropertyChanged += (sender, e) => { + if (e.PropertyName == "IsLoading") + label.Text = image.IsLoading ? "Loading" : "Done"; + }; + + var btnSetOrClear = new Button () { Text = KSetImageSource, AutomationId = "btnLoad" }; + + btnSetOrClear.Clicked += delegate { + if (btnSetOrClear.Text == KSetImageSource) { + ClearImageCache (); + image.Source = + "http://www.public-domain-image.com/free-images/miscellaneous/big-high-border-fence.jpg"; + btnSetOrClear.Text = KClearImageSource; + } else { + image.Source = null; + btnSetOrClear.Text = KSetImageSource; + } + }; + + Content = new StackLayout { + Orientation = StackOrientation.Vertical, + Padding = new Thickness (10), + Children = { btnSetOrClear, image, label } + }; + } + + void ClearImageCache () + { + var cacheService = DependencyService.Get<ICacheService> (); + cacheService?.ClearImageCache (); + } + } +} |