diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/all.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/all.rs index bf0fefd6c0..0d8f617694 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/all.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/all.rs @@ -24,18 +24,16 @@ pub fn new_filter(filters: Vec) -> impl Filter { mod tests { use std::ops::Not; + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::new_rooms, *}; #[async_test] async fn test_one_filter() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; { let filter = |_: &_| true; @@ -54,8 +52,8 @@ mod tests { #[async_test] async fn test_two_filters() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; { let filter1 = |_: &_| true; diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/any.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/any.rs index 185b5a9825..86b0ecaf6a 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/any.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/any.rs @@ -24,18 +24,16 @@ pub fn new_filter(filters: Vec) -> impl Filter { mod tests { use std::ops::Not; + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::new_rooms, *}; #[async_test] async fn test_one_filter_is_true() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let filter = |_: &_| true; let any = new_filter(vec![Box::new(filter)]); @@ -45,8 +43,8 @@ mod tests { #[async_test] async fn test_one_filter_is_false() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let filter = |_: &_| false; let any = new_filter(vec![Box::new(filter)]); @@ -56,8 +54,8 @@ mod tests { #[async_test] async fn test_two_filters_with_true_true() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let filter1 = |_: &_| true; let filter2 = |_: &_| true; @@ -68,8 +66,8 @@ mod tests { #[async_test] async fn test_two_filters_with_true_false() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let filter1 = |_: &_| true; let filter2 = |_: &_| false; @@ -80,8 +78,8 @@ mod tests { #[async_test] async fn test_two_filters_with_false_true() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let filter1 = |_: &_| false; let filter2 = |_: &_| true; @@ -92,8 +90,8 @@ mod tests { #[async_test] async fn test_two_filters_with_false_false() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let filter1 = |_: &_| false; let filter2 = |_: &_| false; diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/category.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/category.rs index 288d0bc566..7937272050 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/category.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/category.rs @@ -79,18 +79,16 @@ pub fn new_filter(expected_category: RoomCategory) -> impl Filter { mod tests { use std::ops::Not; + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::new_rooms, *}; #[async_test] async fn test_kind_is_group() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let matcher = CategoryRoomMatcher { number_of_direct_targets: |_| Some(42) }; @@ -111,8 +109,8 @@ mod tests { #[async_test] async fn test_kind_is_people() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let matcher = CategoryRoomMatcher { number_of_direct_targets: |_| Some(1) }; @@ -133,8 +131,8 @@ mod tests { #[async_test] async fn test_room_kind_cannot_be_found() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let matcher = CategoryRoomMatcher { number_of_direct_targets: |_| None }; diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/favourite.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/favourite.rs index 6e18738435..279a939bf1 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/favourite.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/favourite.rs @@ -42,18 +42,16 @@ pub fn new_filter() -> impl Filter { mod tests { use std::ops::Not; + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::new_rooms, *}; #[async_test] async fn test_is_favourite() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let matcher = FavouriteRoomMatcher { is_favourite: |_| true }; @@ -62,8 +60,8 @@ mod tests { #[async_test] async fn test_is_not_favourite() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let matcher = FavouriteRoomMatcher { is_favourite: |_| false }; diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/invite.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/invite.rs index 8041c342c7..c8879f09f2 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/invite.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/invite.rs @@ -42,19 +42,17 @@ pub fn new_filter() -> impl Filter { #[cfg(test)] mod tests { + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_base::RoomState; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::new_rooms, *}; #[async_test] async fn test_all_invite_kind() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; // When a room has been left, it doesn't match. let matcher = InviteRoomMatcher { state: |_| RoomState::Left }; diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/joined.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/joined.rs index ee1c627788..b5ca056aa8 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/joined.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/joined.rs @@ -42,19 +42,17 @@ pub fn new_filter() -> impl Filter { #[cfg(test)] mod tests { + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_base::RoomState; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::new_rooms, *}; #[async_test] async fn test_all_joined_kind() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; // When a room has been left, it doesn't match. let matcher = JoinedRoomMatcher { state: |_| RoomState::Left }; diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/mod.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/mod.rs index 2eb01063da..881dbd6fad 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/mod.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/mod.rs @@ -64,9 +64,6 @@ mod normalized_match_room_name; mod not; mod unread; -#[cfg(test)] -use std::sync::Arc; - pub use all::new_filter as new_filter_all; pub use any::new_filter as new_filter_any; pub use category::{new_filter as new_filter_category, RoomCategory}; @@ -75,7 +72,7 @@ pub use fuzzy_match_room_name::new_filter as new_filter_fuzzy_match_room_name; pub use invite::new_filter as new_filter_invite; pub use joined::new_filter as new_filter_joined; #[cfg(test)] -use matrix_sdk::{test_utils::logged_in_client_with_server, Client, SlidingSync}; +use matrix_sdk::Client; #[cfg(test)] use matrix_sdk_test::{JoinedRoomBuilder, SyncResponseBuilder}; pub use non_left::new_filter as new_filter_non_left; @@ -116,7 +113,6 @@ pub(super) async fn new_rooms( room_ids: [&RoomId; N], client: &Client, server: &MockServer, - sliding_sync: &Arc, ) -> [Room; N] { let mut response_builder = SyncResponseBuilder::default(); @@ -135,15 +131,7 @@ pub(super) async fn new_rooms( let _response = client.sync_once(Default::default()).await.unwrap(); - room_ids.map(|room_id| Room::new(client.get_room(room_id).unwrap(), sliding_sync)) -} - -#[cfg(test)] -pub(super) async fn client_and_server_prelude() -> (Client, MockServer, Arc) { - let (client, server) = logged_in_client_with_server().await; - let sliding_sync = Arc::new(client.sliding_sync("foo").unwrap().build().await.unwrap()); - - (client, server, sliding_sync) + room_ids.map(|room_id| Room::new(client.get_room(room_id).unwrap())) } #[cfg(test)] diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/non_left.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/non_left.rs index 8f59575a78..e52c2c3db0 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/non_left.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/non_left.rs @@ -41,19 +41,17 @@ pub fn new_filter() -> impl Filter { #[cfg(test)] mod tests { + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_base::RoomState; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::new_rooms, *}; #[async_test] async fn test_all_non_left_kind_of_room_list_entry() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; // When a room has been left, it doesn't match. let matcher = NonLeftRoomMatcher { state: |_| RoomState::Left }; diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/none.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/none.rs index 3fe9f8aaab..e409462f97 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/none.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/none.rs @@ -23,18 +23,16 @@ pub fn new_filter() -> impl Filter { mod tests { use std::ops::Not; + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::new_rooms, *}; #[async_test] async fn test_all_kind_of_room_list_entry() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let none = new_filter(); diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/not.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/not.rs index c3b521ad69..9d70c12549 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/not.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/not.rs @@ -26,18 +26,16 @@ pub fn new_filter(filter: BoxedFilterFn) -> impl Filter { mod tests { use std::ops::Not; + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::new_rooms, *}; #[async_test] async fn test_true() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let filter = Box::new(|_: &_| true); let not = new_filter(filter); @@ -47,8 +45,8 @@ mod tests { #[async_test] async fn test_false() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let filter = Box::new(|_: &_| false); let not = new_filter(filter); diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/unread.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/unread.rs index a031c55a24..0d7885af31 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/unread.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/unread.rs @@ -50,19 +50,17 @@ pub fn new_filter() -> impl Filter { mod tests { use std::ops::Not; + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_base::read_receipts::RoomReadReceipts; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::new_rooms, *}; #[async_test] async fn test_has_unread_notifications() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; for is_marked_as_unread in [true, false] { let matcher = UnreadRoomMatcher { @@ -81,8 +79,8 @@ mod tests { #[async_test] async fn test_has_unread_messages_but_no_unread_notifications_and_is_not_marked_as_unread() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let matcher = UnreadRoomMatcher { read_receipts_and_unread: |_| { @@ -99,8 +97,8 @@ mod tests { #[async_test] async fn test_has_unread_messages_but_no_unread_notifications_and_is_marked_as_unread() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let matcher = UnreadRoomMatcher { read_receipts_and_unread: |_| { @@ -117,8 +115,8 @@ mod tests { #[async_test] async fn test_has_no_unread_notifications_and_is_not_marked_as_unread() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let matcher = UnreadRoomMatcher { read_receipts_and_unread: |_| (RoomReadReceipts::default(), false), @@ -129,8 +127,8 @@ mod tests { #[async_test] async fn test_has_no_unread_notifications_and_is_marked_as_unread() { - let (client, server, sliding_sync) = client_and_server_prelude().await; - let [room] = new_rooms([room_id!("!a:b.c")], &client, &server, &sliding_sync).await; + let (client, server) = logged_in_client_with_server().await; + let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await; let matcher = UnreadRoomMatcher { read_receipts_and_unread: |_| (RoomReadReceipts::default(), true) }; diff --git a/crates/matrix-sdk-ui/src/room_list_service/mod.rs b/crates/matrix-sdk-ui/src/room_list_service/mod.rs index 441c79944b..a389880db4 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/mod.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/mod.rs @@ -376,7 +376,6 @@ impl RoomListService { pub fn room(&self, room_id: &RoomId) -> Result { Ok(Room::new( self.client.get_room(room_id).ok_or_else(|| Error::RoomNotFound(room_id.to_owned()))?, - &self.sliding_sync, )) } diff --git a/crates/matrix-sdk-ui/src/room_list_service/room.rs b/crates/matrix-sdk-ui/src/room_list_service/room.rs index 72851ed3df..504f27684a 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/room.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/room.rs @@ -18,9 +18,7 @@ use core::fmt; use std::{ops::Deref, sync::Arc}; use async_once_cell::OnceCell as AsyncOnceCell; -use matrix_sdk::SlidingSync; use ruma::RoomId; -use tracing::info; use super::Error; use crate::{ @@ -43,9 +41,6 @@ impl fmt::Debug for Room { } struct RoomInner { - /// The Sliding Sync where everything comes from. - sliding_sync: Arc, - /// The underlying client room. room: matrix_sdk::Room, @@ -63,14 +58,8 @@ impl Deref for Room { impl Room { /// Create a new `Room`. - pub(super) fn new(room: matrix_sdk::Room, sliding_sync: &Arc) -> Self { - Self { - inner: Arc::new(RoomInner { - sliding_sync: sliding_sync.clone(), - room, - timeline: AsyncOnceCell::new(), - }), - } + pub(super) fn new(room: matrix_sdk::Room) -> Self { + Self { inner: Arc::new(RoomInner { room, timeline: AsyncOnceCell::new() }) } } /// Get the room ID. diff --git a/crates/matrix-sdk-ui/src/room_list_service/room_list.rs b/crates/matrix-sdk-ui/src/room_list_service/room_list.rs index 8056c14dac..2ec7168620 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/room_list.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/room_list.rs @@ -43,7 +43,6 @@ use super::{ #[derive(Debug)] pub struct RoomList { client: Client, - sliding_sync: Arc, sliding_sync_list: SlidingSyncList, loading_state: SharedObservable, loading_state_task: JoinHandle<()>, @@ -77,7 +76,6 @@ impl RoomList { Ok(Self { client: client.clone(), - sliding_sync: sliding_sync.clone(), sliding_sync_list: sliding_sync_list.clone(), loading_state: loading_state.clone(), loading_state_task: spawn(async move { @@ -124,7 +122,7 @@ impl RoomList { fn entries(&self) -> (Vector, impl Stream>> + '_) { let (rooms, stream) = self.client.rooms_stream(); - let map_room = |room| Room::new(room, &self.sliding_sync); + let map_room = |room| Room::new(room); ( rooms.into_iter().map(map_room).collect(), diff --git a/crates/matrix-sdk-ui/src/room_list_service/sorters/lexicographic.rs b/crates/matrix-sdk-ui/src/room_list_service/sorters/lexicographic.rs index 5b3048ef79..74e260c2aa 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/sorters/lexicographic.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/sorters/lexicographic.rs @@ -37,20 +37,17 @@ pub fn new_sorter(sorters: Vec) -> impl Sorter { #[cfg(test)] mod tests { + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::super::filters::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::super::filters::new_rooms, *}; #[async_test] async fn test_with_zero_sorter() { - let (client, server, sliding_sync) = client_and_server_prelude().await; + let (client, server) = logged_in_client_with_server().await; let [room_a, room_b] = - new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server, &sliding_sync) - .await; + new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server).await; let or = new_sorter(vec![]); @@ -59,10 +56,9 @@ mod tests { #[async_test] async fn test_with_one_sorter() { - let (client, server, sliding_sync) = client_and_server_prelude().await; + let (client, server) = logged_in_client_with_server().await; let [room_a, room_b] = - new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server, &sliding_sync) - .await; + new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server).await; let sorter_1 = |_: &_, _: &_| Ordering::Less; let or = new_sorter(vec![Box::new(sorter_1)]); @@ -72,10 +68,9 @@ mod tests { #[async_test] async fn test_with_two_sorters() { - let (client, server, sliding_sync) = client_and_server_prelude().await; + let (client, server) = logged_in_client_with_server().await; let [room_a, room_b] = - new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server, &sliding_sync) - .await; + new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server).await; let sorter_1 = |_: &_, _: &_| Ordering::Equal; let sorter_2 = |_: &_, _: &_| Ordering::Greater; @@ -86,10 +81,9 @@ mod tests { #[async_test] async fn test_with_more_sorters() { - let (client, server, sliding_sync) = client_and_server_prelude().await; + let (client, server) = logged_in_client_with_server().await; let [room_a, room_b] = - new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server, &sliding_sync) - .await; + new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server).await; let sorter_1 = |_: &_, _: &_| Ordering::Equal; let sorter_2 = |_: &_, _: &_| Ordering::Equal; diff --git a/crates/matrix-sdk-ui/src/room_list_service/sorters/name.rs b/crates/matrix-sdk-ui/src/room_list_service/sorters/name.rs index 17138480e8..1bcdaf0fa9 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/sorters/name.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/sorters/name.rs @@ -47,20 +47,17 @@ pub fn new_sorter() -> impl Sorter { #[cfg(test)] mod tests { + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::super::filters::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::super::filters::new_rooms, *}; #[async_test] async fn test_with_two_names() { - let (client, server, sliding_sync) = client_and_server_prelude().await; + let (client, server) = logged_in_client_with_server().await; let [room_a, room_b] = - new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server, &sliding_sync) - .await; + new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server).await; // `room_a` has a “greater name” than `room_b`. { @@ -92,10 +89,9 @@ mod tests { #[async_test] async fn test_with_one_name() { - let (client, server, sliding_sync) = client_and_server_prelude().await; + let (client, server) = logged_in_client_with_server().await; let [room_a, room_b] = - new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server, &sliding_sync) - .await; + new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server).await; // `room_a` has a name, `room_b` has no name. { @@ -114,10 +110,9 @@ mod tests { #[async_test] async fn test_with_zero_name() { - let (client, server, sliding_sync) = client_and_server_prelude().await; + let (client, server) = logged_in_client_with_server().await; let [room_a, room_b] = - new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server, &sliding_sync) - .await; + new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server).await; // `room_a` and `room_b` has no name. { diff --git a/crates/matrix-sdk-ui/src/room_list_service/sorters/recency.rs b/crates/matrix-sdk-ui/src/room_list_service/sorters/recency.rs index c15a46d504..82d8936083 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/sorters/recency.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/sorters/recency.rs @@ -76,20 +76,17 @@ pub fn new_sorter() -> impl Sorter { #[cfg(test)] mod tests { + use matrix_sdk::test_utils::logged_in_client_with_server; use matrix_sdk_test::async_test; use ruma::room_id; - use super::{ - super::super::filters::{client_and_server_prelude, new_rooms}, - *, - }; + use super::{super::super::filters::new_rooms, *}; #[async_test] async fn test_with_two_recency_stamps() { - let (client, server, sliding_sync) = client_and_server_prelude().await; + let (client, server) = logged_in_client_with_server().await; let [room_a, room_b] = - new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server, &sliding_sync) - .await; + new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server).await; // `room_a` has an older recency stamp than `room_b`. { @@ -117,10 +114,9 @@ mod tests { #[async_test] async fn test_with_one_recency_stamp() { - let (client, server, sliding_sync) = client_and_server_prelude().await; + let (client, server) = logged_in_client_with_server().await; let [room_a, room_b] = - new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server, &sliding_sync) - .await; + new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server).await; // `room_a` has a recency stamp, `room_b` has no recency stamp. { @@ -139,10 +135,9 @@ mod tests { #[async_test] async fn test_with_zero_recency_stamp() { - let (client, server, sliding_sync) = client_and_server_prelude().await; + let (client, server) = logged_in_client_with_server().await; let [room_a, room_b] = - new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server, &sliding_sync) - .await; + new_rooms([room_id!("!a:b.c"), room_id!("!d:e.f")], &client, &server).await; // `room_a` and `room_b` has no recency stamp. {