public void RDPEGFX_CacheManagement_PositiveTest_CacheToSurface_DestRectsBorderOverlapSurface()
        {
            // Init for capability exchange
            RDPEGFX_CapabilityExchange();

            // Create a surface
            this.TestSite.Log.Add(LogEntryKind.Comment, "Create a Surface.");
            RDPGFX_RECT16 surfRect = RdpegfxTestUtility.ConvertToRect(RdpegfxTestUtility.surfPos, RdpegfxTestUtility.surfWidth, RdpegfxTestUtility.surfHeight);
            Surface       surf     = this.rdpegfxAdapter.CreateAndOutputSurface(surfRect, PixelFormat.PIXEL_FORMAT_ARGB_8888);

            this.TestSite.Assert.IsNotNull(surf, "Surface {0} is created", surf.Id);

            ushort cacheW = (ushort)(RdpegfxTestUtility.cacheRect.right - RdpegfxTestUtility.cacheRect.left);
            ushort cacheH = (ushort)(RdpegfxTestUtility.cacheRect.bottom - RdpegfxTestUtility.cacheRect.top);

            List <RDPGFX_POINT16> destPointList = new List <RDPGFX_POINT16>();
            RDPGFX_POINT16        pos           = new RDPGFX_POINT16(
                (ushort)(RdpegfxTestUtility.surfWidth - cacheW),
                (ushort)(RdpegfxTestUtility.surfHeight - cacheH));

            destPointList.Add(pos);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Copy a rect to cache; and copy the cached rect to surface.");
            uint fid = this.rdpegfxAdapter.FillSurfaceByCachedBitmap(surf, RdpegfxTestUtility.cacheRect, RdpegfxTestUtility.cacheKey, destPointList.ToArray(), null, RdpegfxTestUtility.fillColorRed);

            this.TestSite.Log.Add(LogEntryKind.Debug, "Surface is filled by cached bitmap in frame: {0}.", fid);

            this.rdpegfxAdapter.ExpectFrameAck(fid);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Verify output on SUT Display if the verifySUTDisplay entry in PTF config is true.");
            this.VerifySUTDisplay(false, surfRect);

            // Delete the surface after wait 3 seconds.
            this.rdpegfxAdapter.DeleteSurface(surf.Id);
            this.TestSite.Log.Add(LogEntryKind.Debug, "Surface {0} is deleted", surf.Id);
        }
