DEF_TEST(SVGDevice_image_shader_tileboth, reporter) { SkDOM dom; SkPaint paint; int imageWidth = 3, imageHeight = 3; int rectWidth = 10, rectHeight = 10; ImageShaderTestSetup(&dom, &paint, imageWidth, imageHeight, rectWidth, rectHeight, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode); const SkDOM::Node* root = dom.finishParsing(); const SkDOM::Node *patternNode, *imageNode, *rectNode; const SkDOM::Node* innerSvg = dom.getFirstChild(root, "svg"); if (innerSvg == nullptr) { ERRORF(reporter, "inner svg element not found"); return; } bool structureAppropriate = FindImageShaderNodes(reporter, &dom, innerSvg, &patternNode, &imageNode, &rectNode); REPORTER_ASSERT(reporter, structureAppropriate); // the imageNode should always maintain its size. REPORTER_ASSERT(reporter, atoi(dom.findAttr(imageNode, "width")) == imageWidth); REPORTER_ASSERT(reporter, atoi(dom.findAttr(imageNode, "height")) == imageHeight); REPORTER_ASSERT(reporter, atoi(dom.findAttr(patternNode, "width")) == imageWidth); REPORTER_ASSERT(reporter, atoi(dom.findAttr(patternNode, "height")) == imageHeight); }
DEF_TEST(SVGDevice_image_shader_norepeat, reporter) { SkDOM dom; SkPaint paint; int imageWidth = 3, imageHeight = 3; int rectWidth = 10, rectHeight = 10; ImageShaderTestSetup(&dom, &paint, imageWidth, imageHeight, rectWidth, rectHeight, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); const SkDOM::Node* root = dom.finishParsing(); const SkDOM::Node *patternNode, *imageNode, *rectNode; bool structureAppropriate = FindImageShaderNodes(reporter, &dom, root, &patternNode, &imageNode, &rectNode); REPORTER_ASSERT(reporter, structureAppropriate); // the image should always maintain its size. REPORTER_ASSERT(reporter, atoi(dom.findAttr(imageNode, "width")) == imageWidth); REPORTER_ASSERT(reporter, atoi(dom.findAttr(imageNode, "height")) == imageHeight); // making the pattern as large as the container prevents // it from repeating. REPORTER_ASSERT(reporter, strcmp(dom.findAttr(patternNode, "width"), "100%") == 0); REPORTER_ASSERT(reporter, strcmp(dom.findAttr(patternNode, "height"), "100%") == 0); }