Create harness interface spec types
This commit is contained in:
parent
4a4410443a
commit
9955517f4a
4 changed files with 89 additions and 8 deletions
|
@ -8,6 +8,8 @@ pub enum Feedback {
|
||||||
AssertFailure,
|
AssertFailure,
|
||||||
/// Last instruction raised an error
|
/// Last instruction raised an error
|
||||||
Error,
|
Error,
|
||||||
|
/// Last instruction was not supported by adaptor
|
||||||
|
Unsupported,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Feedback {
|
impl Feedback {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use super::{TestRunner, TestAdaptor, TestMetadata};
|
use super::{TestRunner, TestAdaptor, TestMetadata};
|
||||||
use super::{Instruction, TestAssert, UIOp, Feedback};
|
use super::{Instruction, TestAssert, TestOp, Feedback};
|
||||||
|
|
||||||
/// Harness which runs one or more tests
|
/// Harness which runs one or more tests
|
||||||
pub struct TestHarness<R: TestRunner, A: TestAdaptor> {
|
pub struct TestHarness<R: TestRunner, A: TestAdaptor> {
|
||||||
|
@ -21,7 +21,7 @@ impl<R: TestRunner, A: TestAdaptor> TestHarness<R, A> {
|
||||||
Feedback::Success
|
Feedback::Success
|
||||||
}
|
}
|
||||||
|
|
||||||
fn translate_ui_op(&self, _op: UIOp) -> Feedback {
|
fn translate_ui_op(&self, _op: TestOp) -> Feedback {
|
||||||
// TODO
|
// TODO
|
||||||
Feedback::Success
|
Feedback::Success
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ impl<R: TestRunner, A: TestAdaptor> TestHarness<R, A> {
|
||||||
fn translate_instruction(&self, instruction: Instruction) -> Feedback {
|
fn translate_instruction(&self, instruction: Instruction) -> Feedback {
|
||||||
match instruction {
|
match instruction {
|
||||||
Instruction::Assertion(a) => self.translate_assertion(a),
|
Instruction::Assertion(a) => self.translate_assertion(a),
|
||||||
Instruction::Interaction(i) => self.translate_ui_op(i),
|
Instruction::Operation(i) => self.translate_ui_op(i),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,91 @@
|
||||||
pub enum Instruction {
|
pub enum Instruction {
|
||||||
/// Test assertion
|
/// Test assertion
|
||||||
Assertion(TestAssert),
|
Assertion(TestAssert),
|
||||||
/// UI manipulation
|
/// Test harness operation
|
||||||
Interaction(UIOp),
|
Operation(TestOp),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Assertion
|
/// Assertion
|
||||||
pub enum TestAssert {}
|
pub struct TestAssert {
|
||||||
|
/// Tab context
|
||||||
|
pub context: TabSelector,
|
||||||
|
/// Test assertion
|
||||||
|
pub assertion: GeneralAssertType,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test assertion information
|
||||||
|
pub enum GeneralAssertType {
|
||||||
|
/// Element-related assertion
|
||||||
|
Element(ElementAssert),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Element assertion
|
||||||
|
pub struct ElementAssert {
|
||||||
|
/// Element to target
|
||||||
|
pub element: ElementSelector,
|
||||||
|
/// Test assertion
|
||||||
|
pub assert: ElementAssertionType,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assertion operations
|
||||||
|
pub enum ElementAssertionType {
|
||||||
|
/// Assert element exists
|
||||||
|
Exists,
|
||||||
|
/// Assert element contains text
|
||||||
|
TextEquals(String)
|
||||||
|
}
|
||||||
|
|
||||||
/// User interface interaction
|
/// User interface interaction
|
||||||
pub enum UIOp {}
|
pub struct TestOp {
|
||||||
|
/// Tab context
|
||||||
|
pub context: TabSelector,
|
||||||
|
/// Test operation
|
||||||
|
pub op: GeneralOpType,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Element selection mode
|
||||||
|
pub enum ElementSelector {
|
||||||
|
/// Use CSS selector syntax
|
||||||
|
CSS(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Tab selection mode
|
||||||
|
pub enum TabSelector {
|
||||||
|
/// Select by tab title
|
||||||
|
Title(String),
|
||||||
|
/// Select by tab's current URL
|
||||||
|
Url(String),
|
||||||
|
/// Select by tab identifier
|
||||||
|
Id(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test operation information
|
||||||
|
pub enum GeneralOpType {
|
||||||
|
/// Operate on an element
|
||||||
|
Element(ElementOp),
|
||||||
|
/// Basic context operation
|
||||||
|
Basic(BasicOpType),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Basic operation type
|
||||||
|
pub enum BasicOpType {
|
||||||
|
/// Pause executing thread for time, in milliseconds
|
||||||
|
Sleep(u64),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Element manipulation operation
|
||||||
|
pub struct ElementOp {
|
||||||
|
/// Element to target
|
||||||
|
pub element: ElementSelector,
|
||||||
|
/// Operation to perform
|
||||||
|
pub op: ElementOpType,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Element operation type
|
||||||
|
pub enum ElementOpType {
|
||||||
|
/// Click on element
|
||||||
|
Click,
|
||||||
|
/// Wait for element to be created
|
||||||
|
WaitFor,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,6 @@ pub use adaptor::TestAdaptor;
|
||||||
pub use feedback::Feedback;
|
pub use feedback::Feedback;
|
||||||
pub use harness::TestHarness;
|
pub use harness::TestHarness;
|
||||||
pub use headless_adaptor::HeadlessAdaptor;
|
pub use headless_adaptor::HeadlessAdaptor;
|
||||||
pub use instructions::{Instruction, TestAssert, UIOp};
|
pub use instructions::{Instruction, TestAssert, GeneralAssertType, ElementAssert, ElementAssertionType, TestOp, ElementSelector, TabSelector, GeneralOpType, BasicOpType, ElementOp, ElementOpType};
|
||||||
pub use json_runner::JsonRunner;
|
pub use json_runner::JsonRunner;
|
||||||
pub use runner::{TestRunner, TestMetadata};
|
pub use runner::{TestRunner, TestMetadata};
|
||||||
|
|
Loading…
Reference in a new issue