@@ -1732,6 +1732,7 @@ pub async fn dc_empty_server(context: &Context, flags: u32) {
1732
1732
#[ cfg( test) ]
1733
1733
mod tests {
1734
1734
use super :: * ;
1735
+ use crate :: chat:: ChatItem ;
1735
1736
use crate :: test_utils as test;
1736
1737
1737
1738
#[ test]
@@ -1874,4 +1875,35 @@ mod tests {
1874
1875
assert_eq ! ( webrtc_type, VideochatType :: Jitsi ) ;
1875
1876
assert_eq ! ( url, "https://j.si/foo" ) ;
1876
1877
}
1878
+
1879
+ #[ async_std:: test]
1880
+ async fn test_get_width_height ( ) {
1881
+ let t = test:: TestContext :: new ( ) . await ;
1882
+
1883
+ // test that get_width() and get_height() are returning some dimensions for images;
1884
+ // (as the device-chat contains a welcome-images, we check that)
1885
+ t. ctx . update_device_chats ( ) . await . ok ( ) ;
1886
+ let ( device_chat_id, _) =
1887
+ chat:: create_or_lookup_by_contact_id ( & t. ctx , DC_CONTACT_ID_DEVICE , Blocked :: Not )
1888
+ . await
1889
+ . unwrap ( ) ;
1890
+
1891
+ let mut has_image = false ;
1892
+ let chatitems = chat:: get_chat_msgs ( & t. ctx , device_chat_id, 0 , None ) . await ;
1893
+ for chatitem in chatitems {
1894
+ if let ChatItem :: Message { msg_id } = chatitem {
1895
+ if let Ok ( msg) = Message :: load_from_db ( & t. ctx , msg_id. clone ( ) ) . await {
1896
+ if msg. get_viewtype ( ) == Viewtype :: Image {
1897
+ has_image = true ;
1898
+ // just check that width/height are inside some reasonable ranges
1899
+ assert ! ( msg. get_width( ) > 100 ) ;
1900
+ assert ! ( msg. get_height( ) > 100 ) ;
1901
+ assert ! ( msg. get_width( ) < 4000 ) ;
1902
+ assert ! ( msg. get_height( ) < 4000 ) ;
1903
+ }
1904
+ }
1905
+ }
1906
+ }
1907
+ assert ! ( has_image) ;
1908
+ }
1877
1909
}
0 commit comments