File: simple_flow.rs

package info (click to toggle)
phrog 0.50.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 716 kB
  • sloc: makefile: 35; sh: 28; xml: 25
file content (57 lines) | stat: -rw-r--r-- 2,003 bytes parent folder | download | duplicates (2)
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
pub mod common;

use gtk::glib;
use gtk::glib::clone;
use libphosh::prelude::{LockscreenExt, ShellExt};
use libphosh::LockscreenPage;
use std::sync::atomic::Ordering;

use common::*;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use phrog::lockscreen::Lockscreen;
use std::time::Duration;

#[test]
fn test_simple_flow() {
    let mut test = test_init(Some(TestOptions {
        last_user: Some("agx".into()),
        ..Default::default()
    }));

    let ready_rx = test.ready_rx.clone();
    let shell = test.shell.clone();
    test.start("simple-flow", glib::spawn_future_local(clone!(@weak shell => async move {
        let (mut vp, _) = ready_rx.recv().await.unwrap();
        glib::timeout_future(Duration::from_millis(2000)).await;

        let mut lockscreen = shell.lockscreen_manager().lockscreen().unwrap().downcast::<Lockscreen>().unwrap();
        let usp = lockscreen.imp().user_session_page.get().unwrap();

        // test_init mocked sessions such that GNOME should be the first option in the list, but
        // last-session should be empty and thus the selection should default to Phosh.
        assert_eq!(usp.session().id(), "phosh");

        assert_eq!(usp.username(), Some("agx".to_string()));

        // Move the mouse to first user row and click on it.
        vp.click_on(usp.imp().box_users.row_at_index(0).as_ref().unwrap()).await;

        // wait for keypad page to slide in
        glib::timeout_future(Duration::from_millis(500)).await;

        assert_eq!(lockscreen.page(), LockscreenPage::Unlock);

        let (keypad, submit_btn) = get_lockscreen_bits(&mut lockscreen);

        vp.click_on(&keypad_digit(&keypad, 0)).await;
        vp.click_on(&keypad_digit(&keypad, 4)).await;
        vp.click_on(&keypad_digit(&keypad, 5)).await;
        vp.click_on(&keypad_digit(&keypad, 1)).await;

        vp.click_on(&submit_btn).await;
        glib::timeout_future(Duration::from_millis(50)).await;
    })));

    assert!(test.logged_in.load(Ordering::Relaxed));
}