#!/usr/bin/env ruby
      
# Copyright (c) 2009 Cory Ondrejka. All rights reserved.
# See License.txt for licensing details.

require "#{File.dirname(__FILE__)}/../testing_file_support"

describe BalsamiqControlParser do
  it "properly handles searchbox" do
    data = <<-EOF
            <mockup version="1.0" skin="sketch">
      <controls>
        <control controlID="30" controlTypeID="com.balsamiq.mockups::SearchBox" x="23" y="15" w="-1" h="-1" zOrder="0" locked="false" isInGroup="-1">
          <controlProperties>
            <text>search</text>
          </controlProperties>
        </control>
        <control controlID="31" controlTypeID="com.balsamiq.mockups::SearchBox" x="23" y="48" w="-1" h="-1" zOrder="1" locked="false" isInGroup="-1">
          <controlProperties>
            <text>search%20me%21</text>
          </controlProperties>
        </control>
      </controls>
    </mockup>


    EOF
    html = <<-EOF
    <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by Balsamiq Exporter -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" type="text/css" href="reset.css" />
      <link rel="stylesheet" type="text/css" href="searchbox.css" />
    <title>Balsamiq</title>
    <script type="text/javascript">
    </script>
  </head>

  <body>
    <div class="SearchBox" id="SearchBox30"
        style="position: absolute; display: table; left: 23px; top: 15px; width: 94px; height: 23px;
        z-index: 0; outline: none;border: 1px solid #010101; ">
        <input style="background-color: transparent" name=search type="text" onKeyPress="" value="search"></input>
    </div>
    <div class="SearchBox" id="SearchBox31"
        style="position: absolute; display: table; left: 23px; top: 48px; width: 94px; height: 23px;
        z-index: 1; outline: none;border: 1px solid #010101; ">
        <input style="background-color: transparent" name=search type="text" onKeyPress="" value="search me!"></input>
    </div>
  </body>
</html>

    EOF
    css = <<-EOF
    .SearchBox {
  -moz-border-radius: 10px;
  -webkit-border-radius:10px;
  border-radius: 10px;
}

.SearchBox input {
  font-size: 11pt;
  text-align: left;
  margin-left: 8px;
  margin-right: 32px;
}
.SearchBox {
  -moz-border-radius: 10px;
  -webkit-border-radius:10px;
  border-radius: 10px;
}

.SearchBox input {
  font-size: 11pt;
  text-align: left;
  margin-left: 8px;
  margin-right: 32px;
}

    EOF
    js = <<-EOF
    /* Generated by Balsamiq Exporter
/* Simon Willison's cool hack to build out multiple onload events */
function addLoadEvent(func) 
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function') 
  {
    window.onload = func;
  } 
  else 
  {
    window.onload = function() 
    {
      if (oldonload) 
      {
        oldonload();
      }
      func();
    }
  }
}

    EOF
    filename = "searchbox"
    TestingFileSupport::test_elements(filename, data, html, css, js, false)
  end

end
