add some interactive tests for the vertial crop operations

This commit is contained in:
Corey O'Connor 2013-08-13 14:53:40 -06:00
parent e73ed60271
commit 5fb702eeb1
2 changed files with 108 additions and 1 deletions

View File

@ -22,7 +22,7 @@ random_picture = pic_for_image <$> random_image
bench_0 = do
vty <- mkVty
DisplayRegion w h <- display_bounds $ terminal vty
let pictures = replicateM 100 random_picture
let pictures = replicateM 3000 random_picture
bench ps = do
forM ps (update vty)
shutdown vty

View File

@ -173,6 +173,10 @@ all_tests
, inline_test_1
, inline_test_2
, cursor_hide_test_0
, vert_crop_test_0
, vert_crop_test_1
, vert_crop_test_2
, vert_crop_test_3
]
reserve_output_test = Test
@ -946,3 +950,106 @@ cursor_hide_test_0 = Test
, confirm_results = generic_output_match_confirm
}
output_image_and_wait :: Image -> IO ()
output_image_and_wait image = do
t <- current_terminal
reserve_display t
let pic = pic_for_image image
d <- display_bounds t >>= display_context t
output_picture d pic
getLine
release_display t
release_terminal t
return ()
vert_crop_test_0 :: Test
vert_crop_test_0 = Test
{ test_name = "Verify bottom cropping works as expected with single column chars"
, test_ID = "crop_test_0"
, test_action = do
let block_0 = crop_bottom 2 $ vert_cat $ map (string def_attr) lorum_ipsum
block_1 = vert_cat $ map (string def_attr) $ take 2 lorum_ipsum
image = block_0 <-> background_fill 10 2 <-> block_1
output_image_and_wait image
, print_summary = putStr $ [s|
1. Verify the two text blocks are identical.
2. press enter.
3. the display should return to the state before the test.
|]
, confirm_results = generic_output_match_confirm
}
vert_crop_test_1 :: Test
vert_crop_test_1 = Test
{ test_name = "Verify bottom cropping works as expected with double column chars"
, test_ID = "crop_test_0"
, test_action = do
let block_0 = crop_bottom 2 $ vert_cat $ map (string def_attr) lorum_ipsum_chinese
block_1 = vert_cat $ map (string def_attr) $ take 2 lorum_ipsum_chinese
image = block_0 <-> background_fill 10 2 <-> block_1
output_image_and_wait image
, print_summary = putStr $ [s|
1. Verify the two text blocks are identical.
2. press enter.
3. the display should return to the state before the test.
|]
, confirm_results = generic_output_match_confirm
}
vert_crop_test_2 :: Test
vert_crop_test_2 = Test
{ test_name = "Verify top cropping works as expected with single column chars"
, test_ID = "crop_test_0"
, test_action = do
let block_0 = crop_top 2 $ vert_cat $ map (string def_attr) lorum_ipsum
block_1 = vert_cat $ map (string def_attr) $ drop (length lorum_ipsum - 2) lorum_ipsum
image = block_0 <-> background_fill 10 2 <-> block_1
output_image_and_wait image
, print_summary = putStr $ [s|
1. Verify the two text blocks are identical.
2. press enter.
3. the display should return to the state before the test.
|]
, confirm_results = generic_output_match_confirm
}
vert_crop_test_3 :: Test
vert_crop_test_3 = Test
{ test_name = "Verify top cropping works as expected with double column chars"
, test_ID = "crop_test_0"
, test_action = do
let block_0 = crop_top 2 $ vert_cat $ map (string def_attr) lorum_ipsum_chinese
block_1 = vert_cat $ map (string def_attr) $ drop (length lorum_ipsum_chinese - 2 ) lorum_ipsum_chinese
image = block_0 <-> background_fill 10 2 <-> block_1
output_image_and_wait image
, print_summary = putStr $ [s|
1. Verify the two text blocks are identical.
2. press enter.
3. the display should return to the state before the test.
|]
, confirm_results = generic_output_match_confirm
}
lorum_ipsum :: [String]
lorum_ipsum = lines [s|
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium,
totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae
dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit,
sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam
est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius
modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima
veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea
commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil
molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
|]
lorum_ipsum_chinese :: [String]
lorum_ipsum_chinese = lines [s|
, ,
,
, ,
,
觿,
|]