sprite-factory 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,56 @@
1
+ require File.expand_path('../test_case', File.dirname(__FILE__))
2
+
3
+ module SpriteFactory
4
+ module Layout
5
+ class TestCase < SpriteFactory::TestCase
6
+
7
+ #==========================================================================
8
+ # layout test helpers
9
+ #==========================================================================
10
+
11
+ protected
12
+
13
+ def get_regular_images
14
+ return [
15
+ {:width => 20, :height => 10},
16
+ {:width => 20, :height => 10},
17
+ {:width => 20, :height => 10},
18
+ {:width => 20, :height => 10},
19
+ {:width => 20, :height => 10}
20
+ ]
21
+ end
22
+
23
+ def get_irregular_images
24
+ return [
25
+ {:width => 20, :height => 50},
26
+ {:width => 40, :height => 40},
27
+ {:width => 60, :height => 30},
28
+ {:width => 80, :height => 20},
29
+ {:width => 100, :height => 10}
30
+ ]
31
+ end
32
+
33
+ #--------------------------------------------------------------------------
34
+
35
+ def verify_layout(expected_width, expected_height, expected_images, images, options = {})
36
+ max = Layout.send(options[:layout] || :horizontal).layout(images, options)
37
+ assert_equal(expected_width, max[:width])
38
+ assert_equal(expected_height, max[:height])
39
+ assert_equal(expected_images.length, images.length)
40
+ images.length.times.each do |n|
41
+ expected = expected_images[n]
42
+ actual = images[n]
43
+ assert_equal(expected[:x], actual[:x], "image #{n} - unexpected x")
44
+ assert_equal(expected[:y], actual[:y], "image #{n} - unexpected y")
45
+ assert_equal(expected[:cssx] || expected[:x], actual[:cssx], "image #{n} - unexpected cssx")
46
+ assert_equal(expected[:cssy] || expected[:y], actual[:cssy], "image #{n} - unexpected cssy")
47
+ assert_equal(expected[:cssw] || actual[:width], actual[:cssw], "image #{n} - unexpected cssw")
48
+ assert_equal(expected[:cssh] || actual[:height], actual[:cssh], "image #{n} - unexpected cssh")
49
+ end
50
+ end
51
+
52
+ #--------------------------------------------------------------------------
53
+
54
+ end # class TestCase
55
+ end # module Layout
56
+ end # module SpriteFactory
@@ -0,0 +1,100 @@
1
+ require File.expand_path('test_case', File.dirname(__FILE__))
2
+
3
+ module SpriteFactory
4
+ module Layout
5
+ class VerticalTest < SpriteFactory::Layout::TestCase
6
+
7
+ #==========================================================================
8
+ # test REGULAR images
9
+ #==========================================================================
10
+
11
+ def test_vertical_layout_of_regular_images
12
+ images = get_regular_images
13
+ expected = [
14
+ { :x => 0, :y => 0 },
15
+ { :x => 0, :y => 10 },
16
+ { :x => 0, :y => 20 },
17
+ { :x => 0, :y => 30 },
18
+ { :x => 0, :y => 40 }
19
+ ]
20
+ verify_layout(20, 50, expected, images, :layout => :vertical)
21
+ end
22
+
23
+ #--------------------------------------------------------------------------
24
+
25
+ def test_padded_vertical_layout_of_regular_images
26
+ images = get_regular_images
27
+ expected = [
28
+ { :cssx => 0, :cssy => 0, :cssw => 40, :cssh => 50, :x => 10, :y => 20 },
29
+ { :cssx => 0, :cssy => 50, :cssw => 40, :cssh => 50, :x => 10, :y => 70 },
30
+ { :cssx => 0, :cssy => 100, :cssw => 40, :cssh => 50, :x => 10, :y => 120 },
31
+ { :cssx => 0, :cssy => 150, :cssw => 40, :cssh => 50, :x => 10, :y => 170 },
32
+ { :cssx => 0, :cssy => 200, :cssw => 40, :cssh => 50, :x => 10, :y => 220 }
33
+ ]
34
+ verify_layout(40, 250, expected, images, :layout => :vertical, :hpadding => 10, :vpadding => 20)
35
+ end
36
+
37
+ #--------------------------------------------------------------------------
38
+
39
+ def test_fixed_vertical_layout_of_regular_images
40
+ images = get_regular_images
41
+ expected = [
42
+ { :cssx => 0, :cssy => 0, :cssw => 50, :cssh => 50, :x => 15, :y => 20 },
43
+ { :cssx => 0, :cssy => 50, :cssw => 50, :cssh => 50, :x => 15, :y => 70 },
44
+ { :cssx => 0, :cssy => 100, :cssw => 50, :cssh => 50, :x => 15, :y => 120 },
45
+ { :cssx => 0, :cssy => 150, :cssw => 50, :cssh => 50, :x => 15, :y => 170 },
46
+ { :cssx => 0, :cssy => 200, :cssw => 50, :cssh => 50, :x => 15, :y => 220 }
47
+ ]
48
+ verify_layout(50, 250, expected, images, :layout => :vertical, :width => 50, :height => 50)
49
+ end
50
+
51
+ #==========================================================================
52
+ # test IRREGULAR images
53
+ #==========================================================================
54
+
55
+ def test_vertical_layout_of_irregular_images
56
+ images = get_irregular_images
57
+ expected = [
58
+ { :x => 40, :y => 0 },
59
+ { :x => 30, :y => 50 },
60
+ { :x => 20, :y => 90 },
61
+ { :x => 10, :y => 120 },
62
+ { :x => 0, :y => 140 }
63
+ ]
64
+ verify_layout(100, 150, expected, images, :layout => :vertical)
65
+ end
66
+
67
+ #--------------------------------------------------------------------------
68
+
69
+ def test_padded_vertical_layout_of_irregular_images
70
+ images = get_irregular_images
71
+ expected = [
72
+ { :cssx => 40, :cssy => 0, :cssw => 40, :cssh => 90, :x => 50, :y => 20 },
73
+ { :cssx => 30, :cssy => 90, :cssw => 60, :cssh => 80, :x => 40, :y => 110 },
74
+ { :cssx => 20, :cssy => 170, :cssw => 80, :cssh => 70, :x => 30, :y => 190 },
75
+ { :cssx => 10, :cssy => 240, :cssw => 100, :cssh => 60, :x => 20, :y => 260 },
76
+ { :cssx => 0, :cssy => 300, :cssw => 120, :cssh => 50, :x => 10, :y => 320 }
77
+ ]
78
+ verify_layout(120, 350, expected, images, :layout => :vertical, :hpadding => 10, :vpadding => 20)
79
+ end
80
+
81
+ #--------------------------------------------------------------------------
82
+
83
+ def test_fixed_vertical_layout_of_irregular_images
84
+ images = get_irregular_images
85
+ expected = [
86
+ { :cssx => 0, :cssy => 0, :cssw => 100, :cssh => 100, :x => 40, :y => 25 },
87
+ { :cssx => 0, :cssy => 100, :cssw => 100, :cssh => 100, :x => 30, :y => 130 },
88
+ { :cssx => 0, :cssy => 200, :cssw => 100, :cssh => 100, :x => 20, :y => 235 },
89
+ { :cssx => 0, :cssy => 300, :cssw => 100, :cssh => 100, :x => 10, :y => 340 },
90
+ { :cssx => 0, :cssy => 400, :cssw => 100, :cssh => 100, :x => 0, :y => 445 }
91
+ ]
92
+ verify_layout(100, 500, expected, images, :layout => :vertical, :width => 100, :height => 100)
93
+ end
94
+
95
+ #--------------------------------------------------------------------------
96
+
97
+ end # class VerticalTest
98
+ end # module Layout
99
+ end # module SpriteFactory
100
+
@@ -80,6 +80,13 @@ module SpriteFactory
80
80
  assert_match(msg, e.message) if msg
