1use crate::{
2 db::{tests::TestDb, NewUserParams, UserId},
3 executor::Executor,
4 rpc::{Server, CLEANUP_TIMEOUT, RECONNECT_TIMEOUT},
5 AppState, Config,
6};
7use anyhow::anyhow;
8use call::ActiveCall;
9use channel::{ChannelBuffer, ChannelStore};
10use client::{
11 self, proto::PeerId, Client, Connection, Credentials, EstablishConnectionError, UserStore,
12};
13use collections::{HashMap, HashSet};
14use fs::FakeFs;
15use futures::{channel::oneshot, StreamExt as _};
16use gpui::{BackgroundExecutor, Context, Model, Task, TestAppContext, View, VisualTestContext};
17use language::LanguageRegistry;
18use node_runtime::FakeNodeRuntime;
19
20use notifications::NotificationStore;
21use parking_lot::Mutex;
22use project::{Project, WorktreeId};
23use rpc::{
24 proto::{self, ChannelRole},
25 RECEIVE_TIMEOUT,
26};
27use serde_json::json;
28use settings::SettingsStore;
29use std::{
30 cell::{Ref, RefCell, RefMut},
31 env,
32 ops::{Deref, DerefMut},
33 path::Path,
34 sync::{
35 atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst},
36 Arc,
37 },
38};
39use util::{http::FakeHttpClient, SemanticVersion};
40use workspace::{Workspace, WorkspaceStore};
41
42pub struct TestServer {
43 pub app_state: Arc<AppState>,
44 pub test_live_kit_server: Arc<live_kit_client::TestServer>,
45 server: Arc<Server>,
46 next_github_user_id: i32,
47 connection_killers: Arc<Mutex<HashMap<PeerId, Arc<AtomicBool>>>>,
48 forbid_connections: Arc<AtomicBool>,
49 _test_db: TestDb,
50}
51
52pub struct TestClient {
53 pub username: String,
54 pub app_state: Arc<workspace::AppState>,
55 channel_store: Model<ChannelStore>,
56 notification_store: Model<NotificationStore>,
57 state: RefCell<TestClientState>,
58}
59
60#[derive(Default)]
61struct TestClientState {
62 local_projects: Vec<Model<Project>>,
63 remote_projects: Vec<Model<Project>>,
64 buffers: HashMap<Model<Project>, HashSet<Model<language::Buffer>>>,
65 channel_buffers: HashSet<Model<ChannelBuffer>>,
66}
67
68pub struct ContactsSummary {
69 pub current: Vec<String>,
70 pub outgoing_requests: Vec<String>,
71 pub incoming_requests: Vec<String>,
72}
73
74impl TestServer {
75 pub async fn start(deterministic: BackgroundExecutor) -> Self {
76 static NEXT_LIVE_KIT_SERVER_ID: AtomicUsize = AtomicUsize::new(0);
77
78 let use_postgres = env::var("USE_POSTGRES").ok();
79 let use_postgres = use_postgres.as_deref();
80 let test_db = if use_postgres == Some("true") || use_postgres == Some("1") {
81 TestDb::postgres(deterministic.clone())
82 } else {
83 TestDb::sqlite(deterministic.clone())
84 };
85 let live_kit_server_id = NEXT_LIVE_KIT_SERVER_ID.fetch_add(1, SeqCst);
86 let live_kit_server = live_kit_client::TestServer::create(
87 format!("http://livekit.{}.test", live_kit_server_id),
88 format!("devkey-{}", live_kit_server_id),
89 format!("secret-{}", live_kit_server_id),
90 deterministic.clone(),
91 )
92 .unwrap();
93 let app_state = Self::build_app_state(&test_db, &live_kit_server).await;
94 let epoch = app_state
95 .db
96 .create_server(&app_state.config.zed_environment)
97 .await
98 .unwrap();
99 let server = Server::new(
100 epoch,
101 app_state.clone(),
102 Executor::Deterministic(deterministic.clone()),
103 );
104 server.start().await.unwrap();
105 // Advance clock to ensure the server's cleanup task is finished.
106 deterministic.advance_clock(CLEANUP_TIMEOUT);
107 Self {
108 app_state,
109 server,
110 connection_killers: Default::default(),
111 forbid_connections: Default::default(),
112 next_github_user_id: 0,
113 _test_db: test_db,
114 test_live_kit_server: live_kit_server,
115 }
116 }
117
118 pub async fn start2(
119 cx_a: &mut TestAppContext,
120 cx_b: &mut TestAppContext,
121 ) -> (TestServer, TestClient, TestClient, u64) {
122 let mut server = Self::start(cx_a.executor()).await;
123 let client_a = server.create_client(cx_a, "user_a").await;
124 let client_b = server.create_client(cx_b, "user_b").await;
125 let channel_id = server
126 .make_channel(
127 "test-channel",
128 None,
129 (&client_a, cx_a),
130 &mut [(&client_b, cx_b)],
131 )
132 .await;
133 cx_a.run_until_parked();
134
135 (server, client_a, client_b, channel_id)
136 }
137
138 pub async fn start1<'a>(cx: &'a mut TestAppContext) -> TestClient {
139 let mut server = Self::start(cx.executor().clone()).await;
140 server.create_client(cx, "user_a").await
141 }
142
143 pub async fn reset(&self) {
144 self.app_state.db.reset();
145 let epoch = self
146 .app_state
147 .db
148 .create_server(&self.app_state.config.zed_environment)
149 .await
150 .unwrap();
151 self.server.reset(epoch);
152 }
153
154 pub async fn create_client(&mut self, cx: &mut TestAppContext, name: &str) -> TestClient {
155 cx.update(|cx| {
156 if cx.has_global::<SettingsStore>() {
157 panic!("Same cx used to create two test clients")
158 }
159 let settings = SettingsStore::test(cx);
160 cx.set_global(settings);
161 release_channel::init("0.0.0", cx);
162 client::init_settings(cx);
163 });
164
165 let http = FakeHttpClient::with_404_response();
166 let user_id = if let Ok(Some(user)) = self.app_state.db.get_user_by_github_login(name).await
167 {
168 user.id
169 } else {
170 let github_user_id = self.next_github_user_id;
171 self.next_github_user_id += 1;
172 self.app_state
173 .db
174 .create_user(
175 &format!("{name}@example.com"),
176 false,
177 NewUserParams {
178 github_login: name.into(),
179 github_user_id,
180 },
181 )
182 .await
183 .expect("creating user failed")
184 .user_id
185 };
186 let client_name = name.to_string();
187 let mut client = cx.update(|cx| Client::new(http.clone(), cx));
188 let server = self.server.clone();
189 let db = self.app_state.db.clone();
190 let connection_killers = self.connection_killers.clone();
191 let forbid_connections = self.forbid_connections.clone();
192
193 Arc::get_mut(&mut client)
194 .unwrap()
195 .set_id(user_id.to_proto())
196 .override_authenticate(move |cx| {
197 cx.spawn(|_| async move {
198 let access_token = "the-token".to_string();
199 Ok(Credentials {
200 user_id: user_id.to_proto(),
201 access_token,
202 })
203 })
204 })
205 .override_establish_connection(move |credentials, cx| {
206 assert_eq!(credentials.user_id, user_id.0 as u64);
207 assert_eq!(credentials.access_token, "the-token");
208
209 let server = server.clone();
210 let db = db.clone();
211 let connection_killers = connection_killers.clone();
212 let forbid_connections = forbid_connections.clone();
213 let client_name = client_name.clone();
214 cx.spawn(move |cx| async move {
215 if forbid_connections.load(SeqCst) {
216 Err(EstablishConnectionError::other(anyhow!(
217 "server is forbidding connections"
218 )))
219 } else {
220 let (client_conn, server_conn, killed) =
221 Connection::in_memory(cx.background_executor().clone());
222 let (connection_id_tx, connection_id_rx) = oneshot::channel();
223 let user = db
224 .get_user_by_id(user_id)
225 .await
226 .expect("retrieving user failed")
227 .unwrap();
228 cx.background_executor()
229 .spawn(server.handle_connection(
230 server_conn,
231 client_name,
232 user,
233 SemanticVersion::default(),
234 None,
235 Some(connection_id_tx),
236 Executor::Deterministic(cx.background_executor().clone()),
237 ))
238 .detach();
239 let connection_id = connection_id_rx.await.unwrap();
240 connection_killers
241 .lock()
242 .insert(connection_id.into(), killed);
243 Ok(client_conn)
244 }
245 })
246 });
247
248 let fs = FakeFs::new(cx.executor());
249 let user_store = cx.new_model(|cx| UserStore::new(client.clone(), cx));
250 let workspace_store = cx.new_model(|cx| WorkspaceStore::new(client.clone(), cx));
251 let mut language_registry = LanguageRegistry::test();
252 language_registry.set_executor(cx.executor());
253 let app_state = Arc::new(workspace::AppState {
254 client: client.clone(),
255 user_store: user_store.clone(),
256 workspace_store,
257 languages: Arc::new(language_registry),
258 fs: fs.clone(),
259 build_window_options: |_, _, _| Default::default(),
260 node_runtime: FakeNodeRuntime::new(),
261 });
262
263 cx.update(|cx| {
264 theme::init(theme::LoadThemes::JustBase, cx);
265 Project::init(&client, cx);
266 client::init(&client, cx);
267 language::init(cx);
268 editor::init(cx);
269 workspace::init(app_state.clone(), cx);
270 call::init(client.clone(), user_store.clone(), cx);
271 channel::init(&client, user_store.clone(), cx);
272 notifications::init(client.clone(), user_store, cx);
273 collab_ui::init(&app_state, cx);
274 file_finder::init(cx);
275 menu::init();
276 settings::KeymapFile::load_asset("keymaps/default.json", cx).unwrap();
277 });
278
279 client
280 .authenticate_and_connect(false, &cx.to_async())
281 .await
282 .unwrap();
283
284 let client = TestClient {
285 app_state,
286 username: name.to_string(),
287 channel_store: cx.read(ChannelStore::global).clone(),
288 notification_store: cx.read(NotificationStore::global).clone(),
289 state: Default::default(),
290 };
291 client.wait_for_current_user(cx).await;
292 client
293 }
294
295 pub fn disconnect_client(&self, peer_id: PeerId) {
296 self.connection_killers
297 .lock()
298 .remove(&peer_id)
299 .unwrap()
300 .store(true, SeqCst);
301 }
302
303 pub fn simulate_long_connection_interruption(
304 &self,
305 peer_id: PeerId,
306 deterministic: BackgroundExecutor,
307 ) {
308 self.forbid_connections();
309 self.disconnect_client(peer_id);
310 deterministic.advance_clock(RECEIVE_TIMEOUT + RECONNECT_TIMEOUT);
311 self.allow_connections();
312 deterministic.advance_clock(RECEIVE_TIMEOUT + RECONNECT_TIMEOUT);
313 deterministic.run_until_parked();
314 }
315
316 pub fn forbid_connections(&self) {
317 self.forbid_connections.store(true, SeqCst);
318 }
319
320 pub fn allow_connections(&self) {
321 self.forbid_connections.store(false, SeqCst);
322 }
323
324 pub async fn make_contacts(&self, clients: &mut [(&TestClient, &mut TestAppContext)]) {
325 for ix in 1..clients.len() {
326 let (left, right) = clients.split_at_mut(ix);
327 let (client_a, cx_a) = left.last_mut().unwrap();
328 for (client_b, cx_b) in right {
329 client_a
330 .app_state
331 .user_store
332 .update(*cx_a, |store, cx| {
333 store.request_contact(client_b.user_id().unwrap(), cx)
334 })
335 .await
336 .unwrap();
337 cx_a.executor().run_until_parked();
338 client_b
339 .app_state
340 .user_store
341 .update(*cx_b, |store, cx| {
342 store.respond_to_contact_request(client_a.user_id().unwrap(), true, cx)
343 })
344 .await
345 .unwrap();
346 }
347 }
348 }
349
350 pub async fn make_channel(
351 &self,
352 channel: &str,
353 parent: Option<u64>,
354 admin: (&TestClient, &mut TestAppContext),
355 members: &mut [(&TestClient, &mut TestAppContext)],
356 ) -> u64 {
357 let (_, admin_cx) = admin;
358 let channel_id = admin_cx
359 .read(ChannelStore::global)
360 .update(admin_cx, |channel_store, cx| {
361 channel_store.create_channel(channel, parent, cx)
362 })
363 .await
364 .unwrap();
365
366 for (member_client, member_cx) in members {
367 admin_cx
368 .read(ChannelStore::global)
369 .update(admin_cx, |channel_store, cx| {
370 channel_store.invite_member(
371 channel_id,
372 member_client.user_id().unwrap(),
373 ChannelRole::Member,
374 cx,
375 )
376 })
377 .await
378 .unwrap();
379
380 admin_cx.executor().run_until_parked();
381
382 member_cx
383 .read(ChannelStore::global)
384 .update(*member_cx, |channels, cx| {
385 channels.respond_to_channel_invite(channel_id, true, cx)
386 })
387 .await
388 .unwrap();
389 }
390
391 channel_id
392 }
393
394 pub async fn make_public_channel(
395 &self,
396 channel: &str,
397 client: &TestClient,
398 cx: &mut TestAppContext,
399 ) -> u64 {
400 let channel_id = self
401 .make_channel(channel, None, (client, cx), &mut [])
402 .await;
403
404 client
405 .channel_store()
406 .update(cx, |channel_store, cx| {
407 channel_store.set_channel_visibility(
408 channel_id,
409 proto::ChannelVisibility::Public,
410 cx,
411 )
412 })
413 .await
414 .unwrap();
415
416 channel_id
417 }
418
419 pub async fn make_channel_tree(
420 &self,
421 channels: &[(&str, Option<&str>)],
422 creator: (&TestClient, &mut TestAppContext),
423 ) -> Vec<u64> {
424 let mut observed_channels = HashMap::default();
425 let mut result = Vec::new();
426 for (channel, parent) in channels {
427 let id;
428 if let Some(parent) = parent {
429 if let Some(parent_id) = observed_channels.get(parent) {
430 id = self
431 .make_channel(channel, Some(*parent_id), (creator.0, creator.1), &mut [])
432 .await;
433 } else {
434 panic!(
435 "Edge {}->{} referenced before {} was created",
436 parent, channel, parent
437 )
438 }
439 } else {
440 id = self
441 .make_channel(channel, None, (creator.0, creator.1), &mut [])
442 .await;
443 }
444
445 observed_channels.insert(channel, id);
446 result.push(id);
447 }
448
449 result
450 }
451
452 pub async fn create_room(&self, clients: &mut [(&TestClient, &mut TestAppContext)]) {
453 self.make_contacts(clients).await;
454
455 let (left, right) = clients.split_at_mut(1);
456 let (_client_a, cx_a) = &mut left[0];
457 let active_call_a = cx_a.read(ActiveCall::global);
458
459 for (client_b, cx_b) in right {
460 let user_id_b = client_b.current_user_id(*cx_b).to_proto();
461 active_call_a
462 .update(*cx_a, |call, cx| call.invite(user_id_b, None, cx))
463 .await
464 .unwrap();
465
466 cx_b.executor().run_until_parked();
467 let active_call_b = cx_b.read(ActiveCall::global);
468 active_call_b
469 .update(*cx_b, |call, cx| call.accept_incoming(cx))
470 .await
471 .unwrap();
472 }
473 }
474
475 pub async fn build_app_state(
476 test_db: &TestDb,
477 fake_server: &live_kit_client::TestServer,
478 ) -> Arc<AppState> {
479 Arc::new(AppState {
480 db: test_db.db().clone(),
481 live_kit_client: Some(Arc::new(fake_server.create_api_client())),
482 config: Config {
483 http_port: 0,
484 database_url: "".into(),
485 database_max_connections: 0,
486 api_token: "".into(),
487 invite_link_prefix: "".into(),
488 live_kit_server: None,
489 live_kit_key: None,
490 live_kit_secret: None,
491 rust_log: None,
492 log_json: None,
493 zed_environment: "test".into(),
494 },
495 })
496 }
497}
498
499impl Deref for TestServer {
500 type Target = Server;
501
502 fn deref(&self) -> &Self::Target {
503 &self.server
504 }
505}
506
507impl Drop for TestServer {
508 fn drop(&mut self) {
509 self.server.teardown();
510 self.test_live_kit_server.teardown().unwrap();
511 }
512}
513
514impl Deref for TestClient {
515 type Target = Arc<Client>;
516
517 fn deref(&self) -> &Self::Target {
518 &self.app_state.client
519 }
520}
521
522impl TestClient {
523 pub fn fs(&self) -> &FakeFs {
524 self.app_state.fs.as_fake()
525 }
526
527 pub fn channel_store(&self) -> &Model<ChannelStore> {
528 &self.channel_store
529 }
530
531 pub fn notification_store(&self) -> &Model<NotificationStore> {
532 &self.notification_store
533 }
534
535 pub fn user_store(&self) -> &Model<UserStore> {
536 &self.app_state.user_store
537 }
538
539 pub fn language_registry(&self) -> &Arc<LanguageRegistry> {
540 &self.app_state.languages
541 }
542
543 pub fn client(&self) -> &Arc<Client> {
544 &self.app_state.client
545 }
546
547 pub fn current_user_id(&self, cx: &TestAppContext) -> UserId {
548 UserId::from_proto(
549 self.app_state
550 .user_store
551 .read_with(cx, |user_store, _| user_store.current_user().unwrap().id),
552 )
553 }
554
555 pub async fn wait_for_current_user(&self, cx: &TestAppContext) {
556 let mut authed_user = self
557 .app_state
558 .user_store
559 .read_with(cx, |user_store, _| user_store.watch_current_user());
560 while authed_user.next().await.unwrap().is_none() {}
561 }
562
563 pub async fn clear_contacts(&self, cx: &mut TestAppContext) {
564 self.app_state
565 .user_store
566 .update(cx, |store, _| store.clear_contacts())
567 .await;
568 }
569
570 pub fn local_projects<'a>(&'a self) -> impl Deref<Target = Vec<Model<Project>>> + 'a {
571 Ref::map(self.state.borrow(), |state| &state.local_projects)
572 }
573
574 pub fn remote_projects<'a>(&'a self) -> impl Deref<Target = Vec<Model<Project>>> + 'a {
575 Ref::map(self.state.borrow(), |state| &state.remote_projects)
576 }
577
578 pub fn local_projects_mut<'a>(&'a self) -> impl DerefMut<Target = Vec<Model<Project>>> + 'a {
579 RefMut::map(self.state.borrow_mut(), |state| &mut state.local_projects)
580 }
581
582 pub fn remote_projects_mut<'a>(&'a self) -> impl DerefMut<Target = Vec<Model<Project>>> + 'a {
583 RefMut::map(self.state.borrow_mut(), |state| &mut state.remote_projects)
584 }
585
586 pub fn buffers_for_project<'a>(
587 &'a self,
588 project: &Model<Project>,
589 ) -> impl DerefMut<Target = HashSet<Model<language::Buffer>>> + 'a {
590 RefMut::map(self.state.borrow_mut(), |state| {
591 state.buffers.entry(project.clone()).or_default()
592 })
593 }
594
595 pub fn buffers<'a>(
596 &'a self,
597 ) -> impl DerefMut<Target = HashMap<Model<Project>, HashSet<Model<language::Buffer>>>> + 'a
598 {
599 RefMut::map(self.state.borrow_mut(), |state| &mut state.buffers)
600 }
601
602 pub fn channel_buffers<'a>(
603 &'a self,
604 ) -> impl DerefMut<Target = HashSet<Model<ChannelBuffer>>> + 'a {
605 RefMut::map(self.state.borrow_mut(), |state| &mut state.channel_buffers)
606 }
607
608 pub fn summarize_contacts(&self, cx: &TestAppContext) -> ContactsSummary {
609 self.app_state
610 .user_store
611 .read_with(cx, |store, _| ContactsSummary {
612 current: store
613 .contacts()
614 .iter()
615 .map(|contact| contact.user.github_login.clone())
616 .collect(),
617 outgoing_requests: store
618 .outgoing_contact_requests()
619 .iter()
620 .map(|user| user.github_login.clone())
621 .collect(),
622 incoming_requests: store
623 .incoming_contact_requests()
624 .iter()
625 .map(|user| user.github_login.clone())
626 .collect(),
627 })
628 }
629
630 pub async fn build_local_project(
631 &self,
632 root_path: impl AsRef<Path>,
633 cx: &mut TestAppContext,
634 ) -> (Model<Project>, WorktreeId) {
635 let project = self.build_empty_local_project(cx);
636 let (worktree, _) = project
637 .update(cx, |p, cx| {
638 p.find_or_create_local_worktree(root_path, true, cx)
639 })
640 .await
641 .unwrap();
642 worktree
643 .read_with(cx, |tree, _| tree.as_local().unwrap().scan_complete())
644 .await;
645 (project, worktree.read_with(cx, |tree, _| tree.id()))
646 }
647
648 pub async fn build_test_project(&self, cx: &mut TestAppContext) -> Model<Project> {
649 self.fs()
650 .insert_tree(
651 "/a",
652 json!({
653 "1.txt": "one\none\none",
654 "2.js": "function two() { return 2; }",
655 "3.rs": "mod test",
656 }),
657 )
658 .await;
659 self.build_local_project("/a", cx).await.0
660 }
661
662 pub async fn host_workspace(
663 &self,
664 workspace: &View<Workspace>,
665 channel_id: u64,
666 cx: &mut VisualTestContext,
667 ) {
668 cx.update(|cx| {
669 let active_call = ActiveCall::global(cx);
670 active_call.update(cx, |call, cx| call.join_channel(channel_id, cx))
671 })
672 .await
673 .unwrap();
674 cx.update(|cx| {
675 let active_call = ActiveCall::global(cx);
676 let project = workspace.read(cx).project().clone();
677 active_call.update(cx, |call, cx| call.share_project(project, cx))
678 })
679 .await
680 .unwrap();
681 cx.executor().run_until_parked();
682 }
683
684 pub async fn join_workspace<'a>(
685 &'a self,
686 channel_id: u64,
687 cx: &'a mut TestAppContext,
688 ) -> (View<Workspace>, &'a mut VisualTestContext) {
689 cx.update(|cx| workspace::open_channel(channel_id, self.app_state.clone(), None, cx))
690 .await
691 .unwrap();
692 cx.run_until_parked();
693
694 self.active_workspace(cx)
695 }
696
697 pub fn build_empty_local_project(&self, cx: &mut TestAppContext) -> Model<Project> {
698 cx.update(|cx| {
699 Project::local(
700 self.client().clone(),
701 self.app_state.node_runtime.clone(),
702 self.app_state.user_store.clone(),
703 self.app_state.languages.clone(),
704 self.app_state.fs.clone(),
705 cx,
706 )
707 })
708 }
709
710 pub async fn build_remote_project(
711 &self,
712 host_project_id: u64,
713 guest_cx: &mut TestAppContext,
714 ) -> Model<Project> {
715 let active_call = guest_cx.read(ActiveCall::global);
716 let room = active_call.read_with(guest_cx, |call, _| call.room().unwrap().clone());
717 room.update(guest_cx, |room, cx| {
718 room.join_project(
719 host_project_id,
720 self.app_state.languages.clone(),
721 self.app_state.fs.clone(),
722 cx,
723 )
724 })
725 .await
726 .unwrap()
727 }
728
729 pub fn build_workspace<'a>(
730 &'a self,
731 project: &Model<Project>,
732 cx: &'a mut TestAppContext,
733 ) -> (View<Workspace>, &'a mut VisualTestContext) {
734 cx.add_window_view(|cx| {
735 cx.activate_window();
736 Workspace::new(0, project.clone(), self.app_state.clone(), cx)
737 })
738 }
739
740 pub async fn build_test_workspace<'a>(
741 &'a self,
742 cx: &'a mut TestAppContext,
743 ) -> (View<Workspace>, &'a mut VisualTestContext) {
744 let project = self.build_test_project(cx).await;
745 cx.add_window_view(|cx| {
746 cx.activate_window();
747 Workspace::new(0, project.clone(), self.app_state.clone(), cx)
748 })
749 }
750
751 pub fn active_workspace<'a>(
752 &'a self,
753 cx: &'a mut TestAppContext,
754 ) -> (View<Workspace>, &'a mut VisualTestContext) {
755 let window = cx.update(|cx| cx.active_window().unwrap().downcast::<Workspace>().unwrap());
756
757 let view = window.root_view(cx).unwrap();
758 let cx = VisualTestContext::from_window(*window.deref(), cx).as_mut();
759 // it might be nice to try and cleanup these at the end of each test.
760 (view, cx)
761 }
762}
763
764pub fn join_channel_call(cx: &mut TestAppContext) -> Task<anyhow::Result<()>> {
765 let room = cx.read(|cx| ActiveCall::global(cx).read(cx).room().cloned());
766 room.unwrap().update(cx, |room, cx| room.join_call(cx))
767}
768
769impl Drop for TestClient {
770 fn drop(&mut self) {
771 self.app_state.client.teardown();
772 }
773}