-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotice_tests.rs
More file actions
70 lines (55 loc) · 2.15 KB
/
Copy pathnotice_tests.rs
File metadata and controls
70 lines (55 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use std::time::Instant;
use super::notices::{Notice, NoticeLevel};
use super::{HonkHonk, Message};
use crate::audio::{AudioEvent, EngineErrorEvent};
#[test]
fn source_first_run_written_queues_persistent_notice() {
let mut app = HonkHonk::new_for_test();
assert!(app.notices().is_empty());
let _ = app.update(Message::AudioEvent(AudioEvent::SourceFirstRun {
confd_written: true,
}));
let notice = app.notices().front().expect("notice set");
assert_eq!(notice.notice.level, NoticeLevel::Info);
assert!(notice.notice.body.contains("persist"));
assert!(notice.notice.body.contains("HonkHonk Mic"));
}
#[test]
fn source_first_run_not_written_queues_session_notice() {
let mut app = HonkHonk::new_for_test();
let _ = app.update(Message::AudioEvent(AudioEvent::SourceFirstRun {
confd_written: false,
}));
let notice = app.notices().front().expect("notice set");
assert_eq!(notice.notice.level, NoticeLevel::Info);
assert!(notice.notice.body.contains("this session"));
}
#[test]
fn raise_notice_message_queues_notice() {
let mut app = HonkHonk::new_for_test();
let _ = app.update(Message::RaiseNotice(Notice::warning(
"Shortcut unavailable",
"The portal is not running.",
)));
let notice = app.notices().front().expect("notice queued");
assert_eq!(notice.notice.level, NoticeLevel::Warning);
assert_eq!(notice.notice.title, "Shortcut unavailable");
}
#[test]
fn audio_error_event_queues_persistent_error_notice() {
let mut app = HonkHonk::new_for_test();
let _ = app.update(Message::AudioEvent(AudioEvent::Error(
EngineErrorEvent::VirtualSinkNotRegistered,
)));
let notice = app.notices().front().expect("notice queued");
assert_eq!(notice.notice.level, NoticeLevel::Error);
assert_eq!(notice.notice.title, "Audio error");
assert!(notice.notice.body.contains("virtual sink"));
let id = notice.id;
let _ = app.update(Message::NoticeTick(
Instant::now() + Notice::DEFAULT_TIMEOUT * 4,
));
assert!(app.notices().front().is_some());
let _ = app.update(Message::DismissNotice(id));
assert!(app.notices().is_empty());
}