#!/usr/bin/env ruby

require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
require 'chunks/tikz'
require 'nokogiri'

class TikzTest < Test::Unit::TestCase
  include ChunkMatch

if ENV['tikz_server']

  def test_simple_tikzpicture
  match_pattern(Tikz, '\begin{tikzpicture}a\end{tikzpicture}',
    :plain_text => 'a',
    :unmask_text => Regexp.new("<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\"" +
    " width=\"388.543pt\" height=\"0pt\" viewBox=\"0 0 388.543 0\" version=\"1.[12]\">\n<g id=\"surface[0-9]+-1\">\n</g>\n</svg>")
  )
  end

  def test_equation_nowiki
  match_pattern(Tikz, '\begin{tikzpicture}\node[anchor=east] at (-1,-0.5) {$a$};\end{tikzpicture}',
    :plain_text => Regexp.new('\\\node\[anchor=east\] at \(-1,-0\.5\) \{\$a\$\};'),
    :unmask_text => Regexp.new("<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" w" +
    "idth=\"14.824pt\" height=\"13.759pt\" viewBox=\"0 0 14.824 13.759\" version=\"1.[12]\">\n<defs>\n<g>\n<symbol overflow=\"visib" +
    "le\" id=\"glyph[0-9]+-0-0\">\n<path style=\"stroke:none;\" d=\"M (3.828125 -2.03125 L 3.828125 -2.21875 C 3.828125 -3.53125 5.75 -4" +
    ".453125 5.75 -6.21875 C 5.75 -7.453125 4.703125 -8 3.53125 -8 C 2.328125 -8 1.5 -7.3125 1.5 -6.34375 C 1.5 -5.78125 1.73437" +
    "5 -5.515625 2.109375 -5.515625 C 2.40625 -5.515625 2.65625 -5.671875 2.65625 -6.03125 C 2.65625 -6.484375 2.40625 -6.5 2.40" +
    "625 -6.890625 C 2.40625 -7.265625 2.71875 -7.546875 3.4375 -7.546875 C 4.203125 -7.546875 4.671875 -7.125 4.671875 -6.1875 " +
    "C 4.671875 -4.34375 3.34375 -3.890625 3.34375 -2.34375 L 3.34375 -2.03125 Z M 4.28125 -0.578125 C 4.28125 -0.9375 4.03125 -" +
    "1.28125 3.609375 -1.28125 C 3.171875 -1.28125 2.90625 -0.953125 2.90625 -0.578125 C 2.90625 -0.171875 3.125 0.09375 3.59375" +
    " 0.09375 C 4.03125 0.09375 4.28125 -0.1875 4.28125 -0.578125 Z M 7.109375 2.015625 L 7.109375 -9.390625 L 0.125 -9.390625 L" +
    " 0.125 2.015625 Z M 6.484375 1.390625 L 0.734375 1.390625 L 0.734375 -8.78125 L 6.484375 -8.78125 Z( M 6.484375 1.390625){0,1}|3.765" +
    "625 -2 L 3.765625 -2.1875 C 3.765625 -3.46875 5.65625 -4.375 5.65625 -6.109375 C 5.65625 -7.328125 4.625 -7.859375 3.484375 -7." +
    "859375 C 2.296875 -7.859375 1.484375 -7.1875 1.484375 -6.234375 C 1.484375 -5.6875 1.703125 -5.421875 2.078125 -5.421875 C 2.35" +
    "9375 -5.421875 2.609375 -5.5625 2.609375 -5.9375 C 2.609375 -6.375 2.359375 -6.390625 2.359375 -6.78125 C 2.359375 -7.140625 2." +
    "671875 -7.421875 3.375 -7.421875 C 4.125 -7.421875 4.59375 -7 4.59375 -6.078125 C 4.59375 -4.265625 3.296875 -3.828125 3.296875" +
    " -2.296875 L 3.296875 -2 Z M 4.203125 -0.5625 C 4.203125 -0.921875 3.953125 -1.25 3.546875 -1.25 C 3.109375 -1.25 2.859375 -0.9" +
    "375 2.859375 -0.5625 C 2.859375 -0.171875 3.078125 0.09375 3.53125 0.09375 C 3.953125 0.09375 4.203125 -0.1875 4.203125 -0.5625" +
    " Z M 6.984375 1.984375 L 6.984375 -9.21875 L 0.125 -9.21875 L 0.125 1.984375 Z M 6.375 1.359375 L 0.71875 1.359375 L 0.71875 -8" +
    ".625 L 6.375 -8.625 Z M 6.375 1.359375) \"\/>\n<\/symbol>\n<sym" +
    "bol overflow=\"visible\" id=\"glyph[0-9]+-0-1\">\n<path style=\"stroke:none;\" d=\"M (6 -5.640625 L 5.359375 -5.640625 L 4.9375 -5." +
    "09375 L 4.890625 -5.09375 C 4.6875 -5.390625 4.296875 -5.71875 3.6875 -5.71875 C 1.984375 -5.71875 0.609375 -3.9375 0.59375" +
    " -1.640625 C 0.578125 -0.4375 1.203125 0.140625 2 0.140625 C 2.6875 0.140625 3.4375 -0.25 4.046875 -1.015625 L 4.140625 -1." +
    "015625 C 4.09375 -0.796875 4.046875 -0.640625 4.046875 -0.421875 C 4.046875 -0.078125 4.296875 0.125 4.703125 0.125 C 5.468" +
    "75 0.125 5.953125 -0.421875 6.4375 -1.15625 L 6.203125 -1.34375 C 6.046875 -1.140625 5.703125 -0.71875 5.3125 -0.71875 C 5." +
    "125 -0.71875 5.078125 -0.8125 5.078125 -0.96875 C 5.078125 -1.140625 5.140625 -1.40625 5.140625 -1.40625 Z M 4.65625 -4.140" +
    "625 C 4.65625 -3.734375 4.4375 -2.625 4.3125 -2.15625 C 4.09375 -1.296875 3.3125 -0.640625 2.5625 -0.640625 C 2.015625 -0.6" +
    "40625 1.65625 -0.953125 1.65625 -2.015625 C 1.65625 -3.640625 2.421875 -5.265625 3.609375 -5.265625 C 4.28125 -5.265625 4.6" +
    "5625 -4.71875 4.65625 -4.140625 Z( M 4.65625 -4.140625){0,1}|5.90625 -5.546875 L 5.28125 -5.546875 L 4.859375 -5 L 4.8125 -5 " +
    "C 4.609375 -5.296875 4.234375 -5.625 3.625 -5.625 C 1.953125 -5.625 0.59375 -3.859375 0.59375 -1.609375 C 0.578125 -0.421875 " +
    "1.1875 0.140625 1.96875 0.140625 C 2.640625 0.140625 3.375 -0.25 3.984375 -1 L 4.0625 -1 C 4.03125 -0.78125 3.984375 -0.64062" +
    "5 3.984375 -0.40625 C 3.984375 -0.078125 4.234375 0.125 4.625 0.125 C 5.375 0.125 5.84375 -0.40625 6.328125 -1.140625 L 6.093" +
    "75 -1.3125 C 5.953125 -1.109375 5.609375 -0.703125 5.234375 -0.703125 C 5.046875 -0.703125 5 -0.796875 5 -0.953125 C 5 -1.125" +
    " 5.046875 -1.390625 5.046875 -1.390625 Z M 4.578125 -4.078125 C 4.578125 -3.671875 4.359375 -2.578125 4.234375 -2.109375 C 4." +
    "015625 -1.265625 3.25 -0.640625 2.515625 -0.640625 C 1.96875 -0.640625 1.625 -0.9375 1.625 -1.96875 C 1.625 -3.578125 2.375 -" +
    "5.1875 3.546875 -5.1875 C 4.203125 -5.1875 4.578125 -4.640625 4.578125 -4.078125 Z M 4.578125 -4.078125) \"\/>\n<\/symbol>\n<" +
    "\/g>\n<\/defs>\n<g id=\"surface[0-9]+-1\">\n<g style=\"fill:rgb\\(0%," +
    "0%,0%\\);fill-opacity:1;\">\n  <use xlink:href=\"#glyph[0-9]+-0-1\" x=\"(3.945|3.918197)\" y=\"(9.695|9.528107)\"\/>\n<\/g>\n<\/g>\n<\/svg>")
  )
  end
end
end
