#!/usr/bin/env ruby
# $Id: tc_generator.rb,v 1.2 2004/05/12 18:23:34 eto Exp $
# Copyright (C) 2003-2004 Kouichirou Eto, All rights reserved.
# This is free software with ABSOLUTELY NO WARRANTY.
# You can redistribute it and/or modify it under the terms of the GNU GPL2.

require "test_common"

class TC_Generator < Test::Unit::TestCase
  include TestSession

  def test_template_factory
    xml = @memory.template.get("view")
    e = xml.elements["//h1"]
    assert_equal(nil, e.text)

    e.text = "t" # destructive method
    assert_equal("t", e.text)

    xml = @memory.template.get("view")
    e = xml.elements["//h1"]
    assert_equal(nil, e.text) # no side effect
  end

  def test_theme_factory
    f = @memory.theme
    list = f.get_list
    assert_equal(true, list.include?("qwiksystem"))
    assert_equal(true, list.include?("qwikborder"))
    assert_equal(true, 4 <= list.length) # at least 4 themes
    assert_match(/<ul><li>/, "{{theme_list}}".w.html_p(@site))
  end

  def test_generator
    gen = Qwik::PageGenerator.new(@config, @memory)
    xml = gen.generate
    assert_equal(nil, xml.elements["//h1"].text)

    gen = Qwik::PageGenerator.new(@config, @memory)
    gen.update({:view_title => "t"})
    xml = gen.generate
#    puts xml.to_xhtml(0).u8tosjis
    assert_equal("t", xml.elements["//h1"].text)
  end
end
