Exemplo n.º 1
0
            public void OnPlatformDefault(bool useCompiledXaml)
            {
                mockDeviceInfo.Platform = DevicePlatform.Create("\ud83d\ude80");
                var layout = new OnPlatform(useCompiledXaml);

                Assert.AreEqual(63, layout.label0.HeightRequest);
            }
Exemplo n.º 2
0
		bool TryGetValueForPlatform(out object value)
		{
			if (DeviceInfo.Platform == DevicePlatform.Android && Android != s_notset)
			{
				value = Android;
				return true;
			}
			if (DeviceInfo.Platform == DevicePlatform.Create("GTK") && GTK != s_notset)
			{
				value = GTK;
				return true;
			}
			if (DeviceInfo.Platform == DevicePlatform.iOS && iOS != s_notset)
			{
				value = iOS;
				return true;
			}
			if (DeviceInfo.Platform == DevicePlatform.macOS && macOS != s_notset)
			{
				value = macOS;
				return true;
			}
			if (DeviceInfo.Platform == DevicePlatform.MacCatalyst && MacCatalyst != s_notset)
			{
				value = MacCatalyst;
				return true;
			}
			if (DeviceInfo.Platform == DevicePlatform.Tizen && Tizen != s_notset)
			{
				value = Tizen;
				return true;
			}
			if (DeviceInfo.Platform == DevicePlatform.WinUI && WinUI != s_notset)
			{
				value = WinUI;
				return true;
			}
#pragma warning disable CS0618 // Type or member is obsolete
			if (DeviceInfo.Platform == DevicePlatform.WinUI && UWP != s_notset)
			{
				value = UWP;
				return true;
			}
			if (DeviceInfo.Platform == DevicePlatform.Create("UWP") && UWP != s_notset)
			{
				value = UWP;
				return true;
			}
#pragma warning restore CS0618 // Type or member is obsolete
			if (DeviceInfo.Platform == DevicePlatform.Create("WPF") && WPF != s_notset)
			{
				value = WPF;
				return true;
			}
			value = Default;
			return value != s_notset;
		}
Exemplo n.º 3
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     // WPF doesn't show ToolbarItems for pages in modal stack
     // so we use NavigationBehavior.SetApplicationRoot and pop TestCases page from modal stack to make this test case visible with toolbar items
     if (DeviceInfo.Platform == DevicePlatform.Create("WPF"))
     {
         Navigation.PopModalAsync();
     }
 }
Exemplo n.º 4
0
        public void OnPlatformExtension(string markup, string platform, int expected)
        {
            mockDeviceInfo.Platform = DevicePlatform.Create(platform);

            var actual = (new MarkupExtensionParser()).ParseExpression(ref markup, new Internals.XamlServiceProvider(null, null)
            {
                IXamlTypeResolver   = typeResolver,
                IProvideValueTarget = new MockValueProvider("foo", new object())
                {
                    TargetProperty = GetType().GetProperty(nameof(FontSize))
                }
            });

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 5
0
            public void OnPlatform2Syntax(bool useCompiledXaml)
            {
                mockDeviceInfo.Platform = DevicePlatform.Android;
                var layout = new OnPlatform(useCompiledXaml);

                Assert.AreEqual(42, layout.label0.HeightRequest);

                mockDeviceInfo.Platform = DevicePlatform.iOS;
                layout = new OnPlatform(useCompiledXaml);
                Assert.AreEqual(21, layout.label0.HeightRequest);


                mockDeviceInfo.Platform = DevicePlatform.Create("FooBar");
                layout = new OnPlatform(useCompiledXaml);
                Assert.AreEqual(42, layout.label0.HeightRequest);
            }
Exemplo n.º 6
0
            DevicePlatform SetUpPlatform(string platform)
            {
                var p = DevicePlatform.Create(platform);

                mockDeviceInfo.Platform = p;
                if (p == DevicePlatform.iOS)
                {
                    DependencyService.Register <INativeValueConverterService, MockIosPlatformValueConverterService>();
                    DependencyService.Register <INativeBindingService, MockIosPlatformBindingService>();
                }
                else if (p == DevicePlatform.Android)
                {
                    DependencyService.Register <INativeValueConverterService, MockAndroidPlatformValueConverterService>();
                    DependencyService.Register <INativeBindingService, MockAndroidPlatformBindingService>();
                }

                return(p);
            }