Author: snjeza
Date: 2012-01-13 11:07:19 -0500 (Fri, 13 Jan 2012)
New Revision: 37832
Modified:
trunk/central/tests/org.jboss.tools.central.test/src/org/jboss/tools/central/test/CentralTest.java
Log:
JBIDE-10366 Add tests for JBoss Central
Modified:
trunk/central/tests/org.jboss.tools.central.test/src/org/jboss/tools/central/test/CentralTest.java
===================================================================
---
trunk/central/tests/org.jboss.tools.central.test/src/org/jboss/tools/central/test/CentralTest.java 2012-01-13
16:04:51 UTC (rev 37831)
+++
trunk/central/tests/org.jboss.tools.central.test/src/org/jboss/tools/central/test/CentralTest.java 2012-01-13
16:07:19 UTC (rev 37832)
@@ -21,9 +21,11 @@
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.WorkbenchWindow;
import org.jboss.tools.central.JBossCentralActivator;
import org.jboss.tools.central.ShowJBossCentral;
import org.jboss.tools.central.editors.JBossCentralEditor;
@@ -46,17 +48,19 @@
public class CentralTest {
private static JBossCentralEditor editor;
+ private static final String ORG_ECLIPSE_UI_INTERNAL_INTROVIEW =
"org.eclipse.ui.internal.introview";
+
@BeforeClass
public static void init() throws Exception {
- Display.getDefault().syncExec(new Runnable() {
-
- @Override
- public void run() {
- editor = JBossCentralActivator.getJBossCentralEditor();
- }
- });
-
+ final WorkbenchWindow window = (WorkbenchWindow) PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow();
+ final IWorkbenchPage page = window.getActivePage();
+ IViewPart welcomeView = page.findView(ORG_ECLIPSE_UI_INTERNAL_INTROVIEW);
+ if (welcomeView != null) {
+ page.hideView(welcomeView);
+ }
+ editor = JBossCentralActivator.getJBossCentralEditor();
}
@AfterClass
@@ -66,70 +70,89 @@
@Test
public void testEditorOpen() throws Exception {
- assertTrue("The JBoss Central editor isn't open",editor != null);
+ assertTrue("The JBoss Central editor isn't open", editor != null);
}
-
+
@Test
public void testTutorials() throws Exception {
- Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY, new
NullProgressMonitor());
- Map<String, TutorialCategory> categories =
RefreshTutorialsJob.INSTANCE.getTutorialCategories();
+ Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY,
+ new NullProgressMonitor());
+ Map<String, TutorialCategory> categories = RefreshTutorialsJob.INSTANCE
+ .getTutorialCategories();
assertTrue("No one tutorial is found", categories.size() > 0);
}
-
+
@Test
public void testNews() throws Exception {
- Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY, new
NullProgressMonitor());
+ Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY,
+ new NullProgressMonitor());
List<FeedsEntry> news = RefreshNewsJob.INSTANCE.getEntries();
assertTrue("No one news is found", news.size() > 0);
}
-
+
@Test
public void testBlogs() throws Exception {
- Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY, new
NullProgressMonitor());
+ Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY,
+ new NullProgressMonitor());
List<FeedsEntry> blogs = RefreshBlogsJob.INSTANCE.getEntries();
assertTrue("No one blog is found", blogs.size() > 0);
}
-
+
@Test
public void testCachingBlogs() throws Exception {
- Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY, new
NullProgressMonitor());
- assertTrue("Blog entries aren't cached",
RefreshBlogsJob.INSTANCE.getCacheFile().exists());
+ Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY,
+ new NullProgressMonitor());
+ assertTrue("Blog entries aren't cached", RefreshBlogsJob.INSTANCE
+ .getCacheFile().exists());
}
-
+
@Test
public void testCachingNews() throws Exception {
- Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY, new
NullProgressMonitor());
- assertTrue("News entries aren't cached",
RefreshNewsJob.INSTANCE.getCacheFile().exists());
+ Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY,
+ new NullProgressMonitor());
+ assertTrue("News entries aren't cached", RefreshNewsJob.INSTANCE
+ .getCacheFile().exists());
}
+
@Test
public void testShowOnStartup() throws Exception {
EditorTestHelper.closeAllEditors();
- assertTrue("The Show On Startup property isn't set by default",
JBossCentralActivator.getDefault().showJBossCentralOnStartup());
+ assertTrue("The Show On Startup property isn't set by default",
+ JBossCentralActivator.getDefault().showJBossCentralOnStartup());
new ShowJBossCentral().earlyStartup();
JobUtils.delay(1000);
- Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY, new
NullProgressMonitor());
-
- assertTrue("The JBoss Central editor isn't open by default",
hasOpenEditor());
+ Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY,
+ new NullProgressMonitor());
+
+ assertTrue("The JBoss Central editor isn't open by default",
+ hasOpenEditor());
IEclipsePreferences prefs = JBossCentralActivator.getDefault()
.getPreferences();
prefs.putBoolean(JBossCentralActivator.SHOW_JBOSS_CENTRAL_ON_STARTUP,
false);
- assertFalse("The Show On Startup property isn't changed",
JBossCentralActivator.getDefault().showJBossCentralOnStartup());
+ assertFalse("The Show On Startup property isn't changed",
+ JBossCentralActivator.getDefault().showJBossCentralOnStartup());
EditorTestHelper.closeAllEditors();
new ShowJBossCentral().earlyStartup();
- Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY, new
NullProgressMonitor());
+ Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY,
+ new NullProgressMonitor());
JobUtils.delay(1000);
- assertFalse("The JBoss Central editor is open when the Show On Startup property is
unchecked", hasOpenEditor());
- prefs.putBoolean(JBossCentralActivator.SHOW_JBOSS_CENTRAL_ON_STARTUP,
+ assertFalse(
+ "The JBoss Central editor is open when the Show On Startup property is
unchecked",
+ hasOpenEditor());
+ prefs.putBoolean(
+ JBossCentralActivator.SHOW_JBOSS_CENTRAL_ON_STARTUP,
JBossCentralActivator.SHOW_JBOSS_CENTRAL_ON_STARTUP_DEFAULT_VALUE);
}
private boolean hasOpenEditor() {
- IWorkbenchWindow[] windows= PlatformUI.getWorkbench().getWorkbenchWindows();
- for (int i= 0; i < windows.length; i++) {
- IWorkbenchPage[] pages= windows[i].getPages();
- for (int j= 0; j < pages.length; j++) {
- IEditorReference[] editorReferences= pages[j].getEditorReferences();
+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench()
+ .getWorkbenchWindows();
+ for (int i = 0; i < windows.length; i++) {
+ IWorkbenchPage[] pages = windows[i].getPages();
+ for (int j = 0; j < pages.length; j++) {
+ IEditorReference[] editorReferences = pages[j]
+ .getEditorReferences();
if (editorReferences.length > 0) {
return true;
}
Show replies by date