in src/main/java/com/atlassian/uwc/converters/sharepoint/ColorConverterTest.java [24:127]
public void testConvertColor() {
String input, expected, actual;
//color in span
input = "<html><span color=\"#ffff00\">Testing</span></html>";
expected = "<html>{color:#ffff00}Testing{color}</html>";
actual = tester.convertColor(input);
assertNotNull(actual);
assertEquals(expected, actual);
//simple color in font
input = "<font size=\"5\" color=\"#ffff00\">Testing</font>";
expected = "<font size=\"5\">" +
"{color:#ffff00}Testing{color}" +
"</font>";
actual = tester.convertColor(input);
assertNotNull(actual);
assertEquals(expected, actual);
//bgcolor in div
input = "<html><div align=\"left\" dir=\"ltr\" style=\"background-color:rgb(255, 192, 203)\">\n" +
"Testing</div></html>";
expected = "<html>{panel:bgColor=#ffc0cb}\n" +
"Testing{panel}</html>";
actual = tester.convertColor(input);
assertNotNull(actual);
assertEquals(expected, actual);
//bgcolor in span
input = "<html><span style=\"background-color:rgb(255, 240, 200)\">\n" +
"Testing span</span>\n</html>";
expected = "<html>{panel:bgColor=#fff0c8}\n" +
"Testing span{panel}\n</html>";
actual = tester.convertColor(input);
assertNotNull(actual);
assertEquals(expected, actual);
//color and background at same time
input = "<html>" +
"<font size=\"7\" color=\"#8b0000\">" +
"\n" +
"<span style=\"background-color:rgb(50, 0, 255)\">" +
"\n" +
"Testing both</span>" +
"\n" +
"</font>" +
"</html>";
expected = "<html>" +
"<font size=\"7\">" +
"{panel:bgColor=#3200ff}" +
"{color:#8b0000}" +
"\n" +
"\n" +
"Testing both" +
"{color}" +
"{panel}\n" +
"</font></html>";
actual = tester.convertColor(input);
assertNotNull(actual);
assertEquals(expected, actual);
//same ones back to back
input = "<html><span style=\"background-color:rgb(255, 192, 203)\">" +
"It\'s my " +
"</span>" +
"<span style=\"background-color:rgb(255, 192, 203)\">" +
"*party *" +
"</span>" +
"<span style=\"background-color:rgb(255, 192, 203)\">" +
"and I\'ll </span>" +
"<span style=\"background-color:rgb(255, 192, 203)\">" +
"_cry _" +
"</span>" +
"<span style=\"background-color:rgb(255, 192, 203)\">" +
"if I want to.\n" +
"</span></html>";
expected = "<html>{panel:bgColor=#ffc0cb}" +
"It\'s my *party *and I\'ll _cry _if I want to.\n" +
"{panel}</html>";
actual = tester.convertColor(input);
assertNotNull(actual);
assertEquals(expected, actual);
//nesting
input = "<html><span style=\"background-color:rgb(255, 192, 203)\">" +
"Before " +
"<span style=\"background-color:rgb(0, 0, 255)\">" +
" middle " +
"</span>" +
"after.\n" +
"</span>" +
"</html>";
expected = "<html>{panel:bgColor=#ffc0cb}" +
"Before {panel}" +
"{panel:bgColor=#0000ff}" +
" middle " +
"{panel}" +
"{panel:bgColor=#ffc0cb}" +
"after.\n" +
"{panel}</html>";
actual = tester.convertColor(input);
assertNotNull(actual);
assertEquals(expected, actual);
}