Example #2
0
 /// <summary>
 /// Convert a position and width/height into Rectangle structure
 /// </summary>
 /// <param name="pos"> Left-top position of a rectangle </param>
 /// <param name="width"> Width of a rectangle </param>
 /// <param name="height"> Height of a rectangle </param>
 /// <returns> Converted rectangle </returns>
 public static RDPGFX_RECT16 ConvertToRect(RDPGFX_POINT16 pos, ushort width, ushort height)
 {
     return(new RDPGFX_RECT16(pos.x, pos.y, (ushort)(pos.x + width), (ushort)(pos.y + height)));
 }
        /// <summary>
        /// Common function to send H264 data to the client
        /// </summary>
        /// <param name="h264DataFile">XML file of H264 data</param>
        /// <param name="isAVC444">Whether need RDP client support AVC444/AVC444v2</param>
        private void SendH264CodecStream(string h264DataFile, bool isAVC444)
        {
            //Load H264 data
            RdpegfxH264TestDatas h264TestData = GetH264TestData(h264DataFile);

            // Init for capability exchange
            this.TestSite.Log.Add(LogEntryKind.Comment, "Do capability exchange.");
            RDPEGFX_CapabilityExchange();
            if (isAVC444)
            {
                this.TestSite.Assume.IsTrue(this.isH264AVC444Supported, "This test case requires RDP client to support AVC444/AVC444v2.");
            }
            else
            {
                this.TestSite.Assume.IsTrue(this.isH264AVC420Supported, "To test H264 codec, client must indicate support for H264 codec in RDPGFX_CAPS_ADVERTISE_PDU");
            }

            this.TestSite.Log.Add(LogEntryKind.Comment, "Create a surface and fill it with green color.");
            // Create & output a surface
            RDPGFX_POINT16 surfPos     = new RDPGFX_POINT16((ushort)h264TestData.SurfaceInfo.outputOriginX, (ushort)h264TestData.SurfaceInfo.outputOriginY);
            RDPGFX_RECT16  surfRect    = RdpegfxTestUtility.ConvertToRect(surfPos, h264TestData.SurfaceInfo.width, h264TestData.SurfaceInfo.height);
            RDPGFX_RECT16  compareRect = RdpegfxTestUtility.ConvertToRect(surfPos, h264TestData.SurfaceInfo.width, h264TestData.SurfaceInfo.height);

            if (isWindowsImplementation && compareRect.top < 32 && compareRect.bottom > 32)
            {
                // Ignore the field of RDP client connection bar
                compareRect.top = 32;
            }
            Surface surf = this.rdpegfxAdapter.CreateAndOutputSurface(surfRect, (PixelFormat)h264TestData.SurfaceInfo.pixelFormat);

            this.TestSite.Assert.IsNotNull(surf, "Surface {0} is created", surf.Id);

            // Send solid fill request to client to fill surface with green color
            RDPGFX_RECT16[] fillRects = { new RDPGFX_RECT16(h264TestData.TestDataList[0].DestRect.left,
                                                            h264TestData.TestDataList[0].DestRect.top,
                                                            h264TestData.TestDataList[0].DestRect.right,
                                                            h264TestData.TestDataList[0].DestRect.bottom) }; // Relative to surface
            uint            fid = this.rdpegfxAdapter.SolidFillSurface(surf, RdpegfxTestUtility.fillColorGreen, fillRects);

            this.TestSite.Log.Add(LogEntryKind.Debug, "Surface is filled with solid color in frame: {0}", fid);
            this.rdpegfxAdapter.ExpectFrameAck(fid);

            // Send H264 codec data
            foreach (TestData data in h264TestData.TestDataList)
            {
                ushort        codecId   = data.codecId;
                PixelFormat   pixFormat = (PixelFormat)data.pixelFormat;
                RDPGFX_RECT16 bmRect    = new RDPGFX_RECT16();
                bmRect.left   = data.DestRect.left;
                bmRect.top    = data.DestRect.top;
                bmRect.right  = data.DestRect.right;
                bmRect.bottom = data.DestRect.bottom;

                if (codecId == (ushort)CodecType.RDPGFX_CODECID_AVC420 && data.AVC420BitmapStream != null)
                {
                    this.TestSite.Log.Add(LogEntryKind.Comment, "Sending H264 AVC420 Encoded Bitmap Data Messages to client.");
                    fid = this.rdpegfxAdapter.SendImageWithH264AVC420Codec(surf.Id, pixFormat, bmRect, data.AVC420BitmapStream.To_RFX_AVC420_BITMAP_STREAM(), data.GetBaseImage());
                    // Test case pass if frame acknowledge is received.
                    this.rdpegfxAdapter.ExpectFrameAck(fid);
                }
                else if (codecId == (ushort)CodecType.RDPGFX_CODECID_AVC444 && data.AVC444BitmapStream != null)
                {
                    this.TestSite.Log.Add(LogEntryKind.Comment, "Sending H264 AVC444 Encoded Bitmap Data Messages to client.");
                    fid = this.rdpegfxAdapter.SendImageWithH264AVC444Codec(surf.Id, pixFormat, bmRect, CodecType.RDPGFX_CODECID_AVC444, data.AVC444BitmapStream.To_RFX_AVC444_BITMAP_STREAM(), data.GetBaseImage());
                    // Test case pass if frame acknowledge is received.
                    this.rdpegfxAdapter.ExpectFrameAck(fid);
                }
                else if (codecId == (ushort)CodecType.RDPGFX_CODECID_AVC444v2 && data.AVC444v2BitmapStream != null)
                {
                    this.TestSite.Log.Add(LogEntryKind.Comment, "Sending H264 AVC444v2 Encoded Bitmap Data Messages to client.");
                    fid = this.rdpegfxAdapter.SendImageWithH264AVC444Codec(surf.Id, pixFormat, bmRect, CodecType.RDPGFX_CODECID_AVC444v2, data.AVC444v2BitmapStream.To_RFX_AVC444V2_BITMAP_STREAM(), data.GetBaseImage());
                    // Test case pass if frame acknowledge is received.
                    this.rdpegfxAdapter.ExpectFrameAck(fid);
                }
                else
                {
                    Site.Assert.Fail("Test data doesn't contain proper H264 encoded data corresponding to codec ID.");
                }

                this.TestSite.Log.Add(LogEntryKind.Comment, "Verify output on SUT Display if the verifySUTDisplay entry in PTF config is true.");
                this.VerifySUTDisplay(true, compareRect, 2);
            }

            // Delete the surface
            this.rdpegfxAdapter.DeleteSurface(surf.Id);
            this.TestSite.Log.Add(LogEntryKind.Debug, "Surface {0} is deleted", surf.Id);
        }
        public void RDPEGFX_SurfaceToScreen_PositiveTest_MultiSurfaceOverlap()
        {
            uint fid;

            this.TestSite.Log.Add(LogEntryKind.Comment, "Do capability exchange.");
            // Init for capability exchange
            RDPEGFX_CapabilityExchange();

            RDPGFX_RECT16 verifyRect = RdpegfxTestUtility.ConvertToRect(RdpegfxTestUtility.surfPos, RdpegfxTestUtility.surfWidth, RdpegfxTestUtility.surfHeight);

            // Init Data for test
            RDPGFX_POINT16[] positions = new RDPGFX_POINT16[4];
            positions[0] = new RDPGFX_POINT16(RdpegfxTestUtility.surfPos.x, RdpegfxTestUtility.surfPos.y);
            positions[1] = new RDPGFX_POINT16((ushort)(RdpegfxTestUtility.surfPos.x + RdpegfxTestUtility.surfWidth / 2), RdpegfxTestUtility.surfPos.y);
            positions[2] = new RDPGFX_POINT16(RdpegfxTestUtility.surfPos.x, (ushort)(RdpegfxTestUtility.surfPos.y + RdpegfxTestUtility.surfHeight / 2));
            positions[3] = new RDPGFX_POINT16(RdpegfxTestUtility.surfPos.x, RdpegfxTestUtility.surfPos.y);

            ushort[] widths = new ushort[4];
            widths[0] = RdpegfxTestUtility.surfWidth;
            widths[1] = (ushort)(RdpegfxTestUtility.surfWidth / 2);
            widths[2] = RdpegfxTestUtility.surfWidth;
            widths[3] = (ushort)(RdpegfxTestUtility.surfWidth / 2);

            ushort[] heights = new ushort[4];
            heights[0] = (ushort)(RdpegfxTestUtility.surfHeight / 2);
            heights[1] = RdpegfxTestUtility.surfHeight;
            heights[2] = (ushort)(RdpegfxTestUtility.surfHeight / 2);
            heights[3] = RdpegfxTestUtility.surfHeight;

            Color[] colors = new Color[4];
            colors[0] = Color.Green;
            colors[1] = Color.Blue;
            colors[2] = Color.Red;
            colors[3] = Color.Yellow;

            Surface[] surfaces = new Surface[4];
            // Test the overlap
            for (int i = 0; i < positions.Length; i++)
            {
                this.TestSite.Log.Add(LogEntryKind.Comment, "Create a surface and fill it with color: {0}.", colors[i]);
                // Create & output a surface
                RDPGFX_RECT16 surfRect = RdpegfxTestUtility.ConvertToRect(positions[i], widths[i], heights[i]);
                surfaces[i] = this.rdpegfxAdapter.CreateAndOutputSurface(surfRect, PixelFormat.PIXEL_FORMAT_XRGB_8888);
                this.TestSite.Assert.IsNotNull(surfaces[i], "Surface {0} is created", surfaces[i].Id);

                // Send solid fill request to client to fill surface with green color
                RDPGFX_RECT16   fillSurfRect = RdpegfxTestUtility.ConvertToRect(RdpegfxTestUtility.imgPos, widths[i], heights[i]);
                RDPGFX_RECT16[] fillRects    = { fillSurfRect }; // Relative to surface
                fid = this.rdpegfxAdapter.SolidFillSurface(surfaces[i], RdpegfxTestUtility.ToRdpgfx_Color32(colors[i]), fillRects);
                this.TestSite.Log.Add(LogEntryKind.Debug, "Surface is filled with solid color in frame: {0}", fid);

                // Expect the client to send a frame acknowledge pdu
                // If the server receives the message, it indicates that the client has been successfully decoded the logical frame of graphics commands
                this.rdpegfxAdapter.ExpectFrameAck(fid);

                this.TestSite.Log.Add(LogEntryKind.Comment, "Verify output on SUT Display if the verifySUTDisplay entry in PTF config is true.");
                this.VerifySUTDisplay(false, verifyRect);
            }
            // Delete the surface
            for (int i = 0; i < surfaces.Length; i++)
            {
                if (surfaces[i] != null)
                {
                    this.rdpegfxAdapter.DeleteSurface(surfaces[i].Id);
                    this.TestSite.Log.Add(LogEntryKind.Debug, "Surface {0} is deleted", surfaces[i].Id);
                }
            }
        }