[WINDOWSCODECS_WINETEST]
authorAmine Khaldi <amine.khaldi@reactos.org>
Wed, 8 Oct 2014 19:32:14 +0000 (19:32 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Wed, 8 Oct 2014 19:32:14 +0000 (19:32 +0000)
* Sync with Wine 1.7.27.
CORE-8540

svn path=/trunk/; revision=64616

rostests/winetests/windowscodecs/converter.c
rostests/winetests/windowscodecs/metadata.c
rostests/winetests/windowscodecs/propertybag.c
rostests/winetests/windowscodecs/tiffformat.c

index 1cdbafa..2edae4b 100644 (file)
@@ -383,6 +383,7 @@ typedef struct property_opt_test_data
 
 static const WCHAR wszTiffCompressionMethod[] = {'T','i','f','f','C','o','m','p','r','e','s','s','i','o','n','M','e','t','h','o','d',0};
 static const WCHAR wszCompressionQuality[] = {'C','o','m','p','r','e','s','s','i','o','n','Q','u','a','l','i','t','y',0};
+static const WCHAR wszInterlaceOption[] = {'I','n','t','e','r','l','a','c','e','O','p','t','i','o','n',0};
 
 static const struct property_opt_test_data testdata_tiff_props[] = {
     { wszTiffCompressionMethod, VT_UI1,         VT_UI1,  WICTiffCompressionDontCare },
@@ -513,8 +514,16 @@ static void test_encoder_properties(const CLSID* clsid_encoder, IPropertyBag2 *o
     }
 }
 
+struct setting {
+    const WCHAR *name;
+    PROPBAG2_TYPE type;
+    VARTYPE vt;
+    void *value;
+};
+
 static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* clsid_encoder,
-    const struct bitmap_data **dsts, const CLSID *clsid_decoder, const char *name)
+    const struct bitmap_data **dsts, const CLSID *clsid_decoder, WICRect *rc,
+    const struct setting *settings, const char *name)
 {
     HRESULT hr;
     IWICBitmapEncoder *encoder;
@@ -559,6 +568,26 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
                     if(options)
                         test_encoder_properties(clsid_encoder, options);
 
+                    if (settings)
+                    {
+                        int j;
+                        for (j=0; settings[j].name; j++)
+                        {
+                            PROPBAG2 propbag;
+                            VARIANT var;
+
+                            memset(&propbag, 0, sizeof(propbag));
+                            memset(&var, 0, sizeof(var));
+                            propbag.pstrName = (LPOLESTR)settings[j].name;
+                            propbag.dwType = settings[j].type;
+                            V_VT(&var) = settings[j].vt;
+                            V_UNKNOWN(&var) = settings[j].value;
+
+                            hr = IPropertyBag2_Write(options, 1, &propbag, &var);
+                            ok(SUCCEEDED(hr), "Writing property %s failed, hr=%x\n", wine_dbgstr_w(settings[j].name), hr);
+                        }
+                    }
+
                     hr = IWICBitmapFrameEncode_Initialize(frameencode, options);
                     ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr);
 
@@ -570,8 +599,14 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
                     hr = IWICBitmapFrameEncode_SetSize(frameencode, srcs[i]->width, srcs[i]->height);
                     ok(SUCCEEDED(hr), "SetSize failed, hr=%x\n", hr);
 
-                    hr = IWICBitmapFrameEncode_WriteSource(frameencode, &src_obj->IWICBitmapSource_iface, NULL);
-                    ok(SUCCEEDED(hr), "WriteSource failed, hr=%x\n", hr);
+                    hr = IWICBitmapFrameEncode_WriteSource(frameencode, &src_obj->IWICBitmapSource_iface, rc);
+                    if (rc && (rc->Width <= 0 || rc->Height <= 0))
+                    {
+                        /* WriteSource fails but WriteSource_Proxy succeeds. */
+                        ok(hr == E_INVALIDARG, "WriteSource failed, hr=%x (%s)\n", hr, name);
+                        hr = IWICBitmapFrameEncode_WriteSource_Proxy(frameencode, &src_obj->IWICBitmapSource_iface, rc);
+                    }
+                    ok(SUCCEEDED(hr), "WriteSource failed, hr=%x (%s)\n", hr, name);
 
                     hr = IWICBitmapFrameEncode_Commit(frameencode);
                     ok(SUCCEEDED(hr), "Commit failed, hr=%x\n", hr);
@@ -640,7 +675,39 @@ static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encod
     dsts[0] = dst;
     dsts[1] = NULL;
 
