mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
made parser aware of that now vid & pid have 0x
This commit is contained in:
@ -5,7 +5,7 @@ import org.junit.BeforeClass;
|
||||
public abstract class AbstractWithPreferencesTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
public static void init() throws Exception {
|
||||
Base.initPlatform();
|
||||
Preferences.init(null);
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package processing.app.debug;
|
||||
|
||||
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 java.util.Map;
|
||||
|
||||
@ -11,11 +13,16 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class UploaderFactoryTest extends AbstractWithPreferencesTest {
|
||||
|
||||
private TargetPackage targetPackage;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
targetPackage = new TargetPackage("arduino", new File(".", "hardware/arduino/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreateAnInstanceOfHttpUploader() throws Exception {
|
||||
Map<String, String> prefs = new HashMap<String, String>();
|
||||
prefs.put("upload.via_http", "true");
|
||||
TargetBoard board = new TargetBoard("dummy", new PreferencesMap(prefs), null);
|
||||
TargetBoard board = targetPackage.getPlatforms().get("avr").getBoards().get("dogstick");
|
||||
Uploader uploader = new UploaderFactory().newUploader(board, "192.168.0.1 (mydogstick)");
|
||||
|
||||
assertTrue(uploader instanceof HttpUploader);
|
||||
@ -23,8 +30,7 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
|
||||
|
||||
@Test
|
||||
public void shouldCreateAnInstanceOfBasicUploaderWhenHTTPIsUnsupported() throws Exception {
|
||||
Map<String, String> prefs = new HashMap<String, String>();
|
||||
TargetBoard board = new TargetBoard("dummy", new PreferencesMap(prefs), null);
|
||||
TargetBoard board = targetPackage.getPlatforms().get("avr").getBoards().get("uno");
|
||||
Uploader uploader = new UploaderFactory().newUploader(board, "192.168.0.1 (mydogstick)");
|
||||
|
||||
assertTrue(uploader instanceof BasicUploader);
|
||||
@ -32,8 +38,7 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
|
||||
|
||||
@Test
|
||||
public void shouldCreateAnInstanceOfBasicUploaderWhenPortIsSerial() throws Exception {
|
||||
Map<String, String> prefs = new HashMap<String, String>();
|
||||
TargetBoard board = new TargetBoard("dummy", new PreferencesMap(prefs), null);
|
||||
TargetBoard board = targetPackage.getPlatforms().get("avr").getBoards().get("uno");
|
||||
Uploader uploader = new UploaderFactory().newUploader(board, "/dev/ttyACM0 (Arduino Leonardo)");
|
||||
|
||||
assertTrue(uploader instanceof BasicUploader);
|
||||
|
@ -11,6 +11,6 @@ public class UDevAdmParserTest {
|
||||
public void shouldCorrectlyParse() throws Exception {
|
||||
String output = TestHelper.inputStreamToString(UDevAdmParserTest.class.getResourceAsStream("udev_output.txt"));
|
||||
|
||||
assertEquals("2341_0036", new UDevAdmParser().extractVIDAndPID(output));
|
||||
assertEquals("0X2341_0X0036", new UDevAdmParser().extractVIDAndPID(output));
|
||||
}
|
||||
}
|
||||
|
@ -11,13 +11,12 @@ public class SystemProfilerParserTest {
|
||||
public void shouldCorrectlyParse() throws Exception {
|
||||
String output = TestHelper.inputStreamToString(SystemProfilerParserTest.class.getResourceAsStream("system_profiler_output.txt"));
|
||||
|
||||
assertEquals("2341_0044", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodemfa121"));
|
||||
assertEquals("2341_0044", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodemfa121"));
|
||||
assertEquals("0X2341_0X0044", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodemfa121"));
|
||||
assertEquals("0X2341_0X0044", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodemfa121"));
|
||||
|
||||
output = TestHelper.inputStreamToString(SystemProfilerParserTest.class.getResourceAsStream("system_profiler_output2.txt"));
|
||||
|
||||
assertEquals("2341_8036", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodemfd131"));
|
||||
assertEquals("2341_8036", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodemfd131"));
|
||||
output = TestHelper.inputStreamToString(SystemProfilerParserTest.class.getResourceAsStream("system_profiler_output2.txt"));
|
||||
|
||||
assertEquals("0X2341_0X8036", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodemfd131"));
|
||||
assertEquals("0X2341_0X8036", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodemfd131"));
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,8 @@ public class ListComPortsParserTest {
|
||||
public void shouldFindVIDPID() throws Exception {
|
||||
String listComPortsOutput = "COM26 - FTDI - FTDIBUS\\VID_0403+PID_6001+A6004CCFA\\0000\nCOM24 - PJRC.COM, LLC. - USB\\VID_16C0&PID_0483\\12345";
|
||||
|
||||
ListComPortsParser parser = new ListComPortsParser();
|
||||
|
||||
assertEquals("0403_6001", parser.extractVIDAndPID(listComPortsOutput, "COM26"));
|
||||
assertEquals("16C0_0483", parser.extractVIDAndPID(listComPortsOutput, "COM24"));
|
||||
assertEquals("0X0403_0X6001", new ListComPortsParser().extractVIDAndPID(listComPortsOutput, "COM26"));
|
||||
assertEquals("0X16C0_0X0483", new ListComPortsParser().extractVIDAndPID(listComPortsOutput, "COM24"));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user