I have some simple GWT client code that I would like to test using GWTTestCase
and GWTTestSuite.
However, those tests require the use of some CSS stylesheet
(only needed for the tests).
My first attempt was :
- Define a
ClientBundle
that provide the CSS file used for tests. - in my
gwtSetUp()
, call the `ensureInjected() method to add the CSS file before my tests get called - Test if the CSS style was applied to a particular element in the DOM, for example
code:
assertEquals("blue", element.getStyle().getBorderColor());
I got no errors, but this not seems to work.
Looking throught the logs of the Console (during the Junit test) I found this :
Initializing ResourceGenerator
Finding operable CssResource subtypes
Computing CSS class replacements
Preparing method css
Finding resources
Parsing CSS stylesheet file:/D:/Workspace/libraries/gwt-text/gwt-text/src/test/java/com/t/i/client/CSSDecorationTest.css
Scanning CSS for requirements
Creating fields
Creating assignment for css()
Creating image sprite classes
Replacing property-based @if blocks
Replacing CSS class names
Performing substitution in node border-color : ..... ;
My css file simple contains :
.d {
border-color: blue;
}
EDIT
Please see this link : https://stackoverflow.com/a/10575244/921244
This was the wrong approach as getStyle do not provide the CSS computed style. Too bad.