81
81
  end
82
82
 
83
+ def assert_not_implemented(msg = nil)
84
+ e = assert_raise NotImplementedError do
85
+ yield
86
+ end
87
+ assert_match(msg, e.message) if msg
88
+ end
89
+
83
90
  #----------------------------------------------------------------------------
84
91
 
85
92
  def assert_reference_image(name)
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
+ - 2
7
8
  - 0
8
- - 0
9
- version: 1.0.0
9
+ version: 1.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jake Gordon
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-04-29 00:00:00 -07:00
17
+ date: 2011-05-08 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -50,15 +50,18 @@ executables:
50
50
  - sf
51
51
  extensions: []
52
52
 
53
- extra_rdoc_files: []
54
-
53
+ extra_rdoc_files:
54
+ - README.md
55
55
  files:
56
+ - .gitignore
56
57
  - LICENSE
57
58
  - README.md
58
59
  - Rakefile
59
60
  - bin/sf
60
61
  - lib/sprite_factory.rb
61
- - lib/sprite_factory/layout.rb
62
+ - lib/sprite_factory/layout/horizontal.rb
63
+ - lib/sprite_factory/layout/packed.rb
64
+ - lib/sprite_factory/layout/vertical.rb
62
65
  - lib/sprite_factory/library/chunky_png.rb
