This repository has been archived by the owner on Dec 11, 2022. It is now read-only.
forked from eclipse-archived/dartboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preference control misbehaves eclipse-archived#164 & Moving forward o…
…n portability eclipse-archived#169 Signed-off-by: Andrew Bowley <[email protected]> * Two new OS-specific packages org.eclipse.dartboard.os.linux/windows * New PlatformUtil class hides portability solution * New DartSdkChecker and SdkLocator classes support preferences access to SDK installations * SDKLocator (note different to SdkLocator) no longer needed, so removed * Solved preference field editor issues with executing shell command in validation eg. re-entry caused by SWT event handling * Improvements DartPreferencePageTest including new WaitCondition for transition from displaying error to clearing the error
- Loading branch information
Showing
20 changed files
with
1,527 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...pse.dartboard.test/src/org/eclipse/dartboard/test/preference/PreferenceTestConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 vogella GmbH and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Jonas Hungershausen - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.dartboard.test.preference; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Optional; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
import org.eclipse.dartboard.util.PlatformUtil; | ||
|
||
public class PreferenceTestConstants { | ||
|
||
private static String OS = System.getProperty("os.name").toLowerCase(); | ||
|
||
public static final String DEFAULT_DART_LOCATION; | ||
public static final String INVALID_SDK_LOCATION = "some-random-test-location/path-segment"; | ||
|
||
public static final String DEFAULT_FLUTTER_LOCATION; | ||
|
||
static { | ||
boolean isWindows = OS.indexOf("win") >= 0; | ||
DEFAULT_DART_LOCATION = isWindows ? "C:\\Program Files\\Dart\\dart-sdk" : "/usr/lib/dart"; | ||
Optional<Path> flutterSdkLocation = null; | ||
try { | ||
flutterSdkLocation = PlatformUtil.getInstance().getLocation("flutter"); | ||
} catch (ExecutionException e) { | ||
} | ||
boolean isFlutterAvailable = (flutterSdkLocation != null) && flutterSdkLocation.isPresent(); | ||
DEFAULT_FLUTTER_LOCATION = isFlutterAvailable ? flutterSdkLocation.get().toString() : null; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...clipse.dartboard.test/src/org/eclipse/dartboard/test/preference/ValidPreferenceState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 vogella GmbH and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Andrew Bowley | ||
*******************************************************************************/ | ||
package org.eclipse.dartboard.test.preference; | ||
|
||
/** | ||
* Interface for preference dialog which can flag when it is displaying it's | ||
* valid state | ||
* | ||
* @author Andrew Bowley | ||
* | ||
*/ | ||
public interface ValidPreferenceState { | ||
|
||
boolean isValid(); | ||
} |
58 changes: 58 additions & 0 deletions
58
org.eclipse.dartboard.test/src/org/eclipse/dartboard/test/preference/WaitForValidState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.eclipse.dartboard.test.preference; | ||
|
||
import org.eclipse.reddeer.common.condition.WaitCondition; | ||
|
||
/** | ||
* RedDeer WaitCondition implementation for wait for preference dialog to | ||
* display it's valid state. This normally means the dialog header displays a | ||
* title rather than an error message. | ||
* | ||
* @author Andrew Bowley | ||
* | ||
*/ | ||
public class WaitForValidState implements WaitCondition { | ||
|
||
private final String title; | ||
private final ValidPreferenceState preferencePage; | ||
private boolean isValid; | ||
|
||
/** | ||
* Construct WaitForValidState object | ||
* | ||
* @param preferencePage Preference page implementing ValidPreferenceState | ||
* interface | ||
* @param title Title displayed in dialog header | ||
*/ | ||
public WaitForValidState(ValidPreferenceState preferencePage, String title) { | ||
this.preferencePage = preferencePage; | ||
this.title = title; | ||
} | ||
|
||
@Override | ||
public boolean test() { | ||
isValid = preferencePage.isValid(); | ||
return isValid; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public Boolean getResult() { | ||
return isValid; | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return title + " preference dialog transition to valid state"; | ||
} | ||
|
||
@Override | ||
public String errorMessageWhile() { | ||
return "Waiting for " + description(); | ||
} | ||
|
||
@Override | ||
public String errorMessageUntil() { | ||
return "Until " + description(); | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
org.eclipse.dartboard/src/org/eclipse/dartboard/os/linux/PlatformDartSdkChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 vogella GmbH and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Andrew Bowley | ||
*******************************************************************************/ | ||
package org.eclipse.dartboard.os.linux; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import org.eclipse.dartboard.util.DartSdkChecker; | ||
import org.eclipse.swt.widgets.Shell; | ||
|
||
import com.google.common.collect.Lists; | ||
|
||
/** | ||
* Checks if a given Linux location contains a Dart SDK | ||
* | ||
* @author Andrew Bowley | ||
* | ||
*/ | ||
@SuppressWarnings("nls") | ||
public class PlatformDartSdkChecker extends DartSdkChecker { | ||
|
||
/** | ||
* Construct LinuxDartSdkChecker object | ||
* | ||
* @param shell Parent shell of owner or null if none | ||
* @param isFlutter Flag set true if Dart SDK is inside Flutter | ||
*/ | ||
public PlatformDartSdkChecker(Shell shell, boolean isFlutter) { | ||
super(shell, !isFlutter ? "bin" | ||
: "bin" + File.separator + "cache" + File.separator + "dart-sdk" + File.separator + "bin"); | ||
} | ||
|
||
@Override | ||
public String[] getDartVersionCommands(String executablePath) { | ||
return new String[] { "/bin/bash", "-c", executablePath + " --version" }; | ||
} | ||
|
||
@Override | ||
public List<String> getBlacklist() { | ||
return Lists.newArrayList("/bin/dart", "/usr/bin/dart"); | ||
} | ||
|
||
@Override | ||
public String getDartExecutable() { | ||
return "dart"; //$NON-NLS-1$ | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
org.eclipse.dartboard/src/org/eclipse/dartboard/os/linux/PlatformFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 vogella GmbH and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Andrew Bowley | ||
*******************************************************************************/ | ||
package org.eclipse.dartboard.os.linux; | ||
|
||
import org.eclipse.dartboard.util.DartSdkChecker; | ||
import org.eclipse.dartboard.util.IPlatformFactory; | ||
import org.eclipse.dartboard.util.SdkLocator; | ||
import org.eclipse.swt.widgets.Shell; | ||
|
||
public class PlatformFactory implements IPlatformFactory { | ||
|
||
private final PlatformSdkLocator sdkLocator; | ||
|
||
public PlatformFactory() { | ||
sdkLocator = new PlatformSdkLocator(); | ||
} | ||
|
||
@Override | ||
public DartSdkChecker getDartSdkChecker(Shell shell, boolean isFlutter) { | ||
|
||
/** | ||
* Returns a Dart SDK checker | ||
* | ||
* @param shell Parent shell of owner or null if none | ||
* @param isFlutter Flag set true if Dart SDK is inside Flutter | ||
* @return DartSdkChecker object | ||
*/ | ||
return new PlatformDartSdkChecker(shell, isFlutter); | ||
|
||
} | ||
|
||
/** | ||
* Returns support for locating SDK artifacts | ||
* | ||
* @return SdkLocator | ||
*/ | ||
@Override | ||
public SdkLocator getSdkLocator() { | ||
return sdkLocator; | ||
} | ||
} |
Oops, something went wrong.