-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🦄 refactor: Simplify test apis, add doc
- Merge a lot of functions into script_run
- Loading branch information
Showing
11 changed files
with
145 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,11 +37,11 @@ jobs: | |
- runner: ubuntu-latest | ||
target: ppc64le | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y pkg-config libssl-dev openssl | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.x | ||
|
@@ -72,11 +72,11 @@ jobs: | |
- runner: ubuntu-latest | ||
target: armv7 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y pkg-config libssl-dev openssl | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.x | ||
|
@@ -103,10 +103,10 @@ jobs: | |
- runner: windows-latest | ||
target: x86 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
run: | | ||
choco install -y openssl | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.x | ||
|
@@ -133,10 +133,10 @@ jobs: | |
- runner: macos-14 | ||
target: aarch64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
run: | | ||
brew install [email protected] | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.x | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/target | ||
*.log | ||
*.cast | ||
*.deprecated | ||
|
||
# Byte-compiled / optimized / DLL files | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//! Api for GUI part testing | ||
//! | ||
//! For GUI part, basicially we need to check the following: | ||
//! - Is the current screen is the expected screen? | ||
//! - Does the screen have the expected elements? | ||
//! - Can we interact with the screen? | ||
use std::error::Error; | ||
|
||
use crate::gui::screen::Screen; | ||
|
||
use super::needle::Needle; | ||
|
||
/// The API can used for testing, with bypass [`Screen`] operations. | ||
pub trait GuiTestApi: Screen { | ||
/// Check if the current screen is the expected screen | ||
fn assert_screen(&mut self, needle: Needle) -> Result<(), Box<dyn Error>>; | ||
/// Check and click the target position | ||
/// | ||
/// Suggest using assert_screen and click seperately, as futher consider adding relative position etc. | ||
fn assert_screen_click(&mut self, needle: Needle) -> Result<(), Box<dyn Error>>; | ||
|
||
/// Wait until current screen changed | ||
fn wait_screen_change(&mut self, timeout: u32) -> Result<(), Box<dyn Error>>; | ||
|
||
/// Wait and assert the screen won't change in timeout | ||
fn wait_still_screen(&mut self, timeout: u32) -> Result<(), Box<dyn Error>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pub mod cli_api; | ||
pub mod cli_exec; | ||
pub mod cli_exec_sudo; | ||
pub mod gui_api; | ||
|
||
pub mod needle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//! Object to match the GUI | ||
//! | ||
//! We can't do the same thing as the CLI part: give a string and wait for | ||
//! it. We need to match the GUI with a needle. | ||
use image::RgbaImage; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
#[serde(tag = "type")] | ||
pub enum Needle { | ||
/// Basic needle, just compare the screen with given image to see if the similarity is enough | ||
Basic(Vec<Area>), | ||
// In future, consider adding more needle types, | ||
// like using neural network to match the screen | ||
// to get a better flexibility | ||
} | ||
|
||
/// Needle type | ||
/// OpenQA needle compatible, with same definition | ||
/// | ||
/// See <https://open.qa/docs/#_needle> | ||
#[derive(Serialize, Deserialize)] | ||
pub enum NeedleType { | ||
#[serde(rename = "match")] | ||
Match, | ||
#[serde(rename = "ocr")] | ||
Ocr, // Currently not supported | ||
#[serde(rename = "exclude")] | ||
Exclude, | ||
} | ||
|
||
/// Click point | ||
/// OpenQA needle compatible, with same definition | ||
/// | ||
/// See <https://open.qa/docs/#_needle> | ||
#[derive(Serialize, Deserialize)] | ||
pub struct ClickPoint { | ||
pub xpos: u32, | ||
pub ypos: u32, | ||
} | ||
|
||
/// Area to match | ||
/// OpenQA needle compatible, with same definition | ||
/// | ||
/// See <https://open.qa/docs/#_needle> | ||
#[derive(Serialize, Deserialize)] | ||
pub struct Area { | ||
/// X coordinate of the top left corner | ||
pub x: u32, | ||
/// Y coordinate of the top left corner | ||
pub y: u32, | ||
/// Width of the area | ||
pub width: u32, | ||
/// Height of the area | ||
pub height: u32, | ||
/// Type of the needle | ||
pub needle: NeedleType, | ||
/// The similarity threshold | ||
#[serde(rename = "match")] | ||
pub match_threhold: f32, | ||
/// The click point | ||
pub click_point: Option<ClickPoint>, | ||
/// The image to match | ||
/// | ||
/// This field should be auto added by needle readers | ||
#[serde(skip_serializing, skip_deserializing)] | ||
pub target: Option<RgbaImage>, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.