Something went wrong. Try again.
A desktop BlueSky client built using Rust and `iced`. tangled.org/nateledford.com/hitomi
rust-gui bluesky rust iced
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175use super::{ Message, SessionRestorationOutcome, home, test_support::{ScreenKind, UiTestApp},};
#[test]fn given_restoring_state_when_signed_out_restoration_finishes_then_login_replaces_and_retires_root_scope() { let mut app = UiTestApp::restoring(); let previous_scope = app.state.current_scope.child_token(); assert!(app.home_snapshot().is_none());
assert_eq!( app.dispatch(Message::RestorationFinished { generation: 0, result: Ok(SessionRestorationOutcome::SignedOut), }), 0 );
assert_eq!(app.screen_kind(), ScreenKind::Login); assert!(previous_scope.is_cancelled()); assert!(!app.root_scope_cancelled());}
#[test]fn given_signed_in_restoration_when_initial_feed_load_finishes_then_home_snapshot_exposes_visible_feed() { let mut app = UiTestApp::restoring(); assert_eq!( app.dispatch(Message::RestorationFinished { generation: 0, result: Ok(SessionRestorationOutcome::SignedIn), }), 2 ); assert_eq!(app.screen_kind(), ScreenKind::Home);
assert_eq!( app.dispatch(Message::Home(home::Message::Lifecycle( home::feed_lifecycle::Message::Loaded { generation: 0, request_id: home::HomeInitialRequestId::INITIAL, result: Ok(home::test_support::feed_with_text("installed")), }, ))), 0 ); assert_eq!( app.home_snapshot() .expect("home snapshot") .visible_feed_text .as_deref(), Some("installed") ); let render_generation = app .home_snapshot() .expect("home snapshot") .render_generation; let _ = app.dispatch(Message::Home(home::Message::Timeline( super::timeline::Message::Viewport { destination: crate::feed::TimelineDestination::Home, render_generation, offset: iced::widget::scrollable::AbsoluteOffset { x: 0.0, y: 1.0 }, }, ))); assert_eq!(app.dispatch(Message::Home(home::Message::ManualRefresh)), 1); let request_id = app .home_snapshot() .expect("home snapshot") .active_refresh .expect("manual refresh request"); assert_eq!( app.dispatch(Message::Home(home::Message::Lifecycle( home::feed_lifecycle::Message::FeedRefreshFinished { generation: 0, request_id, result: Ok(home::test_support::feed_with_text("staged")), }, ))), 0 ); let snapshot = app.home_snapshot().expect("home snapshot"); assert_eq!(snapshot.visible_feed_text.as_deref(), Some("installed")); assert_eq!(snapshot.staged_feed_text.as_deref(), Some("staged"));}
#[cfg(feature = "test-support")]#[test]fn gallery_and_home_screens_build_their_complete_view_trees() { let mut app = UiTestApp::restoring(); let _ = app.dispatch(Message::RestorationFinished { generation: 0, result: Ok(SessionRestorationOutcome::SignedIn), }); let _ = app.dispatch(Message::Home(home::Message::Lifecycle( home::feed_lifecycle::Message::Loaded { generation: 0, request_id: home::HomeInitialRequestId::INITIAL, result: Ok(home::test_support::feed_with_text("rendered feed")), }, ))); let window = app.state.main_window; drop(super::view(&app.state, window));
for screen in [ super::Screen::AlertsGallery, super::Screen::ButtonGallery, super::Screen::SkeletonGallery, super::Screen::TabsGallery(super::tabs_gallery::State::default()), ] { app.state.screen = screen; drop(super::view(&app.state, window)); }}
#[cfg(feature = "test-support")]#[test]fn registered_smoke_scenarios_preserve_their_semantic_screen_policy() { use super::smoke::SmokeScenario;
for scenario in SmokeScenario::ALL { let (state, _tasks) = super::boot_smoke(scenario); assert!(!state.restoration_enabled, "{scenario:?} restores sessions"); assert!( state.avatar_cache.is_none(), "{scenario:?} creates avatar cache" ); match scenario { SmokeScenario::Recovery => { assert!(matches!(state.screen, super::Screen::RestoreUnavailable(_))); } SmokeScenario::LoginReady | SmokeScenario::ManualBrowser | SmokeScenario::BrowserWaiting => { assert!(matches!(state.screen, super::Screen::Login(_))); } SmokeScenario::FeedError | SmokeScenario::FeedLoading | SmokeScenario::FeedLive | SmokeScenario::FeedDegraded | SmokeScenario::ServiceStatusAdvisory | SmokeScenario::ServiceStatusPartial | SmokeScenario::TimelineGallery | SmokeScenario::TimelineGalleryLarge | SmokeScenario::VideoGallery | SmokeScenario::VideoGalleryLarge | SmokeScenario::VideoGalleryPoster | SmokeScenario::FeedDestinations | SmokeScenario::FeedDestinationsLarge => { assert!(matches!(state.screen, super::Screen::Home(_))); } SmokeScenario::AlertsGallery => { assert!(matches!(state.screen, super::Screen::AlertsGallery)); } SmokeScenario::ButtonGallery => { assert!(matches!(state.screen, super::Screen::ButtonGallery)); } SmokeScenario::SkeletonGallery => { assert!(matches!(state.screen, super::Screen::SkeletonGallery)); } SmokeScenario::TabsGallery => { assert!(matches!(state.screen, super::Screen::TabsGallery(_))); } SmokeScenario::Settings | SmokeScenario::SettingsSaving | SmokeScenario::SettingsError => { assert!(state.settings_window.is_some()); } } let window = state.main_window; drop(super::view(&state, window)); }}