tests.rs

 1use std::sync::Arc;
 2
 3use call::Room;
 4use client::ChannelId;
 5use gpui::{Entity, TestAppContext};
 6
 7mod channel_buffer_tests;
 8mod channel_guest_tests;
 9mod channel_tests;
10mod editor_tests;
11mod following_tests;
12mod git_tests;
13mod integration_tests;
14mod notification_tests;
15mod random_channel_buffer_tests;
16mod random_project_collaboration_tests;
17mod randomized_test_helpers;
18mod remote_editing_collaboration_tests;
19mod test_server;
20
21use language::{Language, LanguageConfig, LanguageMatcher, tree_sitter_rust};
22pub use randomized_test_helpers::{
23    RandomizedTest, TestError, UserTestPlan, run_randomized_test, save_randomized_test_plan,
24};
25pub use test_server::{TestClient, TestServer};
26
27#[derive(Debug, Eq, PartialEq)]
28struct RoomParticipants {
29    remote: Vec<String>,
30    pending: Vec<String>,
31}
32
33fn room_participants(room: &Entity<Room>, cx: &mut TestAppContext) -> RoomParticipants {
34    room.read_with(cx, |room, _| {
35        let mut remote = room
36            .remote_participants()
37            .values()
38            .map(|participant| participant.user.github_login.clone().to_string())
39            .collect::<Vec<_>>();
40        let mut pending = room
41            .pending_participants()
42            .iter()
43            .map(|user| user.github_login.clone().to_string())
44            .collect::<Vec<_>>();
45        remote.sort();
46        pending.sort();
47        RoomParticipants { remote, pending }
48    })
49}
50
51fn channel_id(room: &Entity<Room>, cx: &mut TestAppContext) -> Option<ChannelId> {
52    cx.read(|cx| room.read(cx).channel_id())
53}
54
55fn rust_lang() -> Arc<Language> {
56    Arc::new(Language::new(
57        LanguageConfig {
58            name: "Rust".into(),
59            matcher: LanguageMatcher {
60                path_suffixes: vec!["rs".to_string()],
61                ..Default::default()
62            },
63            ..Default::default()
64        },
65        Some(tree_sitter_rust::LANGUAGE.into()),
66    ))
67}