public void testNoDefaultLocaleForChangeAndRefresh() throws Throwable { VpeController controller = openInVpe(JsfAllTests.IMPORT_JSF_LOCALES_PROJECT_NAME, NO_DEFLOC_CHANGE_REFRESH_PAGE); nsIDOMDocument doc = controller.getXulRunnerEditor().getDOMDocument(); nsIDOMElement localeText = doc.getElementById(LOCALE_TEXT_ID); String localizedText = getLocalizedText(localeText); assertTrue( "Text is '" + localizedText + "', but should be in 'de' locale", HELLO2_DE.equalsIgnoreCase(localizedText)); // $NON-NLS-1$ //$NON-NLS-2$ /* * Change the locale */ Element fViewElement = controller.getSourceBuilder().getSourceDocument().getElementById(FVIEW_ID); int offset = controller.getSourceBuilder().getPosition(fViewElement, 0, false); assertTrue( "Previous locale should be 'de'", "de" .equalsIgnoreCase( fViewElement.getAttribute("locale"))); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ IRegion reg = new FindReplaceDocumentAdapter( controller.getSourceBuilder().getStructuredTextViewer().getDocument()) .find(offset, "de", true, true, false, false); controller .getSourceBuilder() .getStructuredTextViewer() .getDocument() .replace(reg.getOffset(), reg.getLength(), "en_GB"); /* * Wait until new value is applied and children are refreshed. * Wait while all deferred events are processed */ while (Display.getCurrent().readAndDispatch()) ; /* * Wait while all jobs including started through deferred events are ended */ JobUtils.delay(VpeController.DEFAULT_UPDATE_DELAY_TIME * 4); TestUtil.waitForIdle(); fViewElement = controller.getSourceBuilder().getSourceDocument().getElementById(FVIEW_ID); assertTrue( "Current locale should be 'en_GB'", "en_GB" .equalsIgnoreCase( fViewElement.getAttribute("locale"))); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ doc = controller.getXulRunnerEditor().getDOMDocument(); localeText = doc.getElementById(LOCALE_TEXT_ID); localizedText = getLocalizedText(localeText); /* * Check the new localized message. */ assertTrue( "Text is '" + localizedText + "', but should be in 'en_GB' locale", HELLO_EN_GB.equalsIgnoreCase(localizedText)); // $NON-NLS-1$ //$NON-NLS-2$ closeEditors(); }
@Before public void setUp() throws Exception { TestProjectProvider provider = new TestProjectProvider(BUNDLE, "/projects/" + "WebTest", "WebTest", true); prj = provider.getProject(); JobUtils.delay(3000); }
@After public void tearDown() throws Exception { boolean oldAutoBuilding = ResourcesUtils.setBuildAutomatically(false); Exception last = null; try { JobUtils.delay(500); try { prj.delete(true, null); JobUtils.delay(500); } catch (Exception e) { e.printStackTrace(); last = e; } } finally { ResourcesUtils.setBuildAutomatically(oldAutoBuilding); } if (last != null) throw last; }