Skip to content

Commit

Permalink
Complete signature testing (#1118)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Sep 8, 2021
1 parent 7d3ab13 commit 21ed8f2
Show file tree
Hide file tree
Showing 7 changed files with 454 additions and 0 deletions.
Binary file modified .windows/winmd/component.winmd
Binary file not shown.
Binary file modified .windows/x64/component.dll
Binary file not shown.
Binary file modified .windows/x86/component.dll
Binary file not shown.
115 changes: 115 additions & 0 deletions tests/component/Signatures.Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,121 @@ namespace winrt::Component::Signatures::implementation
check(std::equal(a.begin(), a.end(), c.begin(), c.end()));
check(std::equal(a.begin(), a.end(), d.begin(), d.end()));
}

static Structs::Blittable SignatureBlittable(Structs::Blittable const& a, Structs::Blittable const& b, Structs::Blittable& c)
{
check(a == b);
c = a;
return a;
}
static com_array<Structs::Blittable> ArraySignatureBlittable(array_view<Structs::Blittable const> a, array_view<Structs::Blittable> b, com_array<Structs::Blittable>& c)
{
check(a.size() == b.size());
check(c.size() == 0);
std::copy(a.begin(), a.end(), b.begin());
c = com_array(a.begin(), a.end());
return com_array(a.begin(), a.end());
}
static void CallSignatureBlittable(winrt::Component::Signatures::SignatureBlittable const& handler)
{
Structs::Blittable a{ true, L'A', 1,2,3,4, -1, -2, -3, 1.0f, 0.1, guid("B0180C8C-8FEB-448A-A915-AC92E05135FE") };
Structs::Blittable b;
auto c = handler(a, a, b);
check(a == b);
check(a == c);
}
static void CallArraySignatureBlittable(winrt::Component::Signatures::ArraySignatureBlittable const& handler)
{
std::array a{
Structs::Blittable{ true, L'A', 1,2,3,4, -1, -2, -3, 1.0f, 0.1, guid("B0180C8C-8FEB-448A-A915-AC92E05135FE") },
Structs::Blittable{ false, L'B', 1,2,3,4, -1, -2, -3, 1.0f, 0.1, guid("9E234A6E-DF89-4891-AAD5-632692BBB1DC") },
Structs::Blittable{ true, L'C', 1,2,3,4, -1, -2, -3, 1.0f, 0.1, guid("286F8B75-2DF4-49CF-841C-52438E2D5326") },
};

std::array<Structs::Blittable, 3> b;
com_array<Structs::Blittable> c;
com_array d = handler(a, b, c);
check(a == b);
check(std::equal(a.begin(), a.end(), c.begin(), c.end()));
check(std::equal(a.begin(), a.end(), d.begin(), d.end()));
}

static Structs::NonBlittable SignatureNonBlittable(Structs::NonBlittable const& a, Structs::NonBlittable const& b, Structs::NonBlittable& c)
{
check(a == b);
c = a;
return a;
}
static com_array<Structs::NonBlittable> ArraySignatureNonBlittable(array_view<Structs::NonBlittable const> a, array_view<Structs::NonBlittable> b, com_array<Structs::NonBlittable>& c)
{
check(a.size() == b.size());
check(c.size() == 0);
std::copy(a.begin(), a.end(), b.begin());
c = com_array(a.begin(), a.end());
return com_array(a.begin(), a.end());
}
static void CallSignatureNonBlittable(winrt::Component::Signatures::SignatureNonBlittable const& handler)
{
Structs::NonBlittable a{ L"string", 1234 };
Structs::NonBlittable b;
auto c = handler(a, a, b);
check(a == b);
check(a == c);
}
static void CallArraySignatureNonBlittable(winrt::Component::Signatures::ArraySignatureNonBlittable const& handler)
{
std::array a{
Structs::NonBlittable{ L"first", 1, },
Structs::NonBlittable{ L"second", 2, },
Structs::NonBlittable{ L"third", 3, },
};

std::array<Structs::NonBlittable, 3> b;
com_array<Structs::NonBlittable> c;
com_array d = handler(a, b, c);
check(a == b);
check(std::equal(a.begin(), a.end(), c.begin(), c.end()));
check(std::equal(a.begin(), a.end(), d.begin(), d.end()));
}

