Two new classes to help writing ui tests

I just landed the second part of two chunks that make it easier to
write and maintain tests that excercise the UI. If you don't write or
maintain such tests, you can stop reading now.

The first test class is BrowserWithTestWindowTest. This test class
creates a Browser with a TestingProfile and TestBrowserWindow. Use
this as a base test class for writing tests that exercise Browser but
that don't need any sort of UI. For example, many of the commands
don't need a ui to be tested. See browser_commands_unittest for an
example of BrowserWithTestWindowTest in action.

BrowserWithTestWindowTest currently works with TestTabContentsFactory
(a factory that creates a mocked out version of TabContents), which
does not create HWNDs. I will expand these tests to create a real
HWND, which will allow for a bit more testing than is currently
possible.

The second test class is InProcessBrowserTest. This test class invokes
BrowserMain (but not BrowserInit) to startup Chrome, then runs your
test method. Your test method is then running as if you were inside
Chrome. You can create and destroy Browsers, navigate to pages;
whatever. InProcessBrowserTest can be used as a replacement for
existing UI tests. See InProcessBrowserTest documentation for details
as well as find_bar_win_unittest for an example.

Both of these classes work inside the unit_tests project.

This begs the question, do I need to rewrite all my ui tests now? No.
There is still a need for the automation infrastructure the ui tests
use (Selenium uses it for one) and as such it won't be going away.
That said, InProcessBrowserTest is a easier to use than the UI tests
(you don't need to write IPC messages), should be faster, and is
easier to debug. For new tests, I strongly encourage you to write them
using InProcessBrowserTest. Additionally if you find yourself having
to substantially change around an existing UI test, consider
converting it over.

  -Scott

--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: [email protected] 
View archives, change email options, or unsubscribe: 
    http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to