Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1500
Check if the grid has completely initialized itself
posted

Hello,

I have somewhat a tricky question and would love to hear your thoughts on it. But at first some background of what we do.

We are doing acceptance testing. From each test we:

  1. run the application
  2. simulate the user interacting with the application executing a simple use case
  3. check the application got into the expected state. If yes the test passes, if not - fails.
  4. close the app.

We do our testing from C# completely. The tests are implemented with MsTest.

In order to simulate the user interacting with the application we need to know where exactly on the screen UI components are placed. After we know where they are we can click them to activate, enter in text, etc. For example, we have to dynamically determine where the "Create Order" button is placed and then click on the determined coordinates which will simulate the user clicking the button. In order to determine coordinates of ui controls when we run the application from the tests we run it within a different process which also hosts a WCF service wich exposes the operations that provide the UI information (coordinates in general case) of the control we're interested in. For example,

GridCellCoordinates GetInputGridCorrdinates(string uniqueCellIdentifier);

The service then navigates the UIElements of the application and finds the UIElement of the cell identified by 'uniqueCellIndentifier'. After that it initializes GridCellCoordinates with the Rect of UiElement of the cell and returns to the test. The test then simulates mouse and keyboards actions on the given coordinates.

That was the background. This approach works quite well but one thing. It looks like it takes the grid some time to fully initialize and paint after its DataSource is set and it returned control to the caller. It leads to situations when the cell is found, the UiElement.Rect of it is determined and after the coordinates are sent to a test, but before the tests use them, the grid paints additional column headers. Which of course means that the cell's position changes and the test doesn't have a relevant coordinates anymore. That doesn't happen too often, but some tests fail intermittently because of that.

So my question is: is there a way to determine if the UltraGrid has already finished all its initalization and painting and whatever else it has been doing?

Also I think this may apply not only to grid, but other controls, so please feel free to express any of your thoughts on the topic.

Thanks,
Vitaly 

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi Vitaly,

    VisitorS said:
    It leads to situations when the cell is found, the UiElement.Rect of it is determined and after the coordinates are sent to a test, but before the tests use them, the grid paints additional column headers. Which of course means that the cell's position changes and the test doesn't have a relevant coordinates anymore.

    I think you might be making a bad assumption here.

    Why would the painting of other cells affect the position of a cell that was already painted?

    The only reason I can think of why a UIElement would move is if your code is making a change to the grid. For example, if the form has not finished initializing and the grid is docked or anchored, the grid's size or position might be changed by the form or it's container.

    Or if your code is adding column or loading a layout into the grid things might change.

    But I can't see why painting anything would change the position of an element.

    Obviously, in any of the cases I listed here, the grid cannot possibly know that these things are going to happen to it in the future.

    Regarding your question about detecting if the grid has completely initialized, it's impossible to say whether there is any way to tell without knowing exactly what kind of initialization you are referring to.

    There's no way to tell when the grid is "finished" databinding, because data binding is an ongoing process and is never finished.

    It might be possible for you to tell if any of the grid's UIElements have been dirtied, but this would be horribly inefficient and requires you to recursively loop through all of the UIElements, and I doubt this would help, anyway, since any subsequent change in the grid will dirty more elements that you had already checked.

    You could trap for the grid's Paint event and set a flag the first time it paints. But again, anything that changes after that could still trip you up, I think.

Children
No Data