#!/usr/bin/env ruby
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/test-common"

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

  def copy_all
    pages = []
    src  = @org_data_dir.path+"eto.com"
    dest = @dir
    return nil unless src.exist?
    src.each_entry {|file|
      if /\A\d\d\d\d\.txt\z/ =~ file.to_s
	str = (src+file).read
	(dest+file).open("wb"){|f| f.print str }
	base = file.to_s.sub(".txt", "")
	pages << base
      end
    }
    pages
  end

  def nutest_0008
    copy_all
    t_add_user
    session("/test/0008.html")
    body = @res.body.format_xml
  end

  def test_bench
    repeat = 1
    pages = copy_all
    return if pages.nil?
    t_add_user
    repeat.times {
      pages.each {|base|
#	qp base
	session("/test/#{base}.html")
	body = @res.body.format_xml
      }
    }
  end
end
