示例#1
0
        public void WebBrowserBase_DrawToBitmap_InvokeWithHandle_Success(Rectangle rectangle)
        {
            using var control = new SubWebBrowserBase("8856f961-340a-11d0-a96b-00c04fd705a2")
                  {
                      Width  = 20,
                      Height = 20,
                  };
            Assert.NotEqual(IntPtr.Zero, control.Handle);
            int invalidatedCallCount = 0;

            control.Invalidated += (sender, e) => invalidatedCallCount++;
            int styleChangedCallCount = 0;

            ((Control)control).StyleChanged += (sender, e) => styleChangedCallCount++;
            int createdCallCount = 0;

            control.HandleCreated += (sender, e) => createdCallCount++;

            using var bitmap = new Bitmap(20, 20);
            control.DrawToBitmap(bitmap, rectangle);
            Assert.True(control.IsHandleCreated);
            Assert.Equal(0, invalidatedCallCount);
            Assert.Equal(0, styleChangedCallCount);
            Assert.Equal(0, createdCallCount);
        }
示例#2
0
 public void WebBrowserBase_DrawToBitmap_InvokeZeroHeight_ThrowsArgumentException(int height)
 {
     using var control = new SubWebBrowserBase("8856f961-340a-11d0-a96b-00c04fd705a2")
           {
               Width  = 20,
               Height = height
           };
     using var bitmap = new Bitmap(10, 10);
     Assert.Throws <ArgumentException>(null, () => control.DrawToBitmap(bitmap, new Rectangle(1, 2, 3, 4)));
 }
示例#3
0
 public void WebBrowserBase_DrawToBitmap_InvalidTargetBounds_ThrowsArgumentException(int x, int y, int width, int height)
 {
     using var control = new SubWebBrowserBase("8856f961-340a-11d0-a96b-00c04fd705a2")
           {
               Width  = 20,
               Height = 20
           };
     using var bitmap = new Bitmap(10, 10);
     Assert.Throws <ArgumentException>(null, () => control.DrawToBitmap(bitmap, new Rectangle(x, y, width, height)));
 }
示例#4
0
 public void WebBrowserBase_DrawToBitmap_Invoke_Success(Rectangle targetBounds)
 {
     using var control = new SubWebBrowserBase("8856f961-340a-11d0-a96b-00c04fd705a2")
           {
               Width  = 20,
               Height = 20,
           };
     using var bitmap = new Bitmap(20, 20);
     control.DrawToBitmap(bitmap, targetBounds);
     Assert.True(control.IsHandleCreated);
 }
示例#5
0
 public void WebBrowserBase_DrawToBitmap_NullBitmap_ThrowsArgumentNullException()
 {
     using var control = new SubWebBrowserBase("8856f961-340a-11d0-a96b-00c04fd705a2");
     Assert.Throws <ArgumentNullException>("bitmap", () => control.DrawToBitmap(null, new Rectangle(1, 2, 3, 4)));
 }