63
66
  - lib/sprite_factory/library/rmagick.rb
64
67
  - lib/sprite_factory/runner.rb
@@ -88,6 +91,8 @@ files:
88
91
  - test/images/reference/irregular.fixed.png
89
92
  - test/images/reference/irregular.horizontal.css
90
93
  - test/images/reference/irregular.horizontal.png
94
+ - test/images/reference/irregular.packed.css
95
+ - test/images/reference/irregular.packed.png
91
96
  - test/images/reference/irregular.padded.css
92
97
  - test/images/reference/irregular.padded.png
93
98
  - test/images/reference/irregular.png
@@ -103,6 +108,8 @@ files:
103
108
  - test/images/reference/regular.fixed.png
104
109
  - test/images/reference/regular.horizontal.css
105
110
  - test/images/reference/regular.horizontal.png
111
+ - test/images/reference/regular.packed.css
112
+ - test/images/reference/regular.packed.png
106
113
  - test/images/reference/regular.padded.css
107
114
  - test/images/reference/regular.padded.png
108
115
  - test/images/reference/regular.png
@@ -118,7 +125,10 @@ files:
118
125
  - test/images/regular/regular4.png
119
126
  - test/images/regular/regular5.png
120
127
  - test/integration_test.rb
121
- - test/layout_test.rb
128
+ - test/layout/horizontal_test.rb
129
+ - test/layout/packed_test.rb
130
+ - test/layout/test_case.rb
131
+ - test/layout/vertical_test.rb
122
132
  - test/library_test.rb
123
133
  - test/runner_test.rb
124
134
  - test/style_test.rb
@@ -128,8 +138,8 @@ homepage: https://github.com/jakesgordon/sprite-factory
128
138
  licenses: []
129
139
 
130
140
  post_install_message:
131
- rdoc_options: []
132
-
141
+ rdoc_options:
142
+ - --charset=UTF-8
133
143
  require_paths:
134
144
  - lib
