From 9ca602ae04a761c7983990942a72a45bdfdb2d7d Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Tue, 6 Feb 2018 19:06:11 -0500 Subject: guard xml-using tests with SK_XML I think this will fix the Google3 roll. Unclear to me if we actually want this to work there. I guess it comes down to the expat dependency? Change-Id: I5f8a6263aeae29e338a13207845fbe51ac9acc18 Reviewed-on: https://skia-review.googlesource.com/104562 Reviewed-by: Mike Klein Commit-Queue: Mike Klein --- tests/AnnotationTest.cpp | 69 +++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 33 deletions(-) (limited to 'tests/AnnotationTest.cpp') diff --git a/tests/AnnotationTest.cpp b/tests/AnnotationTest.cpp index b49b80d545..e55cc36ba8 100644 --- a/tests/AnnotationTest.cpp +++ b/tests/AnnotationTest.cpp @@ -8,9 +8,7 @@ #include "SkCanvas.h" #include "SkData.h" #include "SkDocument.h" -#include "SkSVGCanvas.h" #include "SkStream.h" -#include "SkXMLWriter.h" #include "Test.h" /** Returns true if data (may contain null characters) contains needle (null @@ -78,41 +76,46 @@ DEF_TEST(Annotation_PdfDefineNamedDestination, reporter) { ContainsString(rawOutput, out->size(), "/example ")); } -DEF_TEST(Annotation_SvgLink, reporter) { - SkDynamicMemoryWStream outStream; - std::unique_ptr xmlWriter(new SkXMLStreamWriter(&outStream)); - SkRect bounds = SkRect::MakeIWH(400, 400); - std::unique_ptr canvas = SkSVGCanvas::Make(bounds, xmlWriter.get()); +#if defined(SK_XML) + #include "SkSVGCanvas.h" + #include "SkXMLWriter.h" - SkRect r = SkRect::MakeXYWH(SkIntToScalar(72), SkIntToScalar(72), SkIntToScalar(288), - SkIntToScalar(72)); - sk_sp data(SkData::MakeWithCString("http://www.gooogle.com")); - SkAnnotateRectWithURL(canvas.get(), r, data.get()); + DEF_TEST(Annotation_SvgLink, reporter) { + SkDynamicMemoryWStream outStream; + std::unique_ptr xmlWriter(new SkXMLStreamWriter(&outStream)); + SkRect bounds = SkRect::MakeIWH(400, 400); + std::unique_ptr canvas = SkSVGCanvas::Make(bounds, xmlWriter.get()); - canvas->flush(); - sk_sp out = outStream.detachAsData(); - const char* rawOutput = (const char*)out->data(); + SkRect r = SkRect::MakeXYWH(SkIntToScalar(72), SkIntToScalar(72), SkIntToScalar(288), + SkIntToScalar(72)); + sk_sp data(SkData::MakeWithCString("http://www.gooogle.com")); + SkAnnotateRectWithURL(canvas.get(), r, data.get()); - REPORTER_ASSERT(reporter, - ContainsString(rawOutput, out->size(), "a xlink:href=\"http://www.gooogle.com\"")); -} + canvas->flush(); + sk_sp out = outStream.detachAsData(); + const char* rawOutput = (const char*)out->data(); -DEF_TEST(Annotation_SvgLinkNamedDestination, reporter) { - SkDynamicMemoryWStream outStream; - std::unique_ptr xmlWriter(new SkXMLStreamWriter(&outStream)); - SkRect bounds = SkRect::MakeIWH(400, 400); - std::unique_ptr canvas = SkSVGCanvas::Make(bounds, xmlWriter.get()); + REPORTER_ASSERT(reporter, + ContainsString(rawOutput, out->size(), "a xlink:href=\"http://www.gooogle.com\"")); + } - SkRect r = SkRect::MakeXYWH(SkIntToScalar(72), SkIntToScalar(72), SkIntToScalar(288), - SkIntToScalar(72)); - sk_sp data(SkData::MakeWithCString("http://www.gooogle.com/#NamedDestination")); - SkAnnotateLinkToDestination(canvas.get(), r, data.get()); + DEF_TEST(Annotation_SvgLinkNamedDestination, reporter) { + SkDynamicMemoryWStream outStream; + std::unique_ptr xmlWriter(new SkXMLStreamWriter(&outStream)); + SkRect bounds = SkRect::MakeIWH(400, 400); + std::unique_ptr canvas = SkSVGCanvas::Make(bounds, xmlWriter.get()); - canvas->flush(); - sk_sp out = outStream.detachAsData(); - const char* rawOutput = (const char*)out->data(); + SkRect r = SkRect::MakeXYWH(SkIntToScalar(72), SkIntToScalar(72), SkIntToScalar(288), + SkIntToScalar(72)); + sk_sp data(SkData::MakeWithCString("http://www.gooogle.com/#NamedDestination")); + SkAnnotateLinkToDestination(canvas.get(), r, data.get()); - REPORTER_ASSERT(reporter, - ContainsString(rawOutput, out->size(), - "a xlink:href=\"http://www.gooogle.com/#NamedDestination\"")); -} + canvas->flush(); + sk_sp out = outStream.detachAsData(); + const char* rawOutput = (const char*)out->data(); + + REPORTER_ASSERT(reporter, + ContainsString(rawOutput, out->size(), + "a xlink:href=\"http://www.gooogle.com/#NamedDestination\"")); + } +#endif -- cgit v1.2.3