diff --git a/.cirrus.yml b/.cirrus.yml index 5a2a0df6..6795d058 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -24,12 +24,15 @@ ios_integration_task: pub_cache: folder: ~/.pub-cache simulators_script: + - sh -c "ios-deploy -c" || echo "no attached devices" - xcrun simctl list devicetypes - xcrun simctl list runtimes simulators_json_script: - xcrun simctl list devices --json imagemagick_install_script: - - brew install imagemagick + # skip homebrew update + - export HOMEBREW_NO_AUTO_UPDATE=1 + - brew install imagemagick || echo -n # ignore error in auto-update - convert -version || echo -n doctor_script: flutter doctor -v activate_script: pub global activate --source path . diff --git a/.travis.yml b/.travis.yml index 1fb863ff..0cde5ab3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ language: generic env: global: - FLUTTER_CHANNEL=stable - - FLUTTER_VERSION=1.9.1+hotfix.6-${FLUTTER_CHANNEL} - - DART_VERSION=2.5.0 # for unit tests + - FLUTTER_VERSION=1.12.13+hotfix.5-${FLUTTER_CHANNEL} + - DART_VERSION=2.7.0 # for unit tests matrix: fast_finish: true @@ -82,9 +82,14 @@ jobs: install: - flutter doctor -v + - flutter precache + - sh -c "ios-deploy -c" || echo "no attached devices" + + # install ImageMagick - export HOMEBREW_NO_AUTO_UPDATE=1 - brew install imagemagick + # install most current (released or unreleased) Screenshots - pub global activate --source path . @@ -125,8 +130,8 @@ jobs: cache: directories: - ${HOME}/.pub-cache -# - ${HOME}/.gradle/caches/ -# - ${HOME}/.gradle/wrapper/ + - ${HOME}/.gradle/caches/ + - ${HOME}/.gradle/wrapper/ before_install: # envs @@ -140,11 +145,12 @@ jobs: - TOOLS=${ANDROID_HOME}/tools # PATH order is incredibly important. e.g. the 'emulator' script exists in more than one place! - PATH=${ANDROID_HOME}:${ANDROID_HOME}/emulator:${TOOLS}:${TOOLS}/bin:${ANDROID_HOME}/platform-tools:${PATH} - - FLUTTER_CHANNEL=stable - - FLUTTER_VERSION=1.9.1+hotfix.6-${FLUTTER_CHANNEL} +# - FLUTTER_CHANNEL=stable +# - FLUTTER_VERSION=1.9.1+hotfix.6-${FLUTTER_CHANNEL} - FLUTTER_HOME=${HOME}/flutter - PATH=${HOME}/.pub-cache/bin:${PATH} - PATH=${FLUTTER_HOME}/bin:${FLUTTER_HOME}/bin/cache/dart-sdk/bin:${PATH} + - EMULATOR_NAME=NEXUS_6P_API_28 - java -version @@ -187,7 +193,7 @@ jobs: # Create an Android emulator # - echo no | avdmanager --verbose create avd --force -n test -k "system-images;android-$API;$GOO;$ABI" -c 10M - - echo no | avdmanager --verbose create avd --force -n test -k "system-images;android-$API;$GOO;$ABI" + - echo no | avdmanager --verbose create avd --force -n $EMULATOR_NAME -k "system-images;android-$API;$GOO;$ABI" # - EMU_PARAMS=" # -verbose # -no-snapshot @@ -199,12 +205,13 @@ jobs: # -selinux permissive # -qemu -m 2048" - EMU_PARAMS=" - -avd test + -avd $EMULATOR_NAME -no-window -no-audio + -verbose " -# - EMU_COMMAND="emulator" - - EMU_COMMAND="emulator-headless" +# - EMU_COMMAND="emulator-headless" + - EMU_COMMAND="emulator" # This double "sudo" monstrosity is used to have Travis execute the # emulator with its new group permissions and help preserve the rule # of least privilege. diff --git a/lib/src/daemon_client.dart b/lib/src/daemon_client.dart index 2ac00e65..950e37ca 100644 --- a/lib/src/daemon_client.dart +++ b/lib/src/daemon_client.dart @@ -216,7 +216,7 @@ List getIosDevices() { .trim() .split('\n') .sublist(1); - if (iosDeployDevices.isEmpty || iosDeployDevices[0] == noAttachedDevices) { + if (iosDeployDevices[0] == noAttachedDevices) { return []; } return iosDeployDevices.map((line) { diff --git a/test/daemon_client_test.dart b/test/daemon_client_test.dart index 029b5ddb..970c9ad6 100644 --- a/test/daemon_client_test.dart +++ b/test/daemon_client_test.dart @@ -390,6 +390,56 @@ main() { expect(emulator1, isNot(equals(device1))); }); }); + + group('getIosDevices', (){ + FakeProcessManager fakeProcessManager; + FakePlatform fakePlatform; + + setUp(() { + fakeProcessManager = FakeProcessManager(); + fakePlatform = FakePlatform.fromPlatform(const LocalPlatform()) + ..operatingSystem = 'macos'; + }); + + testUsingContext('no real device',(){ + fakeProcessManager.calls = [ + Call( + 'sh -c ios-deploy -c || echo "no attached devices"', + ProcessResult( + 0, + 0, + '[....] Waiting up to 5 seconds for iOS device to be connected\nno attached devices', + '')), + ]; + final iosDevices = getIosDevices(); + expect(iosDevices, isEmpty); + fakeProcessManager.verifyCalls(); + }, overrides: { + ProcessManager: () => fakeProcessManager, + Platform: () => fakePlatform, + }); + + testUsingContext('real device',(){ + final uuid='uuid'; + final model = 'model'; + final expected = [{'id': uuid, 'model': model}]; + fakeProcessManager.calls = [ + Call( + 'sh -c ios-deploy -c || echo "no attached devices"', + ProcessResult( + 0, + 0, + "[....] Waiting up to 5 seconds for iOS device to be connected\n[....] Found $uuid (N69uAP, $model, iphoneos, arm64) a.k.a. 'My iPhone' connected through USB.", + '')), + ]; + final iosDevices = getIosDevices(); + expect(iosDevices, expected); + fakeProcessManager.verifyCalls(); + }, overrides: { + ProcessManager: () => fakeProcessManager, + Platform: () => fakePlatform, + }); + }); } class MockProcess extends Mock implements Process {}