79 строки
1.7 KiB
C#
79 строки
1.7 KiB
C#
//
|
|
// Unit tests for CGContextPDF
|
|
//
|
|
// Authors:
|
|
// Sebastien Pouliot <sebastien@xamarin.com>
|
|
//
|
|
// Copyright 2014 Xamarin Inc. All rights reserved.
|
|
//
|
|
|
|
using System;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
#if XAMCORE_2_0
|
|
using CoreGraphics;
|
|
using Foundation;
|
|
#else
|
|
using MonoTouch.CoreGraphics;
|
|
using MonoTouch.Foundation;
|
|
#endif
|
|
using NUnit.Framework;
|
|
|
|
#if XAMCORE_2_0
|
|
using RectangleF=CoreGraphics.CGRect;
|
|
using SizeF=CoreGraphics.CGSize;
|
|
using PointF=CoreGraphics.CGPoint;
|
|
#else
|
|
using nfloat=global::System.Single;
|
|
using nint=global::System.Int32;
|
|
using nuint=global::System.UInt32;
|
|
#endif
|
|
|
|
namespace MonoTouchFixtures.CoreGraphics {
|
|
|
|
[TestFixture]
|
|
[Preserve (AllMembers = true)]
|
|
public class PDFContextTest {
|
|
|
|
static string filename;
|
|
|
|
static PDFContextTest ()
|
|
{
|
|
filename = Environment.GetFolderPath (Environment.SpecialFolder.CommonDocuments) + "/t.pdf";
|
|
}
|
|
|
|
[Test]
|
|
public void Context_Url ()
|
|
{
|
|
using (var url = new NSUrl (filename))
|
|
using (var ctx = new CGContextPDF (url)) {
|
|
ctx.BeginPage (PDFInfoTest.GetInfo ());
|
|
ctx.SetUrl (url, RectangleF.Empty);
|
|
ctx.EndPage ();
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void Context_Url_Rect ()
|
|
{
|
|
var rect = new RectangleF (10, 10, 100, 100);
|
|
using (var url = new NSUrl (filename))
|
|
using (var ctx = new CGContextPDF (url, rect)) {
|
|
ctx.BeginPage ((CGPDFPageInfo) null);
|
|
ctx.SetDestination ("xamarin", rect);
|
|
ctx.EndPage ();
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void Context_Url_Rect_Info ()
|
|
{
|
|
using (var url = new NSUrl (filename))
|
|
using (var ctx = new CGContextPDF (url, new RectangleF (0, 0, 1000, 1000), PDFInfoTest.GetInfo ())) {
|
|
ctx.AddDestination ("monkey", PointF.Empty);
|
|
ctx.Close ();
|
|
}
|
|
}
|
|
}
|
|
}
|