Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move some utility methods around to provide a cleaner separation of t…

…he base SWT tests.
  • Loading branch information...
commit 3676ac81f5533abd0761e5a5b4c40ef7487fcf17 1 parent 258a521
@ketan authored committed
View
2  ...tbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/keyboard/AbstractKeyboardTest.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.swtbot.swt.finder.keyboard;
+import static org.eclipse.swtbot.swt.finder.utils.SWTUtils.isMac;
+
import org.eclipse.swt.SWT;
import org.eclipse.swtbot.swt.finder.test.AbstractCustomControlExampleTest;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText;
View
7 ...e.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/test/AbstractSWTShellTest.java
@@ -70,9 +70,6 @@ public String getFailureMessage() {
}
});
}
-
- protected boolean isCocoa() {
- return SWT.getPlatform().equals("cocoa");
- }
-
+
+
}
View
43 ...clipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/test/AbstractSWTTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Ketan Padegaonkar and others.
+ * Copyright (c) 2010,2011 Ketan Padegaonkar and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,20 +11,12 @@
package org.eclipse.swtbot.swt.finder.test;
import org.apache.log4j.Logger;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
import org.eclipse.swtbot.swt.finder.RunUIThreadRule;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.finders.ControlFinder;
import org.eclipse.swtbot.swt.finder.finders.Finder;
import org.eclipse.swtbot.swt.finder.finders.MenuFinder;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.results.WidgetResult;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.MethodRule;
@@ -33,6 +25,7 @@
import org.junit.runners.model.Statement;
/**
+ *
* @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
* @version $Id$
*/
@@ -55,7 +48,7 @@ public Statement apply(Statement base, FrameworkMethod method, Object target) {
return new RunUIThreadRule(target).apply(base, method, target);
}
};
-
+
@Before
public final void setupSWTBot() {
bot = new SWTBot();
@@ -63,34 +56,4 @@ public final void setupSWTBot() {
menuFinder = new MenuFinder();
finder = new Finder(controlFinder, menuFinder);
}
-
- protected static boolean isMac() {
- String swtPlatform = SWT.getPlatform();
- return ("carbon".equals(swtPlatform) || "cocoa".equals(swtPlatform));
- }
-
- protected Shell createShell(final String text) {
- return UIThreadRunnable.syncExec(new WidgetResult<Shell>() {
- public Shell run() {
- Shell shell = new Shell(Display.getCurrent());
- shell.setText(text);
- shell.setLayout(new GridLayout(1, false));
- shell.open();
- return shell;
- }
- });
- }
- protected Tree createTree(final Shell shell) {
- return UIThreadRunnable.syncExec(new WidgetResult<Tree>() {
- public Tree run() {
- Tree tree = new Tree(shell, SWT.SINGLE);
- tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- tree.setLinesVisible(true);
- tree.setHeaderVisible(true);
-
- shell.layout(true);
- return tree;
- }
- });
- }
}
View
44 ...lipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/waits/TreeHasRowsTest.java
@@ -14,11 +14,16 @@
import static org.junit.Assert.assertTrue;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.results.WidgetResult;
import org.eclipse.swtbot.swt.finder.test.AbstractSWTShellTest;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.junit.Test;
@@ -54,4 +59,43 @@ protected void createUI(Composite parent) {
tree = createTree(createShell(TEXT));
}
+ protected static boolean isMac() {
+ return (isCarbon() || isCocoa());
+ }
+
+ private static boolean isCarbon() {
+ return "carbon".equals(SWT.getPlatform());
+ }
+
+ protected static boolean isCocoa() {
+ return SWT.getPlatform().equals("cocoa");
+ }
+
+ private Shell createShell(final String text) {
+ return UIThreadRunnable.syncExec(new WidgetResult<Shell>() {
+ public Shell run() {
+ Shell shell = new Shell(Display.getCurrent());
+ shell.setText(text);
+ shell.setLayout(new GridLayout(1, false));
+ shell.open();
+ return shell;
+ }
+ });
+ }
+
+ private Tree createTree(final Shell shell) {
+ return UIThreadRunnable.syncExec(new WidgetResult<Tree>() {
+ public Tree run() {
+ Tree tree = new Tree(shell, SWT.SINGLE);
+ tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ tree.setLinesVisible(true);
+ tree.setHeaderVisible(true);
+
+ shell.layout(true);
+ return tree;
+ }
+ });
+ }
+
+
}
View
3  ...pse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotComboTest.java
@@ -4,13 +4,14 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Ketan Padegaonkar - initial API and implementation
* Cédric Chabanois - http://swtbot.org/bugzilla/show_bug.cgi?id=17
*******************************************************************************/
package org.eclipse.swtbot.swt.finder.widgets;
+import static org.eclipse.swtbot.swt.finder.utils.SWTUtils.isCocoa;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
View
23 org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/utils/SWTUtils.java
@@ -495,4 +495,27 @@ public static boolean isUIThread(Display display) {
public static boolean isUIThread() {
return isUIThread(display);
}
+
+
+ /**
+ * @return <code>true</code> if the current OS is macosx.
+ */
+ public static boolean isMac(){
+ return isCocoa() || isCarbon();
+ }
+
+ /**
+ * @return <code>true</code> if the current platform is {@code cocoa}
+ */
+ public static boolean isCocoa(){
+ return SWT.getPlatform().equals("cocoa");
+ }
+
+ /**
+ * @return <code>true</code> if the current platform is {@code carbon}
+ */
+ public static boolean isCarbon(){
+ return SWT.getPlatform().equals("carbon");
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.