@SuppressWarnings("unused") @Test public void testFindDeveloperImage() throws Exception { Path dsDir = Files.createTempDirectory(getClass().getSimpleName()); File f50 = createDeveloperImage(dsDir, "5.0"); File f51 = createDeveloperImage(dsDir, "5.1"); File f60 = createDeveloperImage(dsDir, "6.0"); File f61 = createDeveloperImage(dsDir, "6.1"); File f612 = createDeveloperImage(dsDir, "6.1.2"); File f613 = createDeveloperImage(dsDir, "6.1.3", false); File f70_11A465 = createDeveloperImage(dsDir, "7.0 (11A465)"); File f703_11B508 = createDeveloperImage(dsDir, "7.0.3 (11B508)"); assertEquals(f703_11B508, AppLauncher.findDeveloperImage(dsDir.toFile(), "7.0.3", "11B508")); assertEquals(f61, AppLauncher.findDeveloperImage(dsDir.toFile(), "6.1.3", "10A123")); assertEquals(f61, AppLauncher.findDeveloperImage(dsDir.toFile(), "6.1.1", "10A123")); assertEquals(f612, AppLauncher.findDeveloperImage(dsDir.toFile(), "6.1.2", "10A123")); assertEquals(f703_11B508, AppLauncher.findDeveloperImage(dsDir.toFile(), "7.0.3", "12C123")); assertEquals(f70_11A465, AppLauncher.findDeveloperImage(dsDir.toFile(), "7.0.2", "12C123")); }
static File findDeveloperImage(File dsDir, String productVersion, String buildVersion) throws FileNotFoundException { String[] versionParts = getProductVersionParts(productVersion); String[] patterns = new String[] { String.format("%s\\.%s\\.%s \\(%s\\)", versionParts[0], versionParts[1], versionParts[2], buildVersion), String.format("%s\\.%s\\.%s \\(.*\\)", versionParts[0], versionParts[1], versionParts[2], buildVersion), String.format("%s\\.%s\\.%s", versionParts[0], versionParts[1], versionParts[2]), String.format("%s\\.%s \\(%s\\)", versionParts[0], versionParts[1], buildVersion), String.format("%s\\.%s \\(.*\\)", versionParts[0], versionParts[1], buildVersion), String.format("%s\\.%s", versionParts[0], versionParts[1]) }; File[] dirs = dsDir.listFiles(); for (String pattern : patterns) { for (File dir : dirs) { if (dir.isDirectory() && dir.getName().matches(pattern)) { File dmg = new File(dir, "DeveloperDiskImage.dmg"); File sig = new File(dir, dmg.getName() + ".signature"); if (dmg.isFile() && sig.isFile()) { return dmg; } } } } throw new FileNotFoundException("No DeveloperDiskImage.dmg found in " + dsDir.getAbsolutePath() + " for iOS version " + productVersion + " (" + buildVersion + ")"); }
AppLauncher { static File findDeveloperImage(File dsDir, String productVersion, String buildVersion) throws FileNotFoundException { String[] versionParts = getProductVersionParts(productVersion); String[] patterns = new String[] { String.format("%s\\.%s\\.%s \\(%s\\)", versionParts[0], versionParts[1], versionParts[2], buildVersion), String.format("%s\\.%s\\.%s \\(.*\\)", versionParts[0], versionParts[1], versionParts[2], buildVersion), String.format("%s\\.%s\\.%s", versionParts[0], versionParts[1], versionParts[2]), String.format("%s\\.%s \\(%s\\)", versionParts[0], versionParts[1], buildVersion), String.format("%s\\.%s \\(.*\\)", versionParts[0], versionParts[1], buildVersion), String.format("%s\\.%s", versionParts[0], versionParts[1]) }; File[] dirs = dsDir.listFiles(); for (String pattern : patterns) { for (File dir : dirs) { if (dir.isDirectory() && dir.getName().matches(pattern)) { File dmg = new File(dir, "DeveloperDiskImage.dmg"); File sig = new File(dir, dmg.getName() + ".signature"); if (dmg.isFile() && sig.isFile()) { return dmg; } } } } throw new FileNotFoundException("No DeveloperDiskImage.dmg found in " + dsDir.getAbsolutePath() + " for iOS version " + productVersion + " (" + buildVersion + ")"); } }
AppLauncher { static File findDeveloperImage(File dsDir, String productVersion, String buildVersion) throws FileNotFoundException { String[] versionParts = getProductVersionParts(productVersion); String[] patterns = new String[] { String.format("%s\\.%s\\.%s \\(%s\\)", versionParts[0], versionParts[1], versionParts[2], buildVersion), String.format("%s\\.%s\\.%s \\(.*\\)", versionParts[0], versionParts[1], versionParts[2], buildVersion), String.format("%s\\.%s\\.%s", versionParts[0], versionParts[1], versionParts[2]), String.format("%s\\.%s \\(%s\\)", versionParts[0], versionParts[1], buildVersion), String.format("%s\\.%s \\(.*\\)", versionParts[0], versionParts[1], buildVersion), String.format("%s\\.%s", versionParts[0], versionParts[1]) }; File[] dirs = dsDir.listFiles(); for (String pattern : patterns) { for (File dir : dirs) { if (dir.isDirectory() && dir.getName().matches(pattern)) { File dmg = new File(dir, "DeveloperDiskImage.dmg"); File sig = new File(dir, dmg.getName() + ".signature"); if (dmg.isFile() && sig.isFile()) { return dmg; } } } } throw new FileNotFoundException("No DeveloperDiskImage.dmg found in " + dsDir.getAbsolutePath() + " for iOS version " + productVersion + " (" + buildVersion + ")"); } AppLauncher(IDevice device, String appId);  AppLauncher(IDevice device, File localAppPath); private  AppLauncher(IDevice device, String appId, File localAppPath); }
AppLauncher { static File findDeveloperImage(File dsDir, String productVersion, String buildVersion) throws FileNotFoundException { String[] versionParts = getProductVersionParts(productVersion); String[] patterns = new String[] { String.format("%s\\.%s\\.%s \\(%s\\)", versionParts[0], versionParts[1], versionParts[2], buildVersion), String.format("%s\\.%s\\.%s \\(.*\\)", versionParts[0], versionParts[1], versionParts[2], buildVersion), String.format("%s\\.%s\\.%s", versionParts[0], versionParts[1], versionParts[2]), String.format("%s\\.%s \\(%s\\)", versionParts[0], versionParts[1], buildVersion), String.format("%s\\.%s \\(.*\\)", versionParts[0], versionParts[1], buildVersion), String.format("%s\\.%s", versionParts[0], versionParts[1]) }; File[] dirs = dsDir.listFiles(); for (String pattern : patterns) { for (File dir : dirs) { if (dir.isDirectory() && dir.getName().matches(pattern)) { File dmg = new File(dir, "DeveloperDiskImage.dmg"); File sig = new File(dir, dmg.getName() + ".signature"); if (dmg.isFile() && sig.isFile()) { return dmg; } } } } throw new FileNotFoundException("No DeveloperDiskImage.dmg found in " + dsDir.getAbsolutePath() + " for iOS version " + productVersion + " (" + buildVersion + ")"); } AppLauncher(IDevice device, String appId);  AppLauncher(IDevice device, File localAppPath); private  AppLauncher(IDevice device, String appId, File localAppPath); AppLauncher uploadProgressCallback(UploadProgressCallback callback); AppLauncher installStatusCallback(StatusCallback callback); AppLauncher args(String ... args); AppLauncher stdout(OutputStream stdout); AppLauncher closeOutOnExit(boolean closeOutOnExit); AppLauncher env(String name, String value); AppLauncher env(Map<String, String> env); AppLauncher debug(boolean debug); AppLauncher forward(int localPort); AppLauncher appLauncherCallback(AppLauncherCallback callback); AppLauncher xcodePath(String xcodePath); AppLauncher launchOnLockedRetries(int launchOnLockedRetries); AppLauncher secondsBetweenLaunchOnLockedRetries(int secondsBetweenLaunchOnLockedRetries); void kill(); void install(); int launch(); static void main(String[] args); }
AppLauncher { static File findDeveloperImage(File dsDir, String productVersion, String buildVersion) throws FileNotFoundException { String[] versionParts = getProductVersionParts(productVersion); String[] patterns = new String[] { String.format("%s\\.%s\\.%s \\(%s\\)", versionParts[0], versionParts[1], versionParts[2], buildVersion), String.format("%s\\.%s\\.%s \\(.*\\)", versionParts[0], versionParts[1], versionParts[2], buildVersion), String.format("%s\\.%s\\.%s", versionParts[0], versionParts[1], versionParts[2]), String.format("%s\\.%s \\(%s\\)", versionParts[0], versionParts[1], buildVersion), String.format("%s\\.%s \\(.*\\)", versionParts[0], versionParts[1], buildVersion), String.format("%s\\.%s", versionParts[0], versionParts[1]) }; File[] dirs = dsDir.listFiles(); for (String pattern : patterns) { for (File dir : dirs) { if (dir.isDirectory() && dir.getName().matches(pattern)) { File dmg = new File(dir, "DeveloperDiskImage.dmg"); File sig = new File(dir, dmg.getName() + ".signature"); if (dmg.isFile() && sig.isFile()) { return dmg; } } } } throw new FileNotFoundException("No DeveloperDiskImage.dmg found in " + dsDir.getAbsolutePath() + " for iOS version " + productVersion + " (" + buildVersion + ")"); } AppLauncher(IDevice device, String appId);  AppLauncher(IDevice device, File localAppPath); private  AppLauncher(IDevice device, String appId, File localAppPath); AppLauncher uploadProgressCallback(UploadProgressCallback callback); AppLauncher installStatusCallback(StatusCallback callback); AppLauncher args(String ... args); AppLauncher stdout(OutputStream stdout); AppLauncher closeOutOnExit(boolean closeOutOnExit); AppLauncher env(String name, String value); AppLauncher env(Map<String, String> env); AppLauncher debug(boolean debug); AppLauncher forward(int localPort); AppLauncher appLauncherCallback(AppLauncherCallback callback); AppLauncher xcodePath(String xcodePath); AppLauncher launchOnLockedRetries(int launchOnLockedRetries); AppLauncher secondsBetweenLaunchOnLockedRetries(int secondsBetweenLaunchOnLockedRetries); void kill(); void install(); int launch(); static void main(String[] args); static final int DEFAULT_FORWARD_PORT; }