diff options
author | E.Z. Hart <hartez@users.noreply.github.com> | 2016-04-25 13:57:44 -0600 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2016-04-25 15:57:44 -0400 |
commit | 843bc4727a40d6ca67127326facf2333f461da2d (patch) | |
tree | 5467ab3850df7f2368baa1290e983adba27f35d9 /Xamarin.Forms.Core.UnitTests | |
parent | 07df05ced2b43446c84d47f4b7a8325abcd0f767 (diff) | |
download | xamarin-forms-843bc4727a40d6ca67127326facf2333f461da2d.tar.gz xamarin-forms-843bc4727a40d6ca67127326facf2333f461da2d.tar.bz2 xamarin-forms-843bc4727a40d6ca67127326facf2333f461da2d.zip |
Make core Ticker abstract and public (#116)
* Make core Ticker abstract and public
Make the core Ticker abstract and public so it can be inherited by platform
implementations; remove now-unused parts of original Ticker; add CreateTicker
to IPlatformServices; remove unused CreateTimer methods from IPlatformServices
* Add docs for Ticker
* Remove unnecessary Ticker.Default set
* Move Ticker into Internals
* Update Ticker docs
* Remove old Ticker docs
* Remove commented code
Diffstat (limited to 'Xamarin.Forms.Core.UnitTests')
-rw-r--r-- | Xamarin.Forms.Core.UnitTests/MockPlatformServices.cs | 27 | ||||
-rw-r--r-- | Xamarin.Forms.Core.UnitTests/MotionTests.cs | 9 | ||||
-rw-r--r-- | Xamarin.Forms.Core.UnitTests/ProgressBarTests.cs | 1 | ||||
-rw-r--r-- | Xamarin.Forms.Core.UnitTests/ViewUnitTests.cs | 1 |
4 files changed, 34 insertions, 4 deletions
diff --git a/Xamarin.Forms.Core.UnitTests/MockPlatformServices.cs b/Xamarin.Forms.Core.UnitTests/MockPlatformServices.cs index 7d2317b3..5109cbb4 100644 --- a/Xamarin.Forms.Core.UnitTests/MockPlatformServices.cs +++ b/Xamarin.Forms.Core.UnitTests/MockPlatformServices.cs @@ -9,6 +9,8 @@ using Xamarin.Forms; using Xamarin.Forms.Core.UnitTests; using System.Security.Cryptography; using System.Text; +using Xamarin.Forms.Internals; + #if WINDOWS_PHONE using Xamarin.Forms.Platform.WinPhone; #endif @@ -88,6 +90,11 @@ namespace Xamarin.Forms.Core.UnitTests invokeOnMainThread (action); } + public Ticker CreateTicker() + { + return new MockTicker(); + } + public void StartTimer (TimeSpan interval, Func<bool> callback) { Timer timer = null; @@ -267,4 +274,24 @@ namespace Xamarin.Forms.Core.UnitTests { } } + + internal class MockTicker : Ticker + { + bool _enabled; + + protected override void EnableTimer() + { + _enabled = true; + + while (_enabled) + { + SendSignals(16); + } + } + + protected override void DisableTimer() + { + _enabled = false; + } + } }
\ No newline at end of file diff --git a/Xamarin.Forms.Core.UnitTests/MotionTests.cs b/Xamarin.Forms.Core.UnitTests/MotionTests.cs index acb764d7..0d8d476c 100644 --- a/Xamarin.Forms.Core.UnitTests/MotionTests.cs +++ b/Xamarin.Forms.Core.UnitTests/MotionTests.cs @@ -1,25 +1,26 @@ using System; using System.Collections.Generic; using NUnit.Framework; +using Xamarin.Forms.Internals; namespace Xamarin.Forms.Core.UnitTests { internal class BlockingTicker : Ticker { - bool enabled; + bool _enabled; protected override void EnableTimer () { - enabled = true; + _enabled = true; - while (enabled) { + while (_enabled) { SendSignals (16); } } protected override void DisableTimer () { - enabled = false; + _enabled = false; } } diff --git a/Xamarin.Forms.Core.UnitTests/ProgressBarTests.cs b/Xamarin.Forms.Core.UnitTests/ProgressBarTests.cs index 2af7eac0..1192b7e7 100644 --- a/Xamarin.Forms.Core.UnitTests/ProgressBarTests.cs +++ b/Xamarin.Forms.Core.UnitTests/ProgressBarTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using Xamarin.Forms.Internals; namespace Xamarin.Forms.Core.UnitTests { diff --git a/Xamarin.Forms.Core.UnitTests/ViewUnitTests.cs b/Xamarin.Forms.Core.UnitTests/ViewUnitTests.cs index 97700ca4..9e7f0546 100644 --- a/Xamarin.Forms.Core.UnitTests/ViewUnitTests.cs +++ b/Xamarin.Forms.Core.UnitTests/ViewUnitTests.cs @@ -4,6 +4,7 @@ using System.Collections.Specialized; using System.Threading.Tasks; using NUnit.Framework; +using Xamarin.Forms.Internals; namespace Xamarin.Forms.Core.UnitTests { |