Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Coverage

on:
workflow_dispatch:
push:
branches: [main, release-*]
pull_request:
branches: [main, release-*]
# push:
# branches: [main, release-*]
# pull_request:
# branches: [main, release-*]

env:
CARGO_TERM_COLOR: always
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
include:
- os: ubuntu-latest
headless: Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- os: macos-latest
extra: -- --skip test_afrim
# - os: macos-latest
# extra: -- --skip test_afrim
- os: windows-latest
extra: -- --skip test_afrim
# extra: -- --skip test_afrim

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -71,14 +71,18 @@ jobs:
cargo test --no-run -p afrim-preprocessor --all-features --verbose
cargo test --no-run -p afrim --all-features --verbose

- uses: OrbitalOwen/desktop-screenshot-action@0.1
with:
file-name: 'desktop1.jpg'

- name: Run tests (minimal)
run: |
cargo test -p afrim-memory --verbose
cargo test -p afrim-preprocessor --no-default-features --verbose
cargo test -p afrim-translator --no-default-features --verbose
cargo test -p afrim-config --no-default-features --verbose
cargo test -p afrim --no-default-features --verbose ${{matrix.extra}}

- uses: OrbitalOwen/desktop-screenshot-action@0.1
with:
file-name: 'desktop2.jpg'

- name: Run tests (normal)
run: |
cargo test -p afrim-preprocessor --verbose
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Web

on:
workflow_dispatch:
push:
branches: [main, release-*]
pull_request:
branches: [main, release-*]
# push:
# branches: [main, release-*]
# pull_request:
# branches: [main, release-*]

env:
CARGO_TERM_COLOR: always
Expand Down
41 changes: 17 additions & 24 deletions service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ pub fn run(
mod tests {
use crate::{frontend::Console, run, Config};
use afrish::{self, TkPackLayout};
use rdev::{self, Button, EventType::*, Key::*};
use std::sync::mpsc::{self, Sender};
use rdev::{self, EventType::*, Key::*};
use std::sync::mpsc::{self};
use std::{thread, time::Duration};

macro_rules! input {
Expand Down Expand Up @@ -255,11 +255,7 @@ mod tests {
input_field
}

fn end_sandbox() {
afrish::end_wish();
}

fn start_simulation(signal: Sender<()>) {
fn start_simulation() {
let typing_speed_ms = Duration::from_millis(500);

// To detect excessive backspace
Expand All @@ -268,15 +264,10 @@ mod tests {
// Start the sandbox
let textfield = start_sandbox(LIMIT);

// Send the ready signal.
signal.send(()).unwrap();

rdev::simulate(&MouseMove { x: 100.0, y: 100.0 }).unwrap();
thread::sleep(typing_speed_ms);
rdev::simulate(&ButtonPress(Button::Left)).unwrap();
thread::sleep(typing_speed_ms);
rdev::simulate(&ButtonRelease(Button::Left)).unwrap();
thread::sleep(typing_speed_ms);
rdev::simulate(&KeyPress(Alt)).unwrap();
rdev::simulate(&KeyPress(Tab)).unwrap();
rdev::simulate(&KeyRelease(Alt)).unwrap();
rdev::simulate(&KeyRelease(Tab)).unwrap();

input!(KeyU, typing_speed_ms);
#[cfg(not(feature = "inhibit"))]
Expand Down Expand Up @@ -378,8 +369,6 @@ mod tests {
rdev::simulate(&KeyPress(ShiftLeft)).unwrap();
input!(Minus, typing_speed_ms);
rdev::simulate(&KeyRelease(ShiftLeft)).unwrap();

end_sandbox();
}

#[test]
Expand All @@ -388,16 +377,20 @@ mod tests {

let (tx, rx) = mpsc::channel();

// TODO: handle simulation errors.
let simulation_thread = thread::spawn(move || start_simulation(tx));
let afrim_thread = thread::spawn(move || {
let test_config = Config::from_file(Path::new("./data/test.toml")).unwrap();
// Send the ready signal.
tx.send(()).unwrap();

assert!(run(test_config, Console::default()).is_ok());
});

// Wait the ready signal.
rx.recv().unwrap();

let test_config = Config::from_file(Path::new("./data/test.toml")).unwrap();
assert!(run(test_config, Console::default()).is_ok());
start_simulation();

// Wait the simulation to end properly.
simulation_thread.join().unwrap();
// Wait the afrim to end properly.
afrim_thread.join().unwrap();
}
}
Loading