135
145
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -1,89 +0,0 @@
1
- module SpriteFactory
2
- module Layout
3
-
4
- #--------------------------------------------------------------------------
5
-
6
- def self.horizontal(images, options = {})
7
- width = options[:width]
8
- height = options[:height]
9
- hpadding = options[:hpadding] || 0
10
- vpadding = options[:vpadding] || 0
11
- max_height = height || ((2 * vpadding) + images.map{|i| i[:height]}.max)
12
- x = 0
13
- images.each do |i|
14
-
15
- if width
16
- i[:cssw] = width
17
- i[:cssx] = x
18
- i[:x] = x + (width - i[:width]) / 2
19
- else
20
- i[:cssw] = i[:width] + (2 * hpadding) # image width plus padding
21
- i[:cssx] = x # anchored at x
22
- i[:x] = i[:cssx] + hpadding # image drawn offset to account for padding
23
- end
24
-
25
- if height
26
- i[:cssh] = height
27
- i[:cssy] = 0
28
- i[:y] = 0 + (height - i[:height]) / 2
29
- else
30
- i[:cssh] = i[:height] + (2 * vpadding) # image height plus padding
31
- i[:cssy] = (max_height - i[:cssh]) / 2 # centered vertically
32
- i[:y] = i[:cssy] + vpadding # image drawn offset to account for padding
33
- end
34
-
35
- x = x + i[:cssw]
36
-
37
- end
38
- { :width => x, :height => max_height }
39
- end
40
-
41
- #--------------------------------------------------------------------------
42
-
43
- def self.vertical(images, options = {})
44
- width = options[:width]
45
- height = options[:height]
46
- hpadding = options[:hpadding] || 0
47
- vpadding = options[:vpadding] || 0
48
- max_width = width || ((2 * hpadding) + images.map{|i| i[:width]}.max)
49
- y = 0
50
- images.each do |i|
51
-
52
- if width
53
- i[:cssw] = width
54
- i[:cssx] = 0
55
- i[:x] = 0 + (width - i[:width]) / 2
56
- else
57
- i[:cssw] = i[:width] + (2 * hpadding) # image width plus padding
58
- i[:cssx] = (max_width - i[:cssw]) / 2 # centered horizontally
59
- i[:x] = i[:cssx] + hpadding # image drawn offset to account for padding
60
- end
61
-
62
- if height
63
- i[:cssh] = height
64
- i[:cssy] = y
65
- i[:y] = y + (height - i[:height]) / 2
66
- else
67
- i[:cssh] = i[:height] + (2 * vpadding) # image height plus padding
68
- i[:cssy] = y # anchored at y
69
- i[:y] = i[:cssy] + vpadding # image drawn offset to account for padding
70
- end
71
-
72
- y = y + i[:cssh]
73
-
74
- end
75
- { :width => max_width, :height => y }
76
- end
77
-
78
- #--------------------------------------------------------------------------
79
-
80
- def self.knapsack(images)
81
-
82
- raise NotImplementedError, "one day, when I have time, I'll do some kind of 'best-fit' algorithm"
83
-
84
- end
85
-
86
- #--------------------------------------------------------------------------
87
-
88
- end
89
- end
@@ -1,228 +0,0 @@
1
- require File.expand_path('test_case', File.dirname(__FILE__))
2
-
3
- module SpriteFactory
4
- class LayoutTest < SpriteFactory::TestCase
5
-
6
- #==========================================================================
7
- # test REGULAR images
8
- #==========================================================================
9
-
10
- def test_horizontal_layout_of_regular_images
11
- images = get_regular_images
12
- expected = [
13
- { :x => 0, :y => 0 },
14
- { :x => 20, :y => 0 },
15
- { :x => 40, :y => 0 },
16
- { :x => 60, :y => 0 },
17
- { :x => 80, :y => 0 }
18
- ]
19
- verify_layout(100, 10, expected, images, :layout => :horizontal)
20
- end
21
-
22
-
23
- #--------------------------------------------------------------------------
24
-
25
- def test_vertical_layout_of_regular_images
26
- images = get_regular_images
27
- expected = [
28
- { :x => 0, :y => 0 },
29
- { :x => 0, :y => 10 },
30
- { :x => 0, :y => 20 },
31
- { :x => 0, :y => 30 },
32
- { :x => 0, :y => 40 }
33
- ]
34
- verify_layout(20, 50, expected, images, :layout => :vertical)
35
- end
36
-
37
- #--------------------------------------------------------------------------
38
-
39
- def test_padded_horizontal_layout_of_regular_images
40
- images = get_regular_images
41
- expected = [
42
- { :cssx => 0, :cssy => 0, :cssw => 40, :cssh => 50, :x => 10, :y => 20 },
43
- { :cssx => 40, :cssy => 0, :cssw => 40, :cssh => 50, :x => 50, :y => 20 },
44
- { :cssx => 80, :cssy => 0, :cssw => 40, :cssh => 50, :x => 90, :y => 20 },
45
- { :cssx => 120, :cssy => 0, :cssw => 40, :cssh => 50, :x => 130, :y => 20 },
46
- { :cssx => 160, :cssy => 0, :cssw => 40, :cssh => 50, :x => 170, :y => 20 }
47
- ]
48
- verify_layout(200, 50, expected, images, :layout => :horizontal, :hpadding => 10, :vpadding => 20)
49
- end
50
-
51
- #--------------------------------------------------------------------------
52
-
53
- def test_padded_vertical_layout_of_regular_images
54
- images = get_regular_images
55
- expected = [
56
- { :cssx => 0, :cssy => 0, :cssw => 40, :cssh => 50, :x => 10, :y => 20 },
57
- { :cssx => 0, :cssy => 50, :cssw => 40, :cssh => 50, :x => 10, :y => 70 },
58
- { :cssx => 0, :cssy => 100, :cssw => 40, :cssh => 50, :x => 10, :y => 120 },
59
- { :cssx => 0, :cssy => 150, :cssw => 40, :cssh => 50, :x => 10, :y => 170 },
60
- { :cssx => 0, :cssy => 200, :cssw => 40, :cssh => 50, :x => 10, :y => 220 }
61
- ]
62
- verify_layout(40, 250, expected, images, :layout => :vertical, :hpadding => 10, :vpadding => 20)
63
- end
64
-
65
- #--------------------------------------------------------------------------
66
-
67
- def test_fixed_horizontal_layout_of_regular_images
68
- images = get_regular_images
69
- expected = [
70
- { :cssx => 0, :cssy => 0, :cssw => 50, :cssh => 50, :x => 15, :y => 20 },
71
- { :cssx => 50, :cssy => 0, :cssw => 50, :cssh => 50, :x => 65, :y => 20 },
72
- { :cssx => 100, :cssy => 0, :cssw => 50, :cssh => 50, :x => 115, :y => 20 },
73
- { :cssx => 150, :cssy => 0, :cssw => 50, :cssh => 50, :x => 165, :y => 20 },
74
- { :cssx => 200, :cssy => 0, :cssw => 50, :cssh => 50, :x => 215, :y => 20 }
75
- ]
76
- verify_layout(250, 50, expected, images, :layout => :horizontal, :width => 50, :height => 50)
77
- end
78
-
79
- #--------------------------------------------------------------------------
80
-
81
- def test_fixed_vertical_layout_of_regular_images
82
- images = get_regular_images
83
- expected = [
84
- { :cssx => 0, :cssy => 0, :cssw => 50, :cssh => 50, :x => 15, :y => 20 },
85
- { :cssx => 0, :cssy => 50, :cssw => 50, :cssh => 50, :x => 15, :y => 70 },
86
- { :cssx => 0, :cssy => 100, :cssw => 50, :cssh => 50, :x => 15, :y => 120 },
87
- { :cssx => 0, :cssy => 150, :cssw => 50, :cssh => 50, :x => 15, :y => 170 },
88
- { :cssx => 0, :cssy => 200, :cssw => 50, :cssh => 50, :x => 15, :y => 220 }
89
- ]
90
- verify_layout(50, 250, expected, images, :layout => :vertical, :width => 50, :height => 50)
91
- end
92
-
93
- #==========================================================================
94
- # test IRREGULAR images
95
- #==========================================================================
96
-
97
- def test_horizontal_layout_of_irregular_images
98
- images = get_irregular_images
99
- expected = [
100
- { :x => 0, :y => 0 },
101
- { :x => 20, :y => 5 },
102
- { :x => 60, :y => 10 },
103
- { :x => 120, :y => 15 },
104
- { :x => 200, :y => 20 }
105
- ]
106
- verify_layout(300, 50, expected, images, :layout => :horizontal)
107
- end
108
-
109
- #--------------------------------------------------------------------------
110
-
111
- def test_vertical_layout_of_irregular_images
112
- images = get_irregular_images
113
- expected = [
114
- { :x => 40, :y => 0 },
115
- { :x => 30, :y => 50 },
116
- { :x => 20, :y => 90 },
117
- { :x => 10, :y => 120 },
118
- { :x => 0, :y => 140 }
119
- ]
120
- verify_layout(100, 150, expected, images, :layout => :vertical)
121
- end
122
-
123
- #--------------------------------------------------------------------------
124
-
125
- def test_padded_horizontal_layout_of_irregular_images
126
- images = get_irregular_images
127
- expected = [
128
- { :cssx => 0, :cssy => 0, :cssw => 40, :cssh => 90, :x => 10, :y => 20 },
129
- { :cssx => 40, :cssy => 5, :cssw => 60, :cssh => 80, :x => 50, :y => 25 },
130
- { :cssx => 100, :cssy => 10, :cssw => 80, :cssh => 70, :x => 110, :y => 30 },
131
- { :cssx => 180, :cssy => 15, :cssw => 100, :cssh => 60, :x => 190, :y => 35 },
132
- { :cssx => 280, :cssy => 20, :cssw => 120, :cssh => 50, :x => 290, :y => 40 }
133
- ]
134
- verify_layout(400, 90, expected, images, :layout => :horizontal, :hpadding => 10, :vpadding => 20)
135
- end
136
-
137
- #--------------------------------------------------------------------------
138
-
139
- def test_padded_vertical_layout_of_irregular_images
140
- images = get_irregular_images
141
- expected = [
142
- { :cssx => 40, :cssy => 0, :cssw => 40, :cssh => 90, :x => 50, :y => 20 },
143
- { :cssx => 30, :cssy => 90, :cssw => 60, :cssh => 80, :x => 40, :y => 110 },
144
- { :cssx => 20, :cssy => 170, :cssw => 80, :cssh => 70, :x => 30, :y => 190 },
145
- { :cssx => 10, :cssy => 240, :cssw => 100, :cssh => 60, :x => 20, :y => 260 },
146
- { :cssx => 0, :cssy => 300, :cssw => 120, :cssh => 50, :x => 10, :y => 320 }
147
- ]
148
- verify_layout(120, 350, expected, images, :layout => :vertical, :hpadding => 10, :vpadding => 20)
149
- end
150
-
151
- #--------------------------------------------------------------------------
152
-
153
- def test_fixed_horizontal_layout_of_irregular_images
154
- images = get_irregular_images
155
- expected = [
156
- { :cssx => 0, :cssy => 0, :cssw => 100, :cssh => 100, :x => 40, :y => 25 },
157
- { :cssx => 100, :cssy => 0, :cssw => 100, :cssh => 100, :x => 130, :y => 30 },
158
- { :cssx => 200, :cssy => 0, :cssw => 100, :cssh => 100, :x => 220, :y => 35 },
159
- { :cssx => 300, :cssy => 0, :cssw => 100, :cssh => 100, :x => 310, :y => 40 },
160
- { :cssx => 400, :cssy => 0, :cssw => 100, :cssh => 100, :x => 400, :y => 45 }
161
- ]
162
- verify_layout(500, 100, expected, images, :layout => :horizontal, :width => 100, :height => 100)
163
- end
164
-
165
- #--------------------------------------------------------------------------
166
-
167
- def test_fixed_vertical_layout_of_irregular_images
168
- images = get_irregular_images
169
- expected = [
170
- { :cssx => 0, :cssy => 0, :cssw => 100, :cssh => 100, :x => 40, :y => 25 },
171
- { :cssx => 0, :cssy => 100, :cssw => 100, :cssh => 100, :x => 30, :y => 130 },
172
- { :cssx => 0, :cssy => 200, :cssw => 100, :cssh => 100, :x => 20, :y => 235 },
173
- { :cssx => 0, :cssy => 300, :cssw => 100, :cssh => 100, :x => 10, :y => 340 },
174
- { :cssx => 0, :cssy => 400, :cssw => 100, :cssh => 100, :x => 0, :y => 445 }
175
- ]
176
- verify_layout(100, 500, expected, images, :layout => :vertical, :width => 100, :height => 100)
177
- end
178
-
179
- #==========================================================================
180
- # private test helpers
181
- #==========================================================================
182
-
183
- private
184
-
185
- def get_regular_images
186
- return [
187
- {:width => 20, :height => 10},
188
- {:width => 20, :height => 10},
189
- {:width => 20, :height => 10},
190
- {:width => 20, :height => 10},
191
- {:width => 20, :height => 10}
192
- ]
193
- end
194
-
195
- def get_irregular_images
196
- return [
197
- {:width => 20, :height => 50},
198
- {:width => 40, :height => 40},
199
- {:width => 60, :height => 30},
200
- {:width => 80, :height => 20},
201
- {:width => 100, :height => 10}
202
- ]
203
- end
204
-
205
- #--------------------------------------------------------------------------
206
-
207
- def verify_layout(expected_width, expected_height, expected_images, images, options = {})
208
- max = Layout.send(options[:layout] || :horizontal, images, options)
209
- assert_equal(expected_width, max[:width])
210
- assert_equal(expected_height, max[:height])
211
- assert_equal(expected_images.length, images.length)
212
- images.length.times.each do |n|
213
- expected = expected_images[n]
214
- actual = images[n]
215
- assert_equal(expected[:x], actual[:x], "image #{n} - unexpected x")
216
- assert_equal(expected[:y], actual[:y], "image #{n} - unexpected y")
217
- assert_equal(expected[:cssx] || expected[:x], actual[:cssx], "image #{n} - unexpected cssx")
218
- assert_equal(expected[:cssy] || expected[:y], actual[:cssy], "image #{n} - unexpected cssy")
219
- assert_equal(expected[:cssw] || actual[:width], actual[:cssw], "image #{n} - unexpected cssw")
220
- assert_equal(expected[:cssh] || actual[:height], actual[:cssh], "image #{n} - unexpected cssh")
221
- end
222
- end
223
-
224
- #--------------------------------------------------------------------------
225
-
226
- end # class LayoutTest
227
- end # module SpriteFactory
228
-