blob: 91c84f8e0f25f7c7397bcba712dbebe714a98f90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
using System;
using NUnit.Framework;
using Xamarin.Forms.Core.UnitTests;
namespace Xamarin.Forms.Xaml.UnitTests
{
[TestFixture]
public class Issue1594
{
[SetUp]
public void Setup()
{
Device.PlatformServices = new MockPlatformServices();
}
[TearDown]
public void TearDown()
{
Device.PlatformServices = null;
}
[Test]
public void OnPlatformForButtonHeight ()
{
var xaml = @"
<Button
xmlns=""http://xamarin.com/schemas/2014/forms""
xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
xmlns:sys=""clr-namespace:System;assembly=mscorlib""
x:Name=""activateButton"" Text=""ACTIVATE NOW"" TextColor=""White"" BackgroundColor=""#00A0FF"">
<Button.HeightRequest>
<OnPlatform x:TypeArguments=""sys:Double""
iOS=""33""
Android=""44""
WinPhone=""44"" />
</Button.HeightRequest>
</Button>";
((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS;
var button = new Button ().LoadFromXaml (xaml);
Assert.AreEqual (33, button.HeightRequest);
((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android;
button = new Button ().LoadFromXaml (xaml);
Assert.AreEqual (44, button.HeightRequest);
((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.WinPhone;
button = new Button ().LoadFromXaml (xaml);
Assert.AreEqual (44, button.HeightRequest);
}
}
}
|