@Test public void testAddCssFileName() { WApplication application = new WApplication(); WApplication.ApplicationResource res = application.addCssFile("FILE"); Assert.assertEquals("CSS FILE should be on the resource detail", "FILE", res.getResource().getResourceName()); Assert.assertEquals("CSS FILE resource should have been added", 1, application.getCssResources().size()); Assert.assertTrue("CSS FILE resource should be in set", application.getCssResources().contains(res)); // Add Same FILE should not add an extra resource application.addCssFile("FILE"); Assert.assertEquals("A CSS FILE that is already added should not be added", 1, application.getCssResources().size()); // Add Diffenrt FILE application.addCssFile("FILE2"); Assert.assertEquals("A different CSS FILE should be added", 2, application.getCssResources().size()); }
@Test(expected = IllegalArgumentException.class) public void testAddCssFileException() { new WApplication().addCssFile(null); }
application.addCssFile("FileName1a"); application.addCssFile("FileName1b"); Assert.assertEquals("CSS resources should have been added", 2, application.getCssResources().size()); application.addCssFile("FileName2a"); application.addCssFile("FileName2b"); Assert.assertEquals("CSS resources should have been added on second context", 2, application.getCssResources().size());
@Test public void testRemoveCssResource() { WApplication application = new WApplication(); application.setLocked(true); UIContext uic1 = createUIContext(); setActiveContext(uic1); // Add resources application.addCssFile("FileName1a"); application.addCssFile("FileName1b"); Assert.assertEquals("CSS resources should have been added", 2, application.getCssResources().size()); // Second context UIContext uic2 = createUIContext(); setActiveContext(uic2); // Add resources WApplication.ApplicationResource res2a = application.addCssFile("FileName2a"); application.addCssFile("FileName2b"); Assert.assertEquals("CSS resources should have been added on second context", 2, application.getCssResources().size()); // Remove resource application.removeCssResource(res2a); Assert.assertEquals("Should only have one css resource on second context", 1, application.getCssResources().size()); Assert.assertFalse("CSS resource should have been removed on second conext", application.getCssResources().contains(res2a)); // Check first context not changed setActiveContext(uic1); Assert.assertEquals("CSS resource should not have changed on first context", 2, application.getCssResources().size()); }