mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 15:25:52 +00:00
webdriver: Add support to format values with {:?} (#111)
For debugging purposes it is helpful when enum and struct definitions are using derive Debug. Source-Repo: https://github.com/mozilla/webdriver-rust Source-Revision: 989cfcb7ab23ab356b2bf77ff37a37ab1c7be89d committer: jgraham <james@hoppipolla.co.uk> --HG-- extra : subtree_source : http%3A//tristan.corp.lon2.mozilla.com%3A8000 extra : subtree_revision : 5d1bcd860f19a0275cc110d8e86d62788ce5319a
This commit is contained in:
parent
e9a9bb7bc1
commit
89de54cf9d
@ -9,7 +9,7 @@ use rustc_serialize::json::{ToJson, Json};
|
||||
use std::collections::BTreeMap;
|
||||
use std::default::Default;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum WebDriverCommand<T: WebDriverExtensionCommand> {
|
||||
NewSession(NewSessionParameters),
|
||||
DeleteSession,
|
||||
@ -74,7 +74,7 @@ pub trait WebDriverExtensionCommand : Clone + Send + PartialEq {
|
||||
fn parameters_json(&self) -> Option<Json>;
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct VoidWebDriverExtensionCommand;
|
||||
|
||||
impl WebDriverExtensionCommand for VoidWebDriverExtensionCommand {
|
||||
@ -83,7 +83,7 @@ impl WebDriverExtensionCommand for VoidWebDriverExtensionCommand {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct WebDriverMessage <U: WebDriverExtensionRoute=VoidWebDriverExtensionRoute> {
|
||||
pub session_id: Option<String>,
|
||||
pub command: WebDriverCommand<U::Command>,
|
||||
@ -490,7 +490,7 @@ impl CapabilitiesMatching for NewSessionParameters {
|
||||
}
|
||||
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct GetParameters {
|
||||
pub url: String
|
||||
}
|
||||
@ -519,7 +519,7 @@ impl ToJson for GetParameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct TimeoutsParameters {
|
||||
pub script: Option<u64>,
|
||||
pub page_load: Option<u64>,
|
||||
@ -658,7 +658,7 @@ impl ToJson for WindowRectParameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SwitchToWindowParameters {
|
||||
pub handle: String
|
||||
}
|
||||
@ -687,7 +687,7 @@ impl ToJson for SwitchToWindowParameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct LocatorParameters {
|
||||
pub using: LocatorStrategy,
|
||||
pub value: String
|
||||
@ -726,7 +726,7 @@ impl ToJson for LocatorParameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SwitchToFrameParameters {
|
||||
pub id: FrameId
|
||||
}
|
||||
@ -754,7 +754,7 @@ impl ToJson for SwitchToFrameParameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SendKeysParameters {
|
||||
pub text: String
|
||||
}
|
||||
@ -784,7 +784,7 @@ impl ToJson for SendKeysParameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct JavascriptCommandParameters {
|
||||
pub script: String,
|
||||
pub args: Nullable<Vec<Json>>
|
||||
@ -832,7 +832,7 @@ impl ToJson for JavascriptCommandParameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct GetNamedCookieParameters {
|
||||
pub name: Nullable<String>,
|
||||
}
|
||||
@ -863,7 +863,7 @@ impl ToJson for GetNamedCookieParameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct AddCookieParameters {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
@ -978,7 +978,7 @@ impl ToJson for AddCookieParameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct TakeScreenshotParameters {
|
||||
pub element: Nullable<WebElement>
|
||||
}
|
||||
@ -1011,7 +1011,7 @@ impl ToJson for TakeScreenshotParameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ActionsParameters {
|
||||
pub actions: Vec<ActionSequence>
|
||||
}
|
||||
@ -1047,7 +1047,7 @@ impl ToJson for ActionsParameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ActionSequence {
|
||||
pub id: Nullable<String>,
|
||||
pub actions: ActionsType
|
||||
@ -1113,7 +1113,7 @@ impl ToJson for ActionSequence {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum ActionsType {
|
||||
Null(Vec<NullActionItem>),
|
||||
Key(Vec<KeyActionItem>),
|
||||
@ -1162,7 +1162,7 @@ impl Parameters for ActionsType {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum PointerType {
|
||||
Mouse,
|
||||
Pen,
|
||||
@ -1203,7 +1203,7 @@ impl Default for PointerType {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq)]
|
||||
#[derive(Debug, Default, PartialEq)]
|
||||
pub struct PointerActionParameters {
|
||||
pub pointer_type: PointerType
|
||||
}
|
||||
@ -1232,7 +1232,7 @@ impl ToJson for PointerActionParameters {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum NullActionItem {
|
||||
General(GeneralAction)
|
||||
}
|
||||
@ -1265,7 +1265,7 @@ impl ToJson for NullActionItem {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum KeyActionItem {
|
||||
General(GeneralAction),
|
||||
Key(KeyAction)
|
||||
@ -1300,7 +1300,7 @@ impl ToJson for KeyActionItem {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum PointerActionItem {
|
||||
General(GeneralAction),
|
||||
Pointer(PointerAction)
|
||||
@ -1334,7 +1334,7 @@ impl ToJson for PointerActionItem {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum GeneralAction {
|
||||
Pause(PauseAction)
|
||||
}
|
||||
@ -1357,7 +1357,7 @@ impl ToJson for GeneralAction {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct PauseAction {
|
||||
pub duration: u64
|
||||
}
|
||||
@ -1384,7 +1384,7 @@ impl ToJson for PauseAction {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum KeyAction {
|
||||
Up(KeyUpAction),
|
||||
Down(KeyDownAction)
|
||||
@ -1427,7 +1427,7 @@ fn validate_key_value(value_str: &str) -> WebDriverResult<char> {
|
||||
Ok(value)
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct KeyUpAction {
|
||||
pub value: char
|
||||
}
|
||||
@ -1459,7 +1459,7 @@ impl ToJson for KeyUpAction {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct KeyDownAction {
|
||||
pub value: char
|
||||
}
|
||||
@ -1490,7 +1490,7 @@ impl ToJson for KeyDownAction {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum PointerOrigin {
|
||||
Viewport,
|
||||
Pointer,
|
||||
@ -1531,7 +1531,7 @@ impl Default for PointerOrigin {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum PointerAction {
|
||||
Up(PointerUpAction),
|
||||
Down(PointerDownAction),
|
||||
@ -1569,7 +1569,7 @@ impl ToJson for PointerAction {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct PointerUpAction {
|
||||
pub button: u64,
|
||||
}
|
||||
@ -1599,7 +1599,7 @@ impl ToJson for PointerUpAction {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct PointerDownAction {
|
||||
pub button: u64,
|
||||
}
|
||||
@ -1629,7 +1629,7 @@ impl ToJson for PointerDownAction {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct PointerMoveAction {
|
||||
pub duration: Nullable<u64>,
|
||||
pub origin: PointerOrigin,
|
||||
|
@ -6,7 +6,7 @@ use error::{WebDriverResult, WebDriverError, ErrorStatus};
|
||||
|
||||
pub static ELEMENT_KEY: &'static str = "element-6066-11e4-a52e-4f735466cecf";
|
||||
|
||||
#[derive(RustcEncodable, PartialEq, Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq, RustcEncodable)]
|
||||
pub struct Date(pub u64);
|
||||
|
||||
impl Date {
|
||||
@ -22,7 +22,7 @@ impl ToJson for Date {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Nullable<T: ToJson> {
|
||||
Value(T),
|
||||
Null
|
||||
@ -142,7 +142,7 @@ impl <T> From<T> for WebElement
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum FrameId {
|
||||
Short(u16),
|
||||
Element(WebElement),
|
||||
@ -184,7 +184,7 @@ impl ToJson for FrameId {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum LocatorStrategy {
|
||||
CSSSelector,
|
||||
LinkText,
|
||||
|
@ -9,7 +9,7 @@ use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum ErrorStatus {
|
||||
/// The [`ElementClick`] command could not be completed because the
|
||||
/// [element] receiving the events is obscuring the element that was
|
||||
|
@ -71,7 +71,7 @@ fn standard_routes<U:WebDriverExtensionRoute>() -> Vec<(Method, &'static str, Ro
|
||||
(Get, "/status", Route::Status),]
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum Route<U:WebDriverExtensionRoute> {
|
||||
NewSession,
|
||||
DeleteSession,
|
||||
@ -142,7 +142,7 @@ pub trait WebDriverExtensionRoute : Clone + Send + PartialEq {
|
||||
fn command(&self, &Captures, &Json) -> WebDriverResult<WebDriverCommand<Self::Command>>;
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct VoidWebDriverExtensionRoute;
|
||||
|
||||
impl WebDriverExtensionRoute for VoidWebDriverExtensionRoute {
|
||||
@ -153,7 +153,7 @@ impl WebDriverExtensionRoute for VoidWebDriverExtensionRoute {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
struct RequestMatcher<U: WebDriverExtensionRoute> {
|
||||
method: Method,
|
||||
path_regexp: Regex,
|
||||
@ -197,6 +197,7 @@ impl <U: WebDriverExtensionRoute> RequestMatcher<U> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct WebDriverHttpApi<U: WebDriverExtensionRoute> {
|
||||
routes: Vec<(Method, RequestMatcher<U>)>,
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ impl WebDriverResponse {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct CloseWindowResponse {
|
||||
pub window_handles: Vec<String>,
|
||||
}
|
||||
@ -68,7 +68,7 @@ impl ToJson for CloseWindowResponse {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct NewSessionResponse {
|
||||
pub sessionId: String,
|
||||
pub capabilities: json::Json
|
||||
@ -83,7 +83,7 @@ impl NewSessionResponse {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct TimeoutsResponse {
|
||||
pub script: u64,
|
||||
pub pageLoad: u64,
|
||||
@ -100,7 +100,7 @@ impl TimeoutsResponse {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct ValueResponse {
|
||||
pub value: json::Json
|
||||
}
|
||||
@ -113,7 +113,7 @@ impl ValueResponse {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct ElementRectResponse {
|
||||
/// X axis position of the top-left corner of the element relative
|
||||
// to the current browsing context’s document element in CSS reference
|
||||
@ -176,7 +176,7 @@ impl ToJson for WindowRectResponse {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, PartialEq, Debug, Clone)]
|
||||
#[derive(Clone, Debug, PartialEq, RustcEncodable)]
|
||||
pub struct Cookie {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
@ -210,12 +210,12 @@ impl Into<cookie::Cookie<'static>> for Cookie {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct CookieResponse {
|
||||
pub value: Cookie,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct CookiesResponse {
|
||||
pub value: Vec<Cookie>,
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ enum DispatchMessage<U: WebDriverExtensionRoute> {
|
||||
Quit
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Session {
|
||||
id: String
|
||||
}
|
||||
@ -41,6 +41,7 @@ pub trait WebDriverHandler<U: WebDriverExtensionRoute=VoidWebDriverExtensionRout
|
||||
fn delete_session(&mut self, session: &Option<Session>);
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Dispatcher<T: WebDriverHandler<U>,
|
||||
U: WebDriverExtensionRoute> {
|
||||
handler: T,
|
||||
@ -148,6 +149,7 @@ impl<T: WebDriverHandler<U>, U: WebDriverExtensionRoute> Dispatcher<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct HttpHandler<U: WebDriverExtensionRoute> {
|
||||
chan: Mutex<Sender<DispatchMessage<U>>>,
|
||||
api: Mutex<WebDriverHttpApi<U>>
|
||||
|
Loading…
Reference in New Issue
Block a user