-    test_multi_encoder(srcs, clsid_encoder, dsts, clsid_decoder, name);
+    test_multi_encoder(srcs, clsid_encoder, dsts, clsid_decoder, NULL, NULL, name);
+}
+
+static void test_encoder_rects(void)
+{
+    const struct bitmap_data *srcs[2];
+    const struct bitmap_data *dsts[2];
+    WICRect rc;
+
+    srcs[0] = &testdata_24bppBGR;
+    srcs[1] = NULL;
+    dsts[0] = &testdata_24bppBGR;
+    dsts[1] = NULL;
+
+    rc.X = 0;
+    rc.Y = 0;
+    rc.Width = 4;
+    rc.Height = 2;
+
+    test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects full");
+
+    rc.Width = 0;
+    test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects width=0");
+
+    rc.Width = -1;
+    test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects width=-1");
+
+    rc.Width = 4;
+    rc.Height = 0;
+    test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects height=0");
+
+    rc.Height = -1;
+    test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects height=-1");
 }
 
 static const struct bitmap_data *multiple_frames[3] = {
@@ -648,6 +715,15 @@ static const struct bitmap_data *multiple_frames[3] = {
     &testdata_24bppBGR,
     NULL};
 
+static const struct bitmap_data *single_frame[2] = {
+    &testdata_24bppBGR,
+    NULL};
+
+static const struct setting png_interlace_settings[] = {
+    {wszInterlaceOption, PROPBAG2_TYPE_DATA, VT_BOOL, (void*)VARIANT_TRUE},
+    {NULL}
+};
+
 START_TEST(converter)
 {
     CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
@@ -678,7 +754,12 @@ START_TEST(converter)
                  &testdata_24bppBGR, &CLSID_WICTiffDecoder, "TIFF encoder 24bppBGR");
 
     test_multi_encoder(multiple_frames, &CLSID_WICTiffEncoder,
-                       multiple_frames, &CLSID_WICTiffDecoder, "TIFF encoder multi-frame");
+                       multiple_frames, &CLSID_WICTiffDecoder, NULL, NULL, "TIFF encoder multi-frame");
+
+    test_encoder_rects();
+
+    test_multi_encoder(single_frame, &CLSID_WICPngEncoder,
+                       single_frame, &CLSID_WICPngDecoder, NULL, png_interlace_settings, "PNG encoder interlaced");
 
     CoUninitialize();
 }
index 06c85cc..5757003 100644 (file)
@@ -850,7 +850,13 @@ static void test_create_reader(void)
         stream, &reader);
 todo_wine
     ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
-    if (FAILED(hr)) return;
+    /* NOTE: removed once Wine is fixed */
+    if (FAILED(hr))
+    {
+        IStream_Release(stream);
+        IWICComponentFactory_Release(factory);
+        return;
+    }
 
     if (SUCCEEDED(hr))
     {
index 0212e18..1caee57 100644 (file)
@@ -72,10 +72,12 @@ static void test_propertybag_getpropertyinfo(IPropertyBag2 *property, ULONG expe
     ok(pb[0].vt == VT_UI1, "Invalid variant type, pb[0].vt=%x\n", pb[0].vt);
     ok(pb[0].dwType == PROPBAG2_TYPE_DATA, "Invalid variant type, pb[0].dwType=%x\n", pb[0].dwType);
     ok(lstrcmpW(pb[0].pstrName, wszTestProperty1) == 0, "Invalid property name, pb[0].pstrName=%s\n", wine_dbgstr_w(pb[0].pstrName));
+    CoTaskMemFree(pb[0].pstrName);
 
     ok(pb[1].vt == VT_R4, "Invalid variant type, pb[1].vt=%x\n", pb[1].vt);
     ok(pb[1].dwType == PROPBAG2_TYPE_DATA, "Invalid variant type, pb[1].dwType=%x\n", pb[1].dwType);
     ok(lstrcmpW(pb[1].pstrName, wszTestProperty2) == 0, "Invalid property name, pb[1].pstrName=%s\n", wine_dbgstr_w(pb[1].pstrName));
+    CoTaskMemFree(pb[1].pstrName);
 }
 
 static void test_propertybag_countproperties(IPropertyBag2 *property, ULONG expected_count)
index a6d4915..fa4371d 100644 (file)
@@ -241,6 +241,9 @@ static void test_QueryCapability(void)
 todo_wine
     ok(hr == WINCODEC_ERR_COMPONENTNOTFOUND, "expected WINCODEC_ERR_COMPONENTNOTFOUND, got %#x\n", hr);
 
+    if (SUCCEEDED(hr))
+        IWICBitmapDecoder_Release(decoder);
+
     pos.QuadPart = 0;
     hr = IStream_Seek(stream, pos, SEEK_SET, NULL);
     ok(hr == S_OK, "IStream_Seek error %#x\n", hr);