1
Vote

transformations do not work

description

When I run MS silverlight unit tests with agunit for 6.1 resharper all tests where I check elements positions with element.TransformToVisual(other) and similar functions fail with "The value does not fall within the expected range". In the same time those tests pass when running tests normally by running tests project in the browser).
I've enclosed a file with a test that passes in default silverlight 4 testing enviroment but fails in agunit.

file attachments

comments

SDeKock wrote Feb 23, 2012 at 3:49 PM

Hi,

Do you have an example test case we can use to verify this ?
Please attach it to this issue. I will include it in the DummyTests project I use to test AgUnit with.

Steven

antonkulaga wrote Mar 3, 2012 at 9:29 PM

Sorry for the delay in answer, Here I enclose the test wich passes in default silverlight testing enviroment but fails in AgUnit

antonkulaga wrote Mar 3, 2012 at 9:30 PM

[TestClass]
public class AgunitCrashTest:SilverlightTest
{
    public Canvas MyCanvas;
    public Button MyButton;

    [TestInitialize]
    public void SetUp()
    {
        this.MyCanvas = new Canvas() {Width = 1000, Height = 1000};
        this.TestPanel.Children.Add(this.MyCanvas);
        this.MyButton = new Button(){Content = "SomeContent",Width = 200,Height = 200};
        Canvas.SetLeft(MyButton,200);
        Canvas.SetTop(MyButton,200);
        this.MyCanvas.Children.Add(MyButton);
        TestPanel.UpdateLayout();
    }

    [TestCleanup]
    public void CleanUp()
    {
        this.TestPanel.Children.Remove(MyCanvas);
        this.MyCanvas.Children.Remove(MyButton);
        this.MyCanvas = null;
        this.MyButton = null;
    }

    /// <summary>
    /// This test passes in default silverlight testing enviroment but fails in AgUnit for Resharper 6.1 enviroment
    /// </summary>
    [TestMethod]
    public void AgUnitFailureTest()
    {
        TestPanel.UpdateLayout();
        this.MyButton.GetBounds();
        var t = this.MyButton.TransformToVisual(this.MyCanvas);
        // This test passes in default silverlight testing enviroment but fails in AgUnit for Resharper 6.1 enviroment        
        var bounds = new Rect(t.Transform(new Point(0, 0)), this.MyButton.RenderSize); //place of the crash
        Assert.AreEqual(200,bounds.X);
        Assert.AreEqual(200,bounds.Y);
        Assert.AreEqual(bounds.Width,MyButton.ActualWidth);
        Assert.AreEqual(bounds.Height,MyButton.ActualHeight);

    }
}

SDeKock wrote Mar 3, 2012 at 10:00 PM

I'll investigate this, Thank you.

staxmanade wrote Mar 4, 2012 at 5:18 AM

This is most likely because AgUnit doesn't run StatLight with the U.I. mode.

SDeKock: This could possibly be fixed by allowing the U.I. to show up. You can specify this in statlight by passing WindowGeometry object witht eh BrowserWindowState = BrowserWindowState.Normal.

Not sure this should become a hard-coded solution in AgUnit. Possibly look to make this a configuration option?

antonkulaga wrote Mar 16, 2012 at 1:22 PM

SDeKock: This could possibly be fixed by allowing the U.I. to show up. You can specify this in statlight by passing WindowGeometry object witht eh BrowserWindowState = BrowserWindowState.Normal.
I am not experienced with statlight. What should I do (what and where to write) to make agunit work properly wi UI?
Not sure this should become a hard-coded solution in AgUnit. Possibly look to make this a configuration option?
I do a lot of controls unittesting so I definately need it to be on.

antonkulaga wrote Sep 1, 2012 at 3:25 PM

Hi, SDeKock

The bug is very unpleasant, are you going to fix it?
I tried to fix it myself by recompiling AgUnit with BrowserWindowState = BrowserWindowState.Normal but It did not work :-(

SDeKock wrote Sep 1, 2012 at 4:54 PM

I'll see what I can do to get full UI rendering ...

Keep in mind you can also see this behavior during normal runtime.

If the user has has browser window minimized, is looking at another tab (any reason your control has not passed a render cycle), you can get this exception.

In the Silverlight Toolkit for example they use an extension method SafeTransformToVisual to avoid this problem.