зеркало из https://github.com/microsoft/TestWinRT.git
Add benchmark for getting new and existing delegate and boxing tests (#60)
* Add benchmark for getting new and existing delegate. * Add box tests
This commit is contained in:
Родитель
d448f7cf94
Коммит
c08bbd40da
|
@ -256,6 +256,16 @@ namespace winrt::BenchmarkComponent::implementation
|
|||
_handler = value.as<Windows::Foundation::IReference<BenchmarkComponent::ProvideInt>>().Value();
|
||||
}
|
||||
|
||||
BenchmarkComponent::ProvideInt ClassWithMarshalingRoutines::NewIntDelegate()
|
||||
{
|
||||
BenchmarkComponent::ProvideInt handler = [] { return 4; };
|
||||
return handler;
|
||||
}
|
||||
BenchmarkComponent::ProvideInt ClassWithMarshalingRoutines::ExistingIntDelegate()
|
||||
{
|
||||
return _existingHandler;
|
||||
}
|
||||
|
||||
WrappedClass::WrappedClass()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace winrt::BenchmarkComponent::implementation
|
|||
winrt::event<Windows::Foundation::EventHandler<int32_t>> _intChanged;
|
||||
winrt::event<Windows::Foundation::EventHandler<double_t>> _doubleChanged;
|
||||
BenchmarkComponent::ProvideInt _handler;
|
||||
BenchmarkComponent::ProvideInt _existingHandler = [] { return 4; };
|
||||
|
||||
public:
|
||||
ClassWithMarshalingRoutines();
|
||||
|
@ -118,6 +119,9 @@ namespace winrt::BenchmarkComponent::implementation
|
|||
void NullableTimeSpan(Windows::Foundation::IReference<Windows::Foundation::TimeSpan> const& value);
|
||||
Windows::Foundation::IInspectable BoxedDelegate();
|
||||
void BoxedDelegate(Windows::Foundation::IInspectable const& value);
|
||||
|
||||
BenchmarkComponent::ProvideInt NewIntDelegate();
|
||||
BenchmarkComponent::ProvideInt ExistingIntDelegate();
|
||||
};
|
||||
|
||||
struct EventOperations : EventOperationsT<EventOperations>
|
||||
|
|
|
@ -97,6 +97,9 @@ namespace BenchmarkComponent
|
|||
Windows.Foundation.IReference<NonBlittable> NullableNonBlittableStruct{ get; set; };
|
||||
Windows.Foundation.IReference<Windows.Foundation.TimeSpan> NullableTimeSpan{ get; set; };
|
||||
Object BoxedDelegate{ get; set; };
|
||||
|
||||
ProvideInt NewIntDelegate{ get; };
|
||||
ProvideInt ExistingIntDelegate{ get; };
|
||||
}
|
||||
|
||||
[default_interface]
|
||||
|
|
|
@ -188,6 +188,24 @@ namespace TestComponent
|
|||
Windows.Foundation.Collections.IVectorView<String> GetStringVectorSubset(Windows.Foundation.Collections.IVectorView<String> stringVector, Int32 startIndex);
|
||||
Windows.Foundation.Collections.IVectorView<Blittable> GetBlittableVectorSubset(Windows.Foundation.Collections.IVectorView<Blittable> blittableVector, Int32 startIndex);
|
||||
Windows.Foundation.Collections.IVectorView<NonBlittable> GetNonBlittableVectorSubset(Windows.Foundation.Collections.IVectorView<NonBlittable> nonBlittableVector, Int32 startIndex);
|
||||
|
||||
Object Box1(UInt8 param, Object boxedParam);
|
||||
Object Box2(UInt16 param, Object boxedParam);
|
||||
Object Box3(UInt32 param, Object boxedParam);
|
||||
Object Box4(UInt64 param, Object boxedParam);
|
||||
Object Box5(Int16 param, Object boxedParam);
|
||||
Object Box6(Int32 param, Object boxedParam);
|
||||
Object Box7(Int64 param, Object boxedParam);
|
||||
Object Box8(Boolean param, Object boxedParam);
|
||||
Object Box9(Single param, Object boxedParam);
|
||||
Object Box10(Double param, Object boxedParam);
|
||||
Object Box11(Guid param, Object boxedParam);
|
||||
Object Box12(Char param, Object boxedParam);
|
||||
Object Box13(String param, Object boxedParam);
|
||||
Object Box14(Windows.Foundation.TimeSpan param, Object boxedParam);
|
||||
Object Box15(Blittable param, Object boxedParam);
|
||||
Object Box16(NonBlittable param, Object boxedParam);
|
||||
Object Box17(Windows.Foundation.DateTime param, Object boxedParam);
|
||||
}
|
||||
|
||||
delegate void TestHandler(ITests tests);
|
||||
|
|
|
@ -614,6 +614,34 @@ namespace winrt::TestComponent::implementation
|
|||
TEST_GEN(Blittable, Blittable);
|
||||
TEST_GEN(NonBlittable, NonBlittable);
|
||||
|
||||
#undef TEST_GEN
|
||||
|
||||
#define TEST_GEN(number, type, ...) \
|
||||
auto Box ## number ##(type param, IInspectable boxedParam) \
|
||||
{ \
|
||||
auto unboxedValue = unbox_value<type>(boxedParam); \
|
||||
TEST_REQUIRE_N(L"Param", ## number ##, param == unboxedValue); \
|
||||
return box_value(param); \
|
||||
}
|
||||
|
||||
TEST_GEN(1, uint8_t);
|
||||
TEST_GEN(2, uint16_t);
|
||||
TEST_GEN(3, uint32_t);
|
||||
TEST_GEN(4, uint64_t);
|
||||
TEST_GEN(5, int16_t);
|
||||
TEST_GEN(6, int32_t);
|
||||
TEST_GEN(7, int64_t);
|
||||
TEST_GEN(8, bool);
|
||||
TEST_GEN(9, float);
|
||||
TEST_GEN(10, double);
|
||||
TEST_GEN(11, guid);
|
||||
TEST_GEN(12, char16_t);
|
||||
TEST_GEN(13, hstring);
|
||||
TEST_GEN(14, TimeSpan);
|
||||
TEST_GEN(15, Blittable);
|
||||
TEST_GEN(16, NonBlittable);
|
||||
TEST_GEN(17, DateTime);
|
||||
|
||||
#undef TEST_GEN
|
||||
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче