on master help sign in
yet more tests of cropping
commitb21f019794541e18ee2fc8f349ba5beb44d7b096 authorCorey O'Connor <corey@ooyala.com> dateTue 13 Aug 2013, 00:41 (13 years ago) parentc998873
1 file changed+24
test/VerifySpanOps.hs+24
test/VerifySpanOps.hs+24
@@ -185,6 +185,26 @@ crop_top_output_rows = height_crop_output_columns crop_top
185185crop_bottom_output_rows :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
186186crop_bottom_output_rows = height_crop_output_columns crop_bottom
187187
188+crop_right_and_left_rejoined_equivalence :: SingleAttrSingleSpanStack -> Property
189+crop_right_and_left_rejoined_equivalence stack = image_width (stack_image stack) `mod` 2 == 0 ==>
190+ let i = stack_image stack
191+ -- the right part is made by cropping the image from the left.
192+ i_r = crop_left (image_width i `div` 2) i
193+ -- the left part is made by cropping the image from the right
194+ i_l = crop_right (image_width i `div` 2) i
195+ i_alt = i_l <|> i_r
196+ in display_ops_for_image i == display_ops_for_image i_alt
197+
198+crop_top_and_bottom_rejoined_equivalence :: SingleAttrSingleSpanStack -> Property
199+crop_top_and_bottom_rejoined_equivalence stack = image_height (stack_image stack) `mod` 2 == 0 ==>
200+ let i = stack_image stack
201+ -- the top part is made by cropping the image from the bottom.
202+ i_t = crop_bottom (image_height i `div` 2) i
203+ -- the bottom part is made by cropping the image from the top.
204+ i_b = crop_top (image_height i `div` 2) i
205+ i_alt = i_t <-> i_b
206+ in display_ops_for_image i == display_ops_for_image i_alt
207+
188208image_coverage_matches_bounds :: Image -> Result
189209image_coverage_matches_bounds i =
190210 let p = pic_for_image i
@@ -228,6 +248,10 @@ tests = return
228248 crop_left_output_columns
229249 , verify "cropping from the right produces display operations covering the expected columns"
230250 crop_right_output_columns
251+ , verify "the output of a stack is the same as that stack cropped left & right and joined together"
252+ crop_right_and_left_rejoined_equivalence
253+ , verify "the output of a stack is the same as that stack cropped top & bottom and joined together"
254+ crop_top_and_bottom_rejoined_equivalence
231255 , verify "an arbitrary image when rendered to a window of the same size will cover the entire window"
232256 image_coverage_matches_bounds
233257 ]