static Structs::Nested SignatureNested(Structs::Nested const& a, Structs::Nested const& b, Structs::Nested& c)
{
check(a == b);
c = a;
return a;
}
static com_array<Structs::Nested> ArraySignatureNested(array_view<Structs::Nested const> a, array_view<Structs::Nested> b, com_array<Structs::Nested>& c)
{
check(a.size() == b.size());
check(c.size() == 0);
std::copy(a.begin(), a.end(), b.begin());
c = com_array(a.begin(), a.end());
return com_array(a.begin(), a.end());
}
static void CallSignatureNested(winrt::Component::Signatures::SignatureNested const& handler)
{
Structs::Nested a{ { true, L'A', 1,2,3,4, -1, -2, -3, 1.0f, 0.1, guid("B0180C8C-8FEB-448A-A915-AC92E05135FE") }, { L"string", 1234 } };
Structs::Nested b;
auto c = handler(a, a, b);
check(a == b);
check(a == c);
}
static void CallArraySignatureNested(winrt::Component::Signatures::ArraySignatureNested const& handler)
{
std::array a{
Structs::Nested{ { true, L'A', 1,2,3,4, -1, -2, -3, 1.0f, 0.1, guid("B0180C8C-8FEB-448A-A915-AC92E05135FE") }, { L"string", 123 } },
Structs::Nested{ { false, L'B', 1,2,3,4, -1, -2, -3, 1.0f, 0.1, guid("9E234A6E-DF89-4891-AAD5-632692BBB1DC") }, { L"string", 456 } },
Structs::Nested{ { true, L'C', 1,2,3,4, -1, -2, -3, 1.0f, 0.1, guid("286F8B75-2DF4-49CF-841C-52438E2D5326") }, { L"string", 789 } }
};

std::array<Structs::Nested, 3> b;
com_array<Structs::Nested> c;
com_array d = handler(a, b, c);
check(a == b);
check(std::equal(a.begin(), a.end(), c.begin(), c.end()));
check(std::equal(a.begin(), a.end(), d.begin(), d.end()));
}

};
}
namespace winrt::Component::Signatures::factory_implementation
Expand Down
24 changes: 24 additions & 0 deletions tests/component/winrt.idl
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ namespace Component
delegate Component.Simple.Class SignatureClass(Component.Simple.Class a, out Component.Simple.Class b);
delegate Component.Simple.Class[] ArraySignatureClass(Component.Simple.Class[] a, ref Component.Simple.Class[] b, out Component.Simple.Class[] c);

delegate Component.Structs.Blittable SignatureBlittable(Component.Structs.Blittable a, ref const Component.Structs.Blittable b, out Component.Structs.Blittable c);
delegate Component.Structs.Blittable[] ArraySignatureBlittable(Component.Structs.Blittable[] a, ref Component.Structs.Blittable[] b, out Component.Structs.Blittable[] c);

delegate Component.Structs.NonBlittable SignatureNonBlittable(Component.Structs.NonBlittable a, ref const Component.Structs.NonBlittable b, out Component.Structs.NonBlittable c);
delegate Component.Structs.NonBlittable[] ArraySignatureNonBlittable(Component.Structs.NonBlittable[] a, ref Component.Structs.NonBlittable[] b, out Component.Structs.NonBlittable[] c);

delegate Component.Structs.Nested SignatureNested(Component.Structs.Nested a, ref const Component.Structs.Nested b, out Component.Structs.Nested c);
delegate Component.Structs.Nested[] ArraySignatureNested(Component.Structs.Nested[] a, ref Component.Structs.Nested[] b, out Component.Structs.Nested[] c);

runtimeclass Test
{
static Boolean SignatureBoolean(Boolean a, out Boolean b);
Expand Down Expand Up @@ -271,6 +280,21 @@ namespace Component
static Component.Simple.Class[] ArraySignatureClass(Component.Simple.Class[] a, ref Component.Simple.Class[] b, out Component.Simple.Class[] c);
static void CallSignatureClass(SignatureClass handler);
static void CallArraySignatureClass(ArraySignatureClass handler);

static Component.Structs.Blittable SignatureBlittable(Component.Structs.Blittable a, ref const Component.Structs.Blittable b, out Component.Structs.Blittable c);
static Component.Structs.Blittable[] ArraySignatureBlittable(Component.Structs.Blittable[] a, ref Component.Structs.Blittable[] b, out Component.Structs.Blittable[] c);
static void CallSignatureBlittable(SignatureBlittable handler);
static void CallArraySignatureBlittable(ArraySignatureBlittable handler);

static Component.Structs.NonBlittable SignatureNonBlittable(Component.Structs.NonBlittable a, ref const Component.Structs.NonBlittable b, out Component.Structs.NonBlittable c);
static Component.Structs.NonBlittable[] ArraySignatureNonBlittable(Component.Structs.NonBlittable[] a, ref Component.Structs.NonBlittable[] b, out Component.Structs.NonBlittable[] c);
static void CallSignatureNonBlittable(SignatureNonBlittable handler);
static void CallArraySignatureNonBlittable(ArraySignatureNonBlittable handler);

static Component.Structs.Nested SignatureNested(Component.Structs.Nested a, ref const Component.Structs.Nested b, out Component.Structs.Nested c);
static Component.Structs.Nested[] ArraySignatureNested(Component.Structs.Nested[] a, ref Component.Structs.Nested[] b, out Component.Structs.Nested[] c);
static void CallSignatureNested(SignatureNested handler);
static void CallArraySignatureNested(ArraySignatureNested handler);
}
}
}
1 change: 1 addition & 0 deletions tests/winrt/signatures/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ fn main() {
windows::build! {
Component::Signatures::*,
Component::Simple::Class,
Windows::Foundation::PropertyValue,
Windows::Win32::Foundation::{E_NOINTERFACE, E_POINTER, S_FALSE, S_OK},
};
}
Loading

0 comments on commit 21ed8f2

Please sign in to comment.