on master help sign in
add another test of layer support. Animate an image over another
00ad570Corey O'Connor
test/interactive_terminal_test.hs+41−1
@@ -9,6 +9,7 @@ import Graphics.Vty.Picture
9import Graphics.Vty.Terminal
9import Graphics.Vty.Terminal
10import Graphics.Vty.DisplayRegion
10import Graphics.Vty.DisplayRegion
11
11
12+import Control.Concurrent (threadDelay)
12import Control.Exception
13import Control.Exception
13import Control.Monad
14import Control.Monad
14
15
@@ -182,6 +183,7 @@ all_tests
182 , horiz_crop_test_2
183 , horiz_crop_test_2
183 , horiz_crop_test_3
184 , horiz_crop_test_3
184 , layer_0
185 , layer_0
186+ , layer_1
185 ]
187 ]
186
188
187reserve_output_test = Test
189reserve_output_test = Test
@@ -1117,10 +1119,48 @@ layer_0 = Test
1117 p = pic_for_layers [upper_image, lower_image]
1119 p = pic_for_layers [upper_image, lower_image]
1118 output_pic_and_wait p
1120 output_pic_and_wait p
1119 , print_summary = putStr $ [s|
1121 , print_summary = putStr $ [s|
1122+ 1. Verify the text block appears to be Chinese text placed on top Latin text.
1123+ 2. press enter.
1124+ 3. the display should return to the state before the test.
1120|]
1125|]
1121 , confirm_results = generic_output_match_confirm
1126 , confirm_results = generic_output_match_confirm
1122 }
1127 }
1123−
1128+
1129+layer_1 :: Test
1130+layer_1 = Test
1131+ { test_name = "verify layer 1"
1132+ , test_ID = "layer_1"
1133+ , test_action = do
1134+ let upper_image = vert_cat $ map (string def_attr) lorum_ipsum_chinese
1135+ block = resize 10 10 upper_image
1136+ layer_0 = vert_cat $ map (string def_attr) lorum_ipsum
1137+ layer_1 = char_fill (def_attr `with_back_color` blue) '#' 1000 1000
1138+ cheesy_anim_0 block [layer_0, layer_1]
1139+ , print_summary = putStr $ [s|
1140+ 1. Verify the text block appears to be Chinese text moving on top a Latin text.
1141+ Which is all on a background of '#' characters over blue.
1142+ 2. press enter.
1143+ 3. the display should return to the state before the test.
1144+|]
1145+ , confirm_results = generic_output_match_confirm
1146+ }
1147+
1148+cheesy_anim_0 :: Image -> [Image] -> IO ()
1149+cheesy_anim_0 i background = do
1150+ t <- current_terminal
1151+ reserve_display t
1152+ bounds <- display_bounds t
1153+ d <- display_context t bounds
1154+ forM_ [0..100] $ \t -> do
1155+ let i_offset = translate (t `mod` region_width bounds)
1156+ (t `div` 2 `mod` region_height bounds)
1157+ i
1158+ let pic = pic_for_layers $ i_offset : background
1159+ output_picture d pic
1160+ threadDelay 50000
1161+ release_display t
1162+ release_terminal t
1163+ return ()
1124
1164
1125lorum_ipsum :: [String]
1165lorum_ipsum :: [String]
1126lorum_ipsum = lines [s|
1166lorum_ipsum = lines [s|