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

Commit b96f65b

Browse files
Merge branch '15-5'
2 parents 3a5eb2e + 3bcb9c6 commit b96f65b

File tree

27 files changed

+615
-184
lines changed

27 files changed

+615
-184
lines changed

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39853.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ public class RoundedButton : Xamarin.Forms.Button
1313
{
1414
public RoundedButton(int radius)
1515
{
16+
#pragma warning disable 0618
1617
base.BorderRadius = radius;
18+
#pragma warning restore
1719
base.WidthRequest = 2 * radius;
1820
base.HeightRequest = 2 * radius;
1921
HorizontalOptions = LayoutOptions.Center;
@@ -29,14 +31,18 @@ public RoundedButton(int radius)
2931
{
3032
get
3133
{
34+
#pragma warning disable 0618
3235
return base.BorderRadius;
36+
#pragma warning restore
3337
}
3438

3539
set
3640
{
3741
base.WidthRequest = 2 * value;
3842
base.HeightRequest = 2 * value;
43+
#pragma warning disable 0618
3944
base.BorderRadius = value;
45+
#pragma warning restore
4046
}
4147
}
4248

@@ -51,7 +57,9 @@ public RoundedButton(int radius)
5157
{
5258
base.WidthRequest = value;
5359
base.HeightRequest = value;
60+
#pragma warning disable 0618
5461
base.BorderRadius = ((int)value) / 2;
62+
#pragma warning restore
5563
}
5664
}
5765

@@ -66,7 +74,9 @@ public RoundedButton(int radius)
6674
{
6775
base.WidthRequest = value;
6876
base.HeightRequest = value;
77+
#pragma warning disable 0618
6978
base.BorderRadius = ((int)value) / 2;
79+
#pragma warning restore
7080
}
7181
}
7282

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1026.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public Issue1026 ()
2424
Text = "Subscribe with LinkedIn",
2525
WidthRequest = 262,
2626
HorizontalOptions = LayoutOptions.Center,
27+
#pragma warning disable 0618
2728
BorderRadius = 0,
29+
#pragma warning restore
2830
},
2931
// new Label {
3032
// Text = "or by email",
@@ -73,7 +75,9 @@ public Issue1026 ()
7375
Text = "Create an account",
7476
WidthRequest = 262,
7577
HorizontalOptions = LayoutOptions.Center,
78+
#pragma warning disable 0618
7679
BorderRadius = 0,
80+
#pragma warning restore
7781
},
7882
new Label {
7983
Text = "by subscribing, you accept the general conditions.",
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
using Xamarin.Forms.CustomAttributes;
2+
using Xamarin.Forms.Internals;
3+
using System.Reflection;
4+
5+
#if UITEST
6+
using Xamarin.Forms.Core.UITests;
7+
using Xamarin.UITest;
8+
using NUnit.Framework;
9+
#endif
10+
11+
namespace Xamarin.Forms.Controls.Issues
12+
{
13+
[Preserve(AllMembers = true)]
14+
[Issue(IssueTracker.Github, 1436, "Button border not drawn on Android without a BorderRadius", PlatformAffected.Android)]
15+
public class Issue1436 : TestContentPage
16+
{
17+
protected override void Init()
18+
{
19+
var grid = new Grid
20+
{
21+
ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } },
22+
RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } }
23+
};
24+
25+
grid.Children.Add(new Button
26+
{
27+
Text = "Button",
28+
HorizontalOptions = LayoutOptions.End,
29+
BorderColor = Color.AliceBlue,
30+
BorderWidth = 5
31+
}, 0, 0);
32+
33+
grid.Children.Add(new Button
34+
{
35+
Text = "Button",
36+
HorizontalOptions = LayoutOptions.Start,
37+
BackgroundColor = Color.Gray
38+
}, 1, 1);
39+
40+
grid.Children.Add(new Button
41+
{
42+
Text = "Button",
43+
HorizontalOptions = LayoutOptions.End,
44+
}, 0, 1);
45+
46+
grid.Children.Add(new Button
47+
{
48+
Text = "Button",
49+
50+
HorizontalOptions = LayoutOptions.Start,
51+
}, 1, 0);
52+
53+
StackLayout stackLayout = new StackLayout
54+
{
55+
VerticalOptions = LayoutOptions.Center,
56+
Children = {
57+
new Label{ Text = "The following four buttons should all be the same size. One has a ridiculous border. One has a darker background. One is the default button." },
58+
grid,
59+
new Label{ Text = "The following three buttons should all have a red border." },
60+
new Button {
61+
Text = "BorderWidth = 1, CornerRadius = [default],",
62+
HorizontalOptions = LayoutOptions.Center,
63+
BorderColor = Color.Red,
64+
BorderWidth = 1,
65+
},
66+
new Button {
67+
Text = "BorderWidth = 1, CornerRadius = 0",
68+
HorizontalOptions = LayoutOptions.Center,
69+
BackgroundColor = Color.Blue,
70+
BorderColor = Color.Red,
71+
BorderWidth = 1,
72+
CornerRadius = 0,
73+
TextColor = Color.White
74+
},
75+
new Button {
76+
Text = "BorderWidth = 1, CornerRadius = 1",
77+
HorizontalOptions = LayoutOptions.Center,
78+
BackgroundColor = Color.Black,
79+
BorderColor = Color.Red,
80+
BorderWidth = 1,
81+
CornerRadius = 1,
82+
TextColor = Color.White
83+
}
84+
},
85+
};
86+
87+
Content = stackLayout;
88+
}
89+
90+
#if UITEST
91+
[Test]
92+
[Category(UITestCategories.ManualReview)]
93+
public void Issue1436Test()
94+
{
95+
RunningApp.Screenshot("I am at Issue 1436");
96+
}
97+
#endif
98+
}
99+
}

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@
396396
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla60524.cs" />
397397
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla59925.cs" />
398398
<Compile Include="$(MSBuildThisFileDirectory)Issue1326.cs" />
399+
<Compile Include="$(MSBuildThisFileDirectory)Issue1436.cs" />
399400
<Compile Include="$(MSBuildThisFileDirectory)_Template.cs" />
400401
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42620.cs" />
401402
<Compile Include="$(MSBuildThisFileDirectory)Issue1028.cs" />
@@ -840,4 +841,4 @@
840841
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
841842
</EmbeddedResource>
842843
</ItemGroup>
843-
</Project>
844+
</Project>

