@@ -16,16 +16,13 @@ use assert_matches::assert_matches;
16
16
use assert_matches2:: assert_let;
17
17
use eyeball_im:: VectorDiff ;
18
18
use matrix_sdk:: test_utils:: events:: EventFactory ;
19
- use matrix_sdk_base:: deserialized_responses:: SyncTimelineEvent ;
20
19
use matrix_sdk_test:: { async_test, sync_timeline_event, ALICE , BOB , CAROL } ;
21
20
use ruma:: {
22
- assign,
23
21
events:: {
24
22
receipt:: { Receipt , ReceiptThread , ReceiptType } ,
25
- relation:: { InReplyTo , Thread } ,
26
23
room:: {
27
24
member:: { MembershipState , RedactedRoomMemberEventContent , RoomMemberEventContent } ,
28
- message:: { MessageType , Relation , RoomMessageEventContent } ,
25
+ message:: { MessageType , RoomMessageEventContent } ,
29
26
name:: RoomNameEventContent ,
30
27
topic:: RedactedRoomTopicEventContent ,
31
28
} ,
@@ -48,21 +45,11 @@ async fn test_initial_events() {
48
45
let timeline = TestTimeline :: new ( ) ;
49
46
let mut stream = timeline. subscribe ( ) . await ;
50
47
48
+ let f = EventFactory :: new ( ) ;
51
49
timeline
52
50
. inner
53
51
. add_events_at (
54
- vec ! [
55
- SyncTimelineEvent :: new(
56
- timeline
57
- . event_builder
58
- . make_sync_message_event( * ALICE , RoomMessageEventContent :: text_plain( "A" ) ) ,
59
- ) ,
60
- SyncTimelineEvent :: new(
61
- timeline
62
- . event_builder
63
- . make_sync_message_event( * BOB , RoomMessageEventContent :: text_plain( "B" ) ) ,
64
- ) ,
65
- ] ,
52
+ vec ! [ f. text_msg( "A" ) . sender( * ALICE ) , f. text_msg( "B" ) . sender( * BOB ) ] ,
66
53
TimelineEnd :: Back ,
67
54
RemoteEventOrigin :: Sync ,
68
55
)
@@ -393,10 +380,11 @@ async fn test_sanitized() {
393
380
let timeline = TestTimeline :: new ( ) ;
394
381
let mut stream = timeline. subscribe ( ) . await ;
395
382
383
+ let f = EventFactory :: new ( ) ;
384
+
396
385
timeline
397
- . handle_live_message_event (
398
- & ALICE ,
399
- RoomMessageEventContent :: text_html (
386
+ . handle_live_event (
387
+ f. text_html (
400
388
"\
401
389
@@Unknown text@@
402
390
Some text\n \n \
@@ -409,7 +397,8 @@ async fn test_sanitized() {
409
397
<p>Some text</p>\
410
398
<code unknown=\" code\" >Some code</code>\
411
399
",
412
- ) ,
400
+ )
401
+ . sender ( & ALICE ) ,
413
402
)
414
403
. await ;
415
404
@@ -435,12 +424,8 @@ async fn test_reply() {
435
424
let timeline = TestTimeline :: new ( ) ;
436
425
let mut stream = timeline. subscribe ( ) . await ;
437
426
438
- timeline
439
- . handle_live_message_event (
440
- & ALICE ,
441
- RoomMessageEventContent :: text_plain ( "I want you to reply" ) ,
442
- )
443
- . await ;
427
+ let f = EventFactory :: new ( ) ;
428
+ timeline. handle_live_event ( f. text_msg ( "I want you to reply" ) . sender ( & ALICE ) ) . await ;
444
429
445
430
let item = assert_next_matches ! ( stream, VectorDiff :: PushBack { value } => value) ;
446
431
let first_event = item. as_event ( ) . unwrap ( ) ;
@@ -466,13 +451,12 @@ async fn test_reply() {
466
451
"> <{first_event_sender}> I want you to reply\n \
467
452
I'm replying!"
468
453
) ;
469
- let reply = assign ! ( RoomMessageEventContent :: text_html( reply_plain, reply_formatted_body) , {
470
- relates_to: Some ( Relation :: Reply {
471
- in_reply_to: InReplyTo :: new( first_event_id. to_owned( ) ) ,
472
- } ) ,
473
- } ) ;
474
454
475
- timeline. handle_live_message_event ( & BOB , reply) . await ;
455
+ timeline
456
+ . handle_live_event (
457
+ f. text_html ( reply_plain, reply_formatted_body) . reply_to ( first_event_id) . sender ( & BOB ) ,
458
+ )
459
+ . await ;
476
460
477
461
let item = assert_next_matches ! ( stream, VectorDiff :: PushBack { value } => value) ;
478
462
assert_let ! ( TimelineItemContent :: Message ( message) = item. as_event( ) . unwrap( ) . content( ) ) ;
@@ -492,12 +476,8 @@ async fn test_thread() {
492
476
let timeline = TestTimeline :: new ( ) ;
493
477
let mut stream = timeline. subscribe ( ) . await ;
494
478
495
- timeline
496
- . handle_live_message_event (
497
- & ALICE ,
498
- RoomMessageEventContent :: text_plain ( "I want you to reply" ) ,
499
- )
500
- . await ;
479
+ let f = EventFactory :: new ( ) ;
480
+ timeline. handle_live_event ( f. text_msg ( "I want you to reply" ) . sender ( & ALICE ) ) . await ;
501
481
502
482
let item = assert_next_matches ! ( stream, VectorDiff :: PushBack { value } => value) ;
503
483
let first_event = item. as_event ( ) . unwrap ( ) ;
@@ -506,13 +486,13 @@ async fn test_thread() {
506
486
let day_divider = assert_next_matches ! ( stream, VectorDiff :: PushFront { value } => value) ;
507
487
assert ! ( day_divider. is_day_divider( ) ) ;
508
488
509
- let reply = assign ! ( RoomMessageEventContent :: text_plain ( "I'm replying in a thread" ) , {
510
- relates_to : Some ( Relation :: Thread (
511
- Thread :: plain ( first_event_id . to_owned ( ) , first_event_id . to_owned ( ) ) ,
512
- ) )
513
- } ) ;
514
-
515
- timeline . handle_live_message_event ( & BOB , reply ) . await ;
489
+ timeline
490
+ . handle_live_event (
491
+ f . text_msg ( "I'm replying in a thread" )
492
+ . sender ( & BOB )
493
+ . in_thread ( first_event_id , first_event_id ) ,
494
+ )
495
+ . await ;
516
496
517
497
let item = assert_next_matches ! ( stream, VectorDiff :: PushBack { value } => value) ;
518
498
assert_let ! ( TimelineItemContent :: Message ( message) = item. as_event( ) . unwrap( ) . content( ) ) ;
0 commit comments