2021-08-11 11:06:46 +03:00
|
|
|
#if __IOS__ || MONOMAC
|
2019-07-04 20:08:21 +03:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
using Foundation;
|
|
|
|
using WebKit;
|
|
|
|
|
|
|
|
namespace MonoTouchFixtures.WebKit {
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
[Preserve (AllMembers = true)]
|
|
|
|
public class NSAttributedStringCatagoryTest {
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup ()
|
|
|
|
{
|
2022-11-10 19:59:26 +03:00
|
|
|
TestRuntime.AssertXcodeVersion (11, 0);
|
2019-07-04 20:08:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void LoadHtmlAsync_NSUrl ()
|
|
|
|
{
|
|
|
|
var completed = false;
|
|
|
|
string d = Path.Combine (NSBundle.MainBundle.ResourcePath, "access-denied.html");
|
|
|
|
string g = Path.Combine (NSBundle.MainBundle.ResourcePath, "access-granted.html");
|
2023-06-06 22:36:49 +03:00
|
|
|
TestRuntime.RunAsync (TimeSpan.FromSeconds (30), async () => {
|
2019-07-04 20:08:21 +03:00
|
|
|
using (var denied = NSUrl.FromFilename (d))
|
|
|
|
using (var granted = NSUrl.FromFilename (g)) {
|
|
|
|
var options = new NSAttributedStringDocumentAttributes {
|
|
|
|
ReadAccessUrl = granted
|
|
|
|
};
|
|
|
|
var r1 = await NSAttributedString.LoadFromHtmlAsync (granted, options);
|
|
|
|
Assert.That (r1.AttributedString.Value, Is.EqualTo ("Granted"), "granted by options");
|
|
|
|
#if false
|
|
|
|
// this does not match my interpretation of the (headers) docs
|
|
|
|
var r2 = await NSAttributedString.LoadFromHtmlAsync (denied, options);
|
|
|
|
Assert.That (r2.AttributedString.Value, Is.Not.EqualTo ("Denied"), "denied by options");
|
|
|
|
#endif
|
|
|
|
completed = true;
|
|
|
|
}
|
|
|
|
}, () => completed);
|
|
|
|
Assert.True (completed, "completed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-11 11:06:46 +03:00
|
|
|
#endif
|