Xamarin.Forms.Controls/CoreGalleryPages/ButtonCoreGalleryPage.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ protected override void Build (StackLayout stackLayout)
3737
Text = "BorderRadius",
3838
BackgroundColor = Color.Transparent,
3939
BorderColor = Color.Red,
40+
#pragma warning disable 0618
4041
BorderRadius = 20,
42+
#pragma warning restore
4143
BorderWidth = 1,
4244
}
4345
);

Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public ButtonGallery ()
5959
BorderColor = Color.Black,
6060
BackgroundColor = Color.Purple,
6161
BorderWidth = 5,
62+
#pragma warning disable 0618
6263
BorderRadius = 5
64+
#pragma warning restore
6365
};
6466
var timer = new Button { Text = "Timer" };
6567
var busy = new Button { Text = "Toggle Busy" };

Xamarin.Forms.Core.UITests.Shared/PlatformQueries.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal static class PlatformMethodQueries
1010
public static readonly Dictionary<BindableProperty, Tuple<string[], bool>> PropertyPlatformMethodDictionary = new Dictionary<BindableProperty, Tuple<string[], bool>> {
1111
{ ActivityIndicator.ColorProperty, Tuple.Create (new[] { "color" }, false) },
1212
{ ActivityIndicator.IsRunningProperty, Tuple.Create (new[] { "isAnimating" }, false) },
13-
{ Button.BorderRadiusProperty, Tuple.Create (new[] { "layer", "cornerRadius" }, false) },
13+
{ Button.CornerRadiusProperty, Tuple.Create (new[] { "layer", "cornerRadius" }, false) },
1414
{ Button.BorderWidthProperty, Tuple.Create (new[] { "layer", "borderWidth" }, false) },
1515
{ Button.FontProperty, Tuple.Create (new[] { "titleLabel", "font" }, false) },
1616
{ Button.TextProperty, Tuple.Create (new[] { "titleLabel", "text" }, false) },
@@ -33,7 +33,7 @@ internal static class PlatformMethodQueries
3333
{ ActivityIndicator.ColorProperty, Tuple.Create(new[] { "getProgressDrawable", "getColor" }, false) },
3434
{ ActivityIndicator.IsRunningProperty, Tuple.Create(new[] { "isIndeterminate" }, false) },
3535
{ Button.BorderColorProperty, Tuple.Create(new[] { "getBackground" }, false) },
36-
{ Button.BorderRadiusProperty, Tuple.Create(new[] { "getBackground" }, false) },
36+
{ Button.CornerRadiusProperty, Tuple.Create(new[] { "getBackground" }, false) },
3737
{ Button.BorderWidthProperty, Tuple.Create(new[] { "getBackground" }, false) },
3838
{ Button.ImageProperty, Tuple.Create(new[] { "getBackground" }, false) },
3939
{ Button.FontProperty, Tuple.Create(new[] { "getTypeface", "isBold" }, false) },

Xamarin.Forms.Core.UITests.Shared/Tests/ButtonUITests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void BorderRadius()
5959
remote.GoTo();
6060

6161
#if __IOS__
62-
var borderRadius = remote.GetProperty<float>(Button.BorderRadiusProperty);
62+
var borderRadius = remote.GetProperty<float>(Button.CornerRadiusProperty);
6363
Assert.AreEqual(20.0f, borderRadius);
6464
#endif
6565
}

