forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bindable Text Property on Span * Style applied to Span * Added style property * Unit tests added * Minor fix and cleanup * Cleanup of code after review * Updated docs * Set Parent and reduce calls to Text property * OneTime Binding * Allow OneTime Binding as a default * Updated docs
- Loading branch information
Showing
21 changed files
with
550 additions
and
293 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using NUnit.Framework; | ||
|
||
namespace Xamarin.Forms.Core.UnitTests | ||
{ | ||
[TestFixture] | ||
public class SpanTests : BaseTestFixture | ||
{ | ||
[SetUp] | ||
public override void Setup() | ||
{ | ||
base.Setup(); | ||
Device.PlatformServices = new MockPlatformServices(); | ||
} | ||
|
||
[TearDown] | ||
public override void TearDown() | ||
{ | ||
base.TearDown(); | ||
Device.PlatformServices = null; | ||
} | ||
|
||
[Test] | ||
public void StyleApplied() | ||
{ | ||
var pinkStyle = new Style(typeof(Span)) | ||
{ | ||
Setters = { | ||
new Setter { Property = Span.TextColorProperty, Value = Color.Pink }, | ||
}, | ||
Class = "pink", | ||
ApplyToDerivedTypes = true, | ||
}; | ||
|
||
var span = new Span | ||
{ | ||
Style = pinkStyle | ||
}; | ||
|
||
var formattedText = new FormattedString(); | ||
formattedText.Spans.Add(span); | ||
|
||
var label = new Label() | ||
{ | ||
FormattedText = formattedText | ||
}; | ||
|
||
new ContentView | ||
{ | ||
Resources = new ResourceDictionary { pinkStyle }, | ||
Content = label | ||
}; | ||
|
||
Assert.AreEqual(Color.Pink, span.TextColor); | ||
} | ||
|
||
[Test] | ||
public void BindingApplied() | ||
{ | ||
var vm = new ViewModel() | ||
{ | ||
Text = "CheckBindingWorked" | ||
}; | ||
|
||
var formattedText = new FormattedString(); | ||
|
||
var label = new Label() | ||
{ | ||
FormattedText = formattedText | ||
}; | ||
|
||
var span = new Span(); | ||
span.SetBinding(Span.TextProperty, "Text"); | ||
|
||
formattedText.Spans.Add(span); | ||
|
||
label.BindingContext = vm; | ||
|
||
Assert.AreEqual(vm.Text, span.Text); | ||
} | ||
|
||
class ViewModel | ||
{ | ||
public string Text { get; set; } | ||
} | ||
} | ||
} |
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
Oops, something went wrong.