@Test public void testAddCssUrl() { WApplication application = new WApplication(); WApplication.ApplicationResource res = application.addCssUrl("URL"); Assert.assertEquals("CSS URL should be on the resource detail", "URL", res.getUrl()); Assert.assertEquals("CSS URL resource should have been added", 1, application.getCssResources().size()); Assert.assertTrue("CSS URL resource should be in set", application.getCssResources().contains(res)); // Add Same URL should not add an extra resource application.addCssUrl("URL"); Assert.assertEquals("A CSS URL that is already added should not be added", 1, application.getCssResources().size()); // Add Different URL application.addCssUrl("URL2"); Assert.assertEquals("A different CSS URL should be added", 2, application.getCssResources().size()); }
@Test(expected = IllegalArgumentException.class) public void testAddCssUrlException() { new WApplication().addCssUrl(null); }
/** * Configure an application to use wc library. * * @param app the application to configure */ public static void configApplication(final WApplication app) { // CSS String url = EnvironmentHelper.prefixBaseUrl("wclib/css/lib/cssgrid@0.0.4.css"); app.addCssUrl(url); // Javascript - Allow requireJS to load wclib js libraries TemplateWContent registerWclib = new TemplateWContent(new TemplateRegisterWclibJsResource(), "reg"); app.add(registerWclib); app.addJsResource(new ApplicationResourceWContent(registerWclib, "regkey")); }
@Test public void testCssResources() throws IOException, SAXException, XpathException { // No resource WApplication application = new WApplication(); assertSchemaMatch(application); assertXpathNotExists("//ui:application/ui:css", application); // Add URL resource application.addCssUrl("URL"); assertSchemaMatch(application); assertXpathEvaluatesTo("URL", "//ui:application/ui:css/@url", application); }