Xamarin.Forms.Core.UnitTests/BindableObjectUnitTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,23 @@ public void IsSetIsTrueWhenPropSet()
890890
Assert.IsTrue(isSet);
891891
}
892892

893+
[Test]
894+
public void IsSetIsTrueWhenPropCleared()
895+
{
896+
string defaultValue = "default";
897+
string newValue = "new value";
898+
899+
var bindableProperty = BindableProperty.Create("Foo", typeof(string), typeof(MockBindable), defaultValue);
900+
var bindable = new MockBindable();
901+
902+
bindable.SetValue(bindableProperty, newValue);
903+
904+
bindable.ClearValue(bindableProperty);
905+
906+
var isSet = bindable.IsSet(bindableProperty);
907+
Assert.IsTrue(isSet);
908+
}
909+
893910
[Test]
894911
public void IsSetIsTrueWhenPropSetToDefault()
895912
{
@@ -905,6 +922,7 @@ public void IsSetIsTrueWhenPropSetToDefault()
905922
var isSet = bindable.IsSet(bindableProperty);
906923
Assert.IsTrue(isSet);
907924
}
925+
908926
[Test]
909927
public void IsSetIsTrueWhenPropSetByDefaultValueCreator()
910928
{

Xamarin.Forms.Core.UnitTests/ButtonUnitTest.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,47 @@ public void ButtonClickWhenCommandCanExecuteFalse()
250250

251251
Assert.False(invoked);
252252
}
253+
254+
public void ButtonBorderRadiusForwardsToButtonCornerRadius()
255+
{
256+
var button = new Button { Platform = new UnitPlatform() };
257+
button.BorderRadius = 10;
258+
259+
Assert.AreEqual(10, button.CornerRadius);
260+
}
261+
262+
[Test]
263+
public void ButtonCornerRadiusForwardsToButtonBorderRadius()
264+
{
265+
var button = new Button { Platform = new UnitPlatform() };
266+
button.CornerRadius = 10;
267+
268+
Assert.AreEqual(10, button.BorderRadius);
269+
}
270+
271+
[Test]
272+
public void ButtonCornerRadiusClearValueForwardsToButtonBorderRadius()
273+
{
274+
var button = new Button { Platform = new UnitPlatform() };
275+
276+
button.CornerRadius = 10;
277+
278+
button.ClearValue(Button.CornerRadiusProperty);
279+
280+
Assert.AreEqual((int)Button.BorderRadiusProperty.DefaultValue, button.BorderRadius);
281+
}
282+
283+
[Test]
284+
public void ButtonBorderRadiusClearValueForwardsToButtonCornerRadius()
285+
{
286+
var button = new Button { Platform = new UnitPlatform() };
287+
288+
button.BorderRadius = 10;
289+
290+
button.ClearValue(Button.BorderRadiusProperty);
291+
292+
Assert.AreEqual((int)Button.CornerRadiusProperty.DefaultValue, button.CornerRadius);
293+
}
253294

254295
private void AssertButtonContentLayoutsEqual(Button.ButtonContentLayout layout1, object layout2)
255296
{
@@ -259,4 +300,4 @@ private void AssertButtonContentLayoutsEqual(Button.ButtonContentLayout layout1,
259300
Assert.AreEqual(layout1.Spacing, bcl.Spacing);
260301
}
261302
}
262-
}
303+
}

0 commit comments

Comments
 (0)