X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=spec%2Fspec_helper.rb;h=876f1d459c011efe22acd8dc12fb5f7a7dae8d3e;hb=8ab521b2e55858851de2ee5bd00b50792529c444;hp=bbfe1a5ff26739e6ad08d05af6c9be93c212ff0c;hpb=9188f342f67f399dbb7857dd1970ab44a8c24138;p=swftools.git diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bbfe1a5..876f1d4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -56,6 +56,10 @@ class Area text2 = @file.get_text(@x1,@y1,@x2,@y2) text2 == text or raise AreaError.new(self, "doesn't contain text \"#{text}\" (found: \"#{text2}\")") end + def should_contain_link(url) + links = @file.get_links(@x1,@y1,@x2,@y2) + (links & [url]) or raise AreaError.new(self, "doesn't contain url \"#{url}\") + end def to_s "(#{@x1},#{@y1},#{@x2},#{@y2})" end @@ -112,7 +116,7 @@ class DocFile `pdfinfo #{@filename}` =~ /Page size:\s*([0-9]+) x ([0-9]+) pts/ width,height = $1,$2 dpi = (72.0 * 612 / width.to_i).to_i - output = `pdf2swf --flatten -s zoom=#{dpi} -p #{@page} #{@filename} -o #{@swfname} 2>&1` + output = `pdf2swf -f --flatten -s zoom=#{dpi} -p #{@page} #{@filename} -o #{@swfname} 2>&1` #output = `pdf2swf -s zoom=#{dpi} --flatten -p #{@page} #{@filename} -o #{@swfname} 2>&1` raise ConversionFailed.new(output,@swfname) unless File.exists?(@swfname) end @@ -134,6 +138,10 @@ class DocFile #puts `swfstrings -x #{x1} -y #{y1} -W #{x2-x1} -H #{y2-y1} #{@swfname}` `swfstrings -x #{x1} -y #{y1} -W #{x2-x1} -H #{y2-y1} #{@swfname}`.chomp end + def get_links(x1,y1,x2,y2) + self.convert() + `swfdump -a #{@swfname}`.scan(/GetUrl2? URL:"([^"]*)"/).inject([]) do |a,u| a + u end + end def get_area(x1,y1,x2,y2) self.render() data = @img.export_pixels(x1, y1, x2-x1, y2-y1, "RGB")