Esempio n. 1
0
        /// <summary>
        /// Covert MonitorLayout_OrientationValues to DEVMODE orientation value
        /// </summary>
        /// <param name="orientation">MonitorLayout_OrientationValues orientation</param>
        /// <returns></returns>
        private int OrientationToDEVMODEValue(MonitorLayout_OrientationValues orientation)
        {
            switch (orientation)
            {
            case MonitorLayout_OrientationValues.ORIENTATION_LANDSCAPE:
                return(0);

            case MonitorLayout_OrientationValues.ORIENTATION_PORTRAIT:
                return(1);

            case MonitorLayout_OrientationValues.ORIENTATION_LANDSCAPE_FLIPPED:
                return(2);

            case MonitorLayout_OrientationValues.ORIENTATION_PORTRAIT_FLIPPED:
                return(3);

            default:
                return(0);
            }
        }
        /// <summary>
        /// Common test body
        /// </summary>
        private void ChangeDesktopOrientation(string caseName, MonitorLayout_OrientationValues orientation, bool enhancedAdapter = false)
        {
            if (!enhancedAdapter)
            {
                int result = this.rdpedispSutControlAdapter.TriggerOrientationChangeOnClient(caseName, OrientationToDEVMODEValue(orientation));
                if (result >= 0)
                {
                    // Wait for screen orientation change
                    System.Threading.Thread.Sleep(1000);
                    result = this.rdpedispSutControlAdapter.TriggerMaximizeRDPClientWindow(caseName);
                    // Wait for maximize RDP client Window
                    System.Threading.Thread.Sleep(4000);
                }
                this.TestSite.Assert.IsTrue(result >= 0, "Test case fails due to fail operation.");
            }

            this.TestSite.Log.Add(LogEntryKind.Comment, "Expect Display Monitor Layout PDU to change orientation");
            DISPLAYCONTROL_MONITOR_LAYOUT_PDU monitorLayoutPDU = this.rdpedispAdapter.expectMonitorLayoutPDU();

            this.Site.Assert.AreEqual <uint>(40, monitorLayoutPDU.MonitorLayoutSize, "This field MUST be set to 40 bytes, the size of the DISPLAYCONTROL_MONITOR_LAYOUT structure (MS-RDPEDISP section 2.2.2.2.1).");
            this.Site.Assert.AreEqual <uint>(1, monitorLayoutPDU.NumMonitors, "Only one Monitor for this case");
            DISPLAYCONTROL_MONITOR_LAYOUT monitor = monitorLayoutPDU.Monitors[0];

            this.Site.Assert.AreEqual <MonitorLayout_FlagValues>(MonitorLayout_FlagValues.DISPLAYCONTROL_MONITOR_PRIMARY, monitor.Flags, "Client should set this monitor to primary monitor");
            this.Site.Assert.AreEqual <int>(0, monitor.Left, "The left point of the only one monitor should be 0");
            this.Site.Assert.AreEqual <int>(0, monitor.Top, "The Top point of the only one monitor should be 0");
            if (orientation == MonitorLayout_OrientationValues.ORIENTATION_PORTRAIT || orientation == MonitorLayout_OrientationValues.ORIENTATION_PORTRAIT_FLIPPED)
            {
                this.Site.Assert.AreEqual <uint>(originalDesktopHeight, monitor.Width, "The width of monitor MUST be {0}", originalDesktopHeight);
                this.Site.Assert.AreEqual <uint>(originalDesktopWidth, monitor.Height, "The height of monitor MUST be {0}", originalDesktopWidth);
            }
            else
            {
                this.Site.Assert.AreEqual <uint>(originalDesktopWidth, monitor.Width, "The width of monitor MUST be {0}", originalDesktopWidth);
                this.Site.Assert.AreEqual <uint>(originalDesktopHeight, monitor.Height, "The height of monitor MUST be {0}", originalDesktopHeight);
            }
            this.Site.Assert.AreEqual <MonitorLayout_OrientationValues>(orientation, monitor.Orientation, "The Orientation of monitor MUST be {0}", orientation);

            // Clear receive buffer
            this.rdpedispAdapter.ClearReceivedList();
        }
        /// <summary>
        /// Method to create DISPLAYCONTROL_MONITOR_LAYOUT structure
        /// </summary>
        /// <param name="flags">A 32-bit unsigned integer that specifies monitor configuration flags.</param>
        /// <param name="left">A 32-bit signed integer that specifies the x-coordinate of the upper-left corner of the display monitor.</param>
        /// <param name="top">A 32-bit signed integer that specifies the y-coordinate of the upper-left corner of the display monitor.</param>
        /// <param name="width">A 32-bit unsigned integer that specifies the width of the monitor in pixels. </param>
        /// <param name="height">A 32-bit unsigned integer that specifies the height of the monitor in pixels. </param>
        /// <param name="physicalWidth">A 32-bit unsigned integer that specifies the physical width of the monitor, in millimeters (mm).</param>
        /// <param name="physicalHeight">A 32-bit unsigned integer that specifies the physical height of the monitor, in millimeters.</param>
        /// <param name="orientation">A 32-bit unsigned integer that specifies the orientation of the monitor in degrees.</param>
        /// <param name="desktopScaleFactor">A 32-bit, unsigned integer that specifies the desktop scale factor of the monitor.</param>
        /// <param name="deviceScaleFactor">A 32-bit, unsigned integer that specifies the device scale factor of the monitor. </param>
        /// <returns></returns>
        public DISPLAYCONTROL_MONITOR_LAYOUT createMonitorLayout(
            MonitorLayout_FlagValues flags,
            int left,
            int top,
            uint width,
            uint height,
            uint physicalWidth,
            uint physicalHeight,
            MonitorLayout_OrientationValues orientation,
            uint desktopScaleFactor,
            uint deviceScaleFactor)
        {
            DISPLAYCONTROL_MONITOR_LAYOUT monitorLayout = new DISPLAYCONTROL_MONITOR_LAYOUT();

            monitorLayout.Flags = flags;
            monitorLayout.Left  = left;
            monitorLayout.Top   = top;
            if (forceRestriction && width >= MinMonitorSize && width <= MaxMonitorSize && width % 2 == 0)
            {
                monitorLayout.Width = width;
            }
            else
            {
                return(null);
            }
            if (forceRestriction && height >= MinMonitorSize && height <= MaxMonitorSize)
            {
                monitorLayout.Height = height;
            }
            else
            {
                return(null);
            }
            monitorLayout.PhysicalWidth      = physicalWidth;
            monitorLayout.PhysicalHeight     = physicalHeight;
            monitorLayout.Orientation        = orientation;
            monitorLayout.DesktopScaleFactor = desktopScaleFactor;
            monitorLayout.DeviceScaleFactor  = desktopScaleFactor;
            return(monitorLayout);
        }
 /// <summary>
 /// Decode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to Decode the fields of this PDU.</param>
 /// <returns></returns>
 public bool Decode(PduMarshaler marshaler)
 {
     try
     {
         Flags              = (MonitorLayout_FlagValues)marshaler.ReadUInt32();
         Left               = marshaler.ReadInt32();
         Top                = marshaler.ReadInt32();
         Width              = marshaler.ReadUInt32();
         Height             = marshaler.ReadUInt32();
         PhysicalWidth      = marshaler.ReadUInt32();
         PhysicalHeight     = marshaler.ReadUInt32();
         Orientation        = (MonitorLayout_OrientationValues)marshaler.ReadUInt32();
         DesktopScaleFactor = marshaler.ReadUInt32();
         DeviceScaleFactor  = marshaler.ReadUInt32();
         return(true);
     }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
        /// <summary>
        /// Common test body
        /// </summary>
        private void ChangeDesktopOrientation(MonitorLayout_OrientationValues orientation, bool enhancedAdapter = false)
        {
            if (!enhancedAdapter)
            {
                int result = this.rdpedispSutControlAdapter.TriggerOrientationChangeOnClient(OrientationToDEVMODEValue(orientation));
                if (result >= 0)
                {
                    // Wait for screen orientation change
                    System.Threading.Thread.Sleep(1000);
                    result = this.rdpedispSutControlAdapter.TriggerMaximizeRDPClientWindow();
                    // Wait for maximize RDP client Window
                    System.Threading.Thread.Sleep(4000);
                }
                this.TestSite.Assert.IsTrue(result >= 0, "Test case fails due to fail operation.");
            }

            this.TestSite.Log.Add(LogEntryKind.Comment, "Expect Display Monitor Layout PDU to change orientation");
            DISPLAYCONTROL_MONITOR_LAYOUT_PDU monitorLayoutPDU = this.rdpedispAdapter.expectMonitorLayoutPDU();

            this.Site.Assert.AreEqual<uint>(40, monitorLayoutPDU.MonitorLayoutSize, "This field MUST be set to 40 bytes, the size of the DISPLAYCONTROL_MONITOR_LAYOUT structure (MS-RDPEDISP section 2.2.2.2.1).");
            this.Site.Assert.AreEqual<uint>(1, monitorLayoutPDU.NumMonitors, "Only one Monitor for this case");
            DISPLAYCONTROL_MONITOR_LAYOUT monitor = monitorLayoutPDU.Monitors[0];
            this.Site.Assert.AreEqual<MonitorLayout_FlagValues>(MonitorLayout_FlagValues.DISPLAYCONTROL_MONITOR_PRIMARY, monitor.Flags, "Client should set this monitor to primary monitor");
            this.Site.Assert.AreEqual<int>(0, monitor.Left, "The left point of the only one monitor should be 0");
            this.Site.Assert.AreEqual<int>(0, monitor.Top, "The Top point of the only one monitor should be 0");
            if (orientation == MonitorLayout_OrientationValues.ORIENTATION_PORTRAIT || orientation == MonitorLayout_OrientationValues.ORIENTATION_PORTRAIT_FLIPPED)
            {
                this.Site.Assert.AreEqual<uint>(originalDesktopHeight, monitor.Width, "The width of monitor MUST be {0}", originalDesktopHeight);
                this.Site.Assert.AreEqual<uint>(originalDesktopWidth, monitor.Height, "The height of monitor MUST be {0}", originalDesktopWidth);
            }
            else
            {
                this.Site.Assert.AreEqual<uint>(originalDesktopWidth, monitor.Width, "The width of monitor MUST be {0}", originalDesktopWidth);
                this.Site.Assert.AreEqual<uint>(originalDesktopHeight, monitor.Height, "The height of monitor MUST be {0}", originalDesktopHeight);
            }
            this.Site.Assert.AreEqual<MonitorLayout_OrientationValues>(orientation, monitor.Orientation, "The Orientation of monitor MUST be {0}", orientation);

            // Clear receive buffer
            this.rdpedispAdapter.ClearReceivedList();
        }
 /// <summary>
 /// Covert MonitorLayout_OrientationValues to DEVMODE orientation value
 /// </summary>
 /// <param name="orientation">MonitorLayout_OrientationValues orientation</param>
 /// <returns></returns>
 private int OrientationToDEVMODEValue(MonitorLayout_OrientationValues orientation)
 {
     switch (orientation)
     {
         case MonitorLayout_OrientationValues.ORIENTATION_LANDSCAPE:
             return 0;
         case MonitorLayout_OrientationValues.ORIENTATION_PORTRAIT:
             return 1;
         case MonitorLayout_OrientationValues.ORIENTATION_LANDSCAPE_FLIPPED:
             return 2;
         case MonitorLayout_OrientationValues.ORIENTATION_PORTRAIT_FLIPPED:
             return 3;
         default:
             return 0;
     }
 }
 /// <summary>
 /// Decode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to Decode the fields of this PDU.</param>
 /// <returns></returns>
 public bool Decode(PduMarshaler marshaler)
 {
     try
     {
         Flags = (MonitorLayout_FlagValues)marshaler.ReadUInt32();
         Left = marshaler.ReadInt32();
         Top = marshaler.ReadInt32();
         Width = marshaler.ReadUInt32();
         Height = marshaler.ReadUInt32();
         PhysicalWidth = marshaler.ReadUInt32();
         PhysicalHeight = marshaler.ReadUInt32();
         Orientation = (MonitorLayout_OrientationValues)marshaler.ReadUInt32();
         DesktopScaleFactor = marshaler.ReadUInt32();
         DeviceScaleFactor = marshaler.ReadUInt32();
         return true;
     }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }