public void TestMeasure(double availableWidth, double availableHeight) { var view = new Mock <ISwitch>(); var drawable = new SwitchDrawable(view.Object); var size = drawable.Measure(availableWidth, availableHeight); Assert.Equal(new Size(DeviceInfo.ScalingFactor, DeviceInfo.ScalingFactor), size); }
public void TestOnTouchDown() { var view = new Mock <ISwitch>(); var drawable = new SwitchDrawable(view.Object); var exception = Record.Exception(() => { var point = new GPoint(10, 10); drawable.OnTouchDown(point); }); Assert.Null(exception); }
public void TestDraw(bool isEnabled, bool isToggled) { var view = new Mock <ISwitch>(); view.Setup(x => x.IsToggled).Returns(isToggled); Assert.Equal(isToggled, view.Object.IsToggled); var canvas = new Mock <ICanvas>(); var drawable = new SwitchDrawable(view.Object); drawable.IsEnabled = isEnabled; Assert.Equal(isEnabled, drawable.IsEnabled); var exception = Record.Exception(() => { drawable.Draw(canvas.Object, new RectF(0, 0, 100, 100)); }); Assert.Null(exception); }
public static DrawableBase?Create(SvgElement svgElement, Rect skOwnerBounds, DrawableBase?parent, IAssetLoader assetLoader, Attributes ignoreAttributes = Attributes.None) { return(svgElement switch { SvgAnchor svgAnchor => AnchorDrawable.Create(svgAnchor, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgFragment svgFragment => FragmentDrawable.Create(svgFragment, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgImage svgImage => ImageDrawable.Create(svgImage, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgSwitch svgSwitch => SwitchDrawable.Create(svgSwitch, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgUse svgUse => UseDrawable.Create(svgUse, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgCircle svgCircle => CircleDrawable.Create(svgCircle, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgEllipse svgEllipse => EllipseDrawable.Create(svgEllipse, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgRectangle svgRectangle => RectangleDrawable.Create(svgRectangle, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgGroup svgGroup => GroupDrawable.Create(svgGroup, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgLine svgLine => LineDrawable.Create(svgLine, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgPath svgPath => PathDrawable.Create(svgPath, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgPolyline svgPolyline => PolylineDrawable.Create(svgPolyline, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgPolygon svgPolygon => PolygonDrawable.Create(svgPolygon, skOwnerBounds, parent, assetLoader, ignoreAttributes), SvgText svgText => TextDrawable.Create(svgText, skOwnerBounds, parent, assetLoader, ignoreAttributes), _ => null, });