mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-26 20:54:22 +01:00
HostDependentDownloadableContribution better handles Macosx
This commit is contained in:
parent
a98240bc58
commit
e5e5880a15
33
app/src/processing/app/debug/TargetPackageStub.java
Normal file
33
app/src/processing/app/debug/TargetPackageStub.java
Normal file
@ -0,0 +1,33 @@
|
||||
package processing.app.debug;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class TargetPackageStub implements TargetPackage {
|
||||
|
||||
private final String id;
|
||||
|
||||
public TargetPackageStub(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, TargetPlatform> getPlatforms() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TargetPlatform> platforms() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPlatform get(String platform) {
|
||||
return null;
|
||||
}
|
||||
}
|
73
app/test/processing/app/debug/TargetPlatformStub.java
Normal file
73
app/test/processing/app/debug/TargetPlatformStub.java
Normal file
@ -0,0 +1,73 @@
|
||||
package processing.app.debug;
|
||||
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class TargetPlatformStub implements TargetPlatform {
|
||||
|
||||
private final String id;
|
||||
private final TargetPackage targetPackage;
|
||||
|
||||
public TargetPlatformStub(String id, TargetPackage targetPackage) {
|
||||
this.id = id;
|
||||
this.targetPackage = targetPackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFolder() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, TargetBoard> getBoards() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreferencesMap getCustomMenus() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getCustomMenuIds() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, PreferencesMap> getProgrammers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreferencesMap getProgrammer(String programmer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreferencesMap getTool(String tool) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreferencesMap getPreferences() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetBoard getBoard(String boardId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPackage getContainerPackage() {
|
||||
return targetPackage;
|
||||
}
|
||||
}
|
@ -5,26 +5,21 @@ import cc.arduino.packages.Uploader;
|
||||
import cc.arduino.packages.UploaderFactory;
|
||||
import cc.arduino.packages.uploaders.SSHUploader;
|
||||
import cc.arduino.packages.uploaders.SerialUploader;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.app.AbstractWithPreferencesTest;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class UploaderFactoryTest extends AbstractWithPreferencesTest {
|
||||
|
||||
private TargetPackage targetPackage;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
targetPackage = new LegacyTargetPackage("arduino", new File(".", "hardware/arduino/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreateAnInstanceOfSSHUploader() throws Exception {
|
||||
TargetBoard board = targetPackage.getPlatforms().get("avr").getBoards().get("yun");
|
||||
TargetBoard board = new LegacyTargetBoard("yun", new PreferencesMap(new HashMap<String, String>()), new TargetPlatformStub("id", new TargetPackageStub("id")));
|
||||
board.getPreferences().put("upload.via_ssh", "true");
|
||||
|
||||
BoardPort boardPort = new BoardPort();
|
||||
boardPort.setBoardName("yun");
|
||||
boardPort.setAddress("192.168.0.1");
|
||||
@ -36,7 +31,9 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
|
||||
|
||||
@Test
|
||||
public void shouldCreateAnInstanceOfBasicUploaderWhenSSHIsUnsupported() throws Exception {
|
||||
TargetBoard board = targetPackage.getPlatforms().get("avr").getBoards().get("uno");
|
||||
TargetBoard board = new LegacyTargetBoard("uno", new PreferencesMap(new HashMap<String, String>()), new TargetPlatformStub("id", new TargetPackageStub("id")));
|
||||
board.getPreferences().put("upload.via_ssh", "false");
|
||||
|
||||
BoardPort boardPort = new BoardPort();
|
||||
boardPort.setBoardName("myyun");
|
||||
boardPort.setAddress("192.168.0.1");
|
||||
@ -48,7 +45,9 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
|
||||
|
||||
@Test
|
||||
public void shouldCreateAnInstanceOfBasicUploaderWhenPortIsSerial() throws Exception {
|
||||
TargetBoard board = targetPackage.getPlatforms().get("avr").getBoards().get("uno");
|
||||
TargetBoard board = new LegacyTargetBoard("uno", new PreferencesMap(new HashMap<String, String>()), new TargetPlatformStub("id", new TargetPackageStub("id")));
|
||||
board.getPreferences().put("upload.via_ssh", "false");
|
||||
|
||||
BoardPort boardPort = new BoardPort();
|
||||
boardPort.setBoardName("Arduino Leonardo");
|
||||
boardPort.setAddress("/dev/ttyACM0");
|
||||
|
@ -30,8 +30,7 @@ package cc.arduino.packages.contributions;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public abstract class HostDependentDownloadableContribution extends
|
||||
DownloadableContribution {
|
||||
public abstract class HostDependentDownloadableContribution extends DownloadableContribution {
|
||||
|
||||
public abstract String getHost();
|
||||
|
||||
@ -53,25 +52,21 @@ public abstract class HostDependentDownloadableContribution extends
|
||||
|
||||
if (osName.contains("Linux")) {
|
||||
if (osArch.contains("amd64")) {
|
||||
// os.arch = amd64
|
||||
return host.matches("x86_64-.*linux-gnu");
|
||||
} else {
|
||||
// 32 bit systems
|
||||
return host.matches("i[3456]86-.*linux-gnu");
|
||||
}
|
||||
}
|
||||
|
||||
if (osName.contains("Windows")) {
|
||||
if (host.matches("i[3456]86-.*mingw32"))
|
||||
return true;
|
||||
if (host.matches("i[3456]86-.*cygwin"))
|
||||
return true;
|
||||
return host.matches("i[3456]86-.*mingw32") || host.matches("i[3456]86-.*cygwin");
|
||||
}
|
||||
|
||||
if (osName.contains("Mac")) {
|
||||
if (osArch.contains("86")) {
|
||||
if (host.matches("i[3456]86-apple-darwin.*"))
|
||||
return true;
|
||||
if (osArch.contains("x86_64")) {
|
||||
return host.matches("x86_64-apple-darwin.*") || host.matches("i[3456]86-apple-darwin.*");
|
||||
} else {
|
||||
return host.matches("i[3456]86-apple-darwin.*");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user