mirror of
https://github.com/servo/servo.git
synced 2025-06-24 00:54:32 +01:00
Add tests for return values of interface methods.
This commit is contained in:
parent
e5eac5b538
commit
ab8b62e28d
2 changed files with 73 additions and 0 deletions
|
@ -86,6 +86,41 @@ pub trait TestBindingMethods {
|
||||||
fn GetInterfaceAttributeNullable(&self) -> Option<Temporary<Blob>>;
|
fn GetInterfaceAttributeNullable(&self) -> Option<Temporary<Blob>>;
|
||||||
fn SetInterfaceAttributeNullable(&self, _: Option<JSRef<Blob>>) {}
|
fn SetInterfaceAttributeNullable(&self, _: Option<JSRef<Blob>>) {}
|
||||||
|
|
||||||
|
fn ReceiveVoid(&self) -> () {}
|
||||||
|
fn ReceiveBoolean(&self) -> bool { false }
|
||||||
|
fn ReceiveByte(&self) -> i8 { 0 }
|
||||||
|
fn ReceiveOctet(&self) -> u8 { 0 }
|
||||||
|
fn ReceiveShort(&self) -> i16 { 0 }
|
||||||
|
fn ReceiveUnsignedShort(&self) -> u16 { 0 }
|
||||||
|
fn ReceiveLong(&self) -> i32 { 0 }
|
||||||
|
fn ReceiveUnsignedLong(&self) -> u32 { 0 }
|
||||||
|
fn ReceiveLongLong(&self) -> i64 { 0 }
|
||||||
|
fn ReceiveUnsignedLongLong(&self) -> u64 { 0 }
|
||||||
|
fn ReceiveFloat(&self) -> f32 { 0. }
|
||||||
|
fn ReceiveDouble(&self) -> f64 { 0. }
|
||||||
|
fn ReceiveString(&self) -> DOMString { "".to_owned() }
|
||||||
|
fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) }
|
||||||
|
fn ReceiveEnum(&self) -> TestEnum { _empty }
|
||||||
|
fn ReceiveInterface(&self) -> Temporary<Blob>;
|
||||||
|
fn ReceiveAny(&self, _: *JSContext) -> JSVal { NullValue() }
|
||||||
|
|
||||||
|
fn ReceiveNullableBoolean(&self) -> Option<bool> { Some(false) }
|
||||||
|
fn ReceiveNullableByte(&self) -> Option<i8> { Some(0) }
|
||||||
|
fn ReceiveNullableOctet(&self) -> Option<u8> { Some(0) }
|
||||||
|
fn ReceiveNullableShort(&self) -> Option<i16> { Some(0) }
|
||||||
|
fn ReceiveNullableUnsignedShort(&self) -> Option<u16> { Some(0) }
|
||||||
|
fn ReceiveNullableLong(&self) -> Option<i32> { Some(0) }
|
||||||
|
fn ReceiveNullableUnsignedLong(&self) -> Option<u32> { Some(0) }
|
||||||
|
fn ReceiveNullableLongLong(&self) -> Option<i64> { Some(0) }
|
||||||
|
fn ReceiveNullableUnsignedLongLong(&self) -> Option<u64> { Some(0) }
|
||||||
|
fn ReceiveNullableFloat(&self) -> Option<f32> { Some(0.) }
|
||||||
|
fn ReceiveNullableDouble(&self) -> Option<f64> { Some(0.) }
|
||||||
|
fn ReceiveNullableString(&self) -> Option<DOMString> { Some("".to_owned()) }
|
||||||
|
fn ReceiveNullableByteString(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
|
||||||
|
fn ReceiveNullableEnum(&self) -> Option<TestEnum> { Some(_empty) }
|
||||||
|
fn ReceiveNullableInterface(&self) -> Option<Temporary<Blob>>;
|
||||||
|
fn ReceiveNullableAny(&self, _: *JSContext) -> Option<JSVal> { Some(NullValue()) }
|
||||||
|
|
||||||
fn PassBoolean(&self, _: bool) {}
|
fn PassBoolean(&self, _: bool) {}
|
||||||
fn PassByte(&self, _: i8) {}
|
fn PassByte(&self, _: i8) {}
|
||||||
fn PassOctet(&self, _: u8) {}
|
fn PassOctet(&self, _: u8) {}
|
||||||
|
@ -216,6 +251,14 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
Some(Blob::new(&*window))
|
Some(Blob::new(&*window))
|
||||||
}
|
}
|
||||||
|
fn ReceiveInterface(&self) -> Temporary<Blob> {
|
||||||
|
let window = self.window.root();
|
||||||
|
Blob::new(&*window)
|
||||||
|
}
|
||||||
|
fn ReceiveNullableInterface(&self) -> Option<Temporary<Blob>> {
|
||||||
|
let window = self.window.root();
|
||||||
|
Some(Blob::new(&*window))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reflectable for TestBinding {
|
impl Reflectable for TestBinding {
|
||||||
|
|
|
@ -91,6 +91,36 @@ interface TestBinding {
|
||||||
// attribute (HTMLElement or long)? unionAttributeNullable;
|
// attribute (HTMLElement or long)? unionAttributeNullable;
|
||||||
// attribute (DOMString or FormData)? union2AttributeNullable;
|
// attribute (DOMString or FormData)? union2AttributeNullable;
|
||||||
|
|
||||||
|
void receiveVoid();
|
||||||
|
boolean receiveBoolean();
|
||||||
|
byte receiveByte();
|
||||||
|
octet receiveOctet();
|
||||||
|
short receiveShort();
|
||||||
|
unsigned short receiveUnsignedShort();
|
||||||
|
long receiveLong();
|
||||||
|
unsigned long receiveUnsignedLong();
|
||||||
|
long long receiveLongLong();
|
||||||
|
unsigned long long receiveUnsignedLongLong();
|
||||||
|
DOMString receiveString();
|
||||||
|
ByteString receiveByteString();
|
||||||
|
TestEnum receiveEnum();
|
||||||
|
Blob receiveInterface();
|
||||||
|
any receiveAny();
|
||||||
|
|
||||||
|
byte? receiveNullableByte();
|
||||||
|
boolean? receiveNullableBoolean();
|
||||||
|
octet? receiveNullableOctet();
|
||||||
|
short? receiveNullableShort();
|
||||||
|
unsigned short? receiveNullableUnsignedShort();
|
||||||
|
long? receiveNullableLong();
|
||||||
|
unsigned long? receiveNullableUnsignedLong();
|
||||||
|
long long? receiveNullableLongLong();
|
||||||
|
unsigned long long? receiveNullableUnsignedLongLong();
|
||||||
|
DOMString? receiveNullableString();
|
||||||
|
ByteString? receiveNullableByteString();
|
||||||
|
TestEnum? receiveNullableEnum();
|
||||||
|
Blob? receiveNullableInterface();
|
||||||
|
|
||||||
void passBoolean(boolean arg);
|
void passBoolean(boolean arg);
|
||||||
void passByte(byte arg);
|
void passByte(byte arg);
|
||||||
void passOctet(octet arg);
|
void passOctet(octet arg);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue