From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/cryptowinrt/tests/crypto.c | 34 ++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/dlls/cryptowinrt/tests/crypto.c b/dlls/cryptowinrt/tests/crypto.c index 260287dbd23..926901d3f07 100644 --- a/dlls/cryptowinrt/tests/crypto.c +++ b/dlls/cryptowinrt/tests/crypto.c @@ -208,9 +208,14 @@ static struct bool_async_handler default_bool_async_handler = {{&bool_async_hand static void test_CryptobufferStatics(void) { static const WCHAR *cryptobuffer_statics_name = L"Windows.Security.Cryptography.CryptographicBuffer"; + static const WCHAR *buffer_name = L"Windows.Storage.Streams.Buffer"; ICryptographicBufferStatics *cryptobuffer_statics; - IActivationFactory *factory; + IActivationFactory *factory, *factory2; + IBufferFactory *buffer_factory; + const WCHAR *base64_str; + IBuffer *buffer; HSTRING str; + UINT32 len; HRESULT hr; LONG ref;
@@ -233,6 +238,33 @@ static void test_CryptobufferStatics(void) hr = IActivationFactory_QueryInterface( factory, &IID_ICryptographicBufferStatics, (void **)&cryptobuffer_statics ); ok( hr == S_OK, "got hr %#lx.\n", hr );
+ hr = ICryptographicBufferStatics_EncodeToBase64String( cryptobuffer_statics, NULL, &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + base64_str = WindowsGetStringRawBuffer( str, &len ); + ok( !wcscmp( L"", base64_str ) && !len, "got str %s, len %d.\n", wine_dbgstr_w( base64_str ), len ); + WindowsDeleteString( str ); + + hr = WindowsCreateString( buffer_name, wcslen( buffer_name ), &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory2 ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + hr = IActivationFactory_QueryInterface( factory2, &IID_IBufferFactory, (void **)&buffer_factory ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + WindowsDeleteString( str ); + + hr = IBufferFactory_Create( buffer_factory, 0, &buffer ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + hr = ICryptographicBufferStatics_EncodeToBase64String( cryptobuffer_statics, buffer, &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + base64_str = WindowsGetStringRawBuffer( str, &len ); + ok( !wcscmp( L"", base64_str ) && !len, "got str %s, len %d.\n", wine_dbgstr_w( base64_str ), len ); + WindowsDeleteString( str ); + + IBuffer_Release( buffer ); + IBufferFactory_Release( buffer_factory ); + IActivationFactory_Release( factory2 ); + ref = ICryptographicBufferStatics_Release( cryptobuffer_statics ); ok( ref == 2, "got ref %ld.\n", ref ); ref = IActivationFactory_Release( factory );