Skip to content
This repository was archived by the owner on Sep 25, 2024. It is now read-only.

Commit 74cd11c

Browse files
authored
Merge pull request #540 from xamarin/ermau-fix-491
[core] Fix no brush -> material
2 parents 3a21818 + b2bd6a7 commit 74cd11c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Xamarin.PropertyEditing.Tests/MaterialDesignColorViewModelTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,26 @@ public async Task ResourceBrushMatchesMaterialStaysResource()
269269
Assert.That (vm.SelectedBrushType, Is.EqualTo (CommonBrushType.Resource));
270270
}
271271

272+
[Test]
273+
[Description ("Material must distinguish when it's actually set or defaulting to black when setting black as a value")]
274+
public void NoValueToMaterialSets ()
275+
{
276+
var platform = new TargetPlatform (new MockEditorProvider ()) {
277+
SupportsMaterialDesign = true
278+
};
279+
var mockProperty = new Mock<IPropertyInfo> ();
280+
mockProperty.SetupGet (pi => pi.Type).Returns (typeof (CommonSolidBrush));
281+
var mockEditor = new MockObjectEditor (mockProperty.Object);
282+
283+
var vm = new BrushPropertyViewModel (platform, mockProperty.Object, new[] { mockEditor });
284+
Assume.That (vm.MaterialDesign.Color, Is.EqualTo (new CommonColor (0, 0, 0)));
285+
Assume.That (vm.ValueSource, Is.EqualTo (ValueSource.Default).Or.EqualTo (ValueSource.Unset));
286+
Assume.That (vm.SelectedBrushType, Is.EqualTo (CommonBrushType.NoBrush));
287+
288+
vm.SelectedBrushType = CommonBrushType.MaterialDesign;
289+
Assert.That (vm.ValueSource, Is.EqualTo (ValueSource.Local));
290+
}
291+
272292
protected override CommonBrush GetRandomTestValue (Random rand)
273293
{
274294
CommonColor color = rand.NextColor ();

Xamarin.PropertyEditing/ViewModels/MaterialDesignColorViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public CommonColor Color
2424
}
2525

2626
private set {
27-
if (!Color.Equals (value)) {
27+
if (!Color.Equals (value) || !(Parent.Value is CommonSolidBrush)) {
2828
// Debug.WriteLine ($"Setting Color to {value}");
2929
Parent.Value = new CommonSolidBrush (value, null, Parent.Value?.Opacity ?? 1.0);
3030
// Debug.WriteLine ($"Notifying alpha and color change");

0 commit comments

Comments
 (0)