blob: 655504db339e03a314dde85ce05b81fb0a7bebc8 (
plain)
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
|
use azalea_client::{test_utils::prelude::*, tick_counter::TicksConnected};
use azalea_protocol::packets::ConnectionProtocol;
#[test]
fn counter_increments_and_resets_on_disconnect() {
let _lock = init();
let mut simulation = Simulation::new(ConnectionProtocol::Game);
simulation.tick();
assert!(!simulation.has_component::<TicksConnected>());
simulation.receive_packet(default_login_packet());
simulation.tick();
assert!(simulation.has_component::<TicksConnected>());
assert_eq!(simulation.component::<TicksConnected>().0, 1);
// Tick three times; counter should read 2, 3, 4.
for expected in 2..=4 {
simulation.tick();
let counter = simulation.component::<TicksConnected>();
assert_eq!(
counter.0, expected,
"after {expected} tick(s) counter should be {expected}"
);
}
simulation.disconnect();
simulation.tick();
assert!(!simulation.has_component::<TicksConnected>());
}
|