From ee07ff5f0e19def7f6a8ea7e9c23aef92deaa469 Mon Sep 17 00:00:00 2001 From: Maurice McCabe Date: Mon, 16 Dec 2019 13:36:24 -0800 Subject: [PATCH 1/7] Added test for getIosDevices() #172 --- lib/src/daemon_client.dart | 2 +- test/daemon_client_test.dart | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) 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 {} From 3a2d1aabbe11d23b26b0bce6c6459d43af8d2b1f Mon Sep 17 00:00:00 2001 From: Maurice McCabe Date: Mon, 16 Dec 2019 13:58:35 -0800 Subject: [PATCH 2/7] Skip homebrew update, upgraded Flutter to 1.12.13+hotfix.5 --- .cirrus.yml | 4 +++- .travis.yml | 14 ++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index ac29efe2..69bd8bc8 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -13,7 +13,7 @@ unit_task: test_script: - pub run test test/all_tests.dart activate_coverage_script: - - pub global activate coverage 0.13.3 + - pub global activate coverage coverage_test_script: - script/code_coverage.sh @@ -29,6 +29,8 @@ ios_integration_task: simulators_json_script: - xcrun simctl list devices --json imagemagick_install_script: + # skip homebrew update + - export HOMEBREW_NO_AUTO_UPDATE=1 - brew install imagemagick - convert -version || echo -n doctor_script: flutter doctor -v diff --git a/.travis.yml b/.travis.yml index d7d4ed27..b087e925 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 @@ -43,7 +43,7 @@ jobs: - pub run test test/all_tests.dart # install image magick (already installed) # install coverage tool - - pub global activate coverage 0.13.3 + - pub global activate coverage script: - script/code_coverage.sh @@ -103,7 +103,9 @@ jobs: - flutter doctor -v # install ImageMagick - - brew install imagemagick & + # skip homebrew update + - export HOMEBREW_NO_AUTO_UPDATE=1 + - brew install imagemagick # install most current (released or unreleased) Screenshots - pub global activate --source path . @@ -154,8 +156,8 @@ 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} From 80241bed7aec5ea84424ad110b3dfbfebab610cf Mon Sep 17 00:00:00 2001 From: Maurice McCabe Date: Mon, 16 Dec 2019 14:53:27 -0800 Subject: [PATCH 3/7] Ignore error in auto-update --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 69bd8bc8..9692534e 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -31,7 +31,7 @@ ios_integration_task: imagemagick_install_script: # skip homebrew update - export HOMEBREW_NO_AUTO_UPDATE=1 - - brew install imagemagick + - 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 . From 2ef5b7564869201f099c666cdd7edef49b6a73fb Mon Sep 17 00:00:00 2001 From: Maurice McCabe Date: Mon, 16 Dec 2019 14:57:08 -0800 Subject: [PATCH 4/7] Upgraded flutter to 1.12.13+hotfix.5 again --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7d71929..9a6dcd3e 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 From cabfddc41e180aab879fd874558aab9dd93a3332 Mon Sep 17 00:00:00 2001 From: Maurice McCabe Date: Mon, 16 Dec 2019 15:07:02 -0800 Subject: [PATCH 5/7] Added diagnostic --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9a6dcd3e..8660981b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -82,6 +82,9 @@ jobs: install: - flutter doctor -v + - flutter precache + - sh -c "ios-deploy -c" || echo "no attached devices" + # install ImageMagick - export HOMEBREW_NO_AUTO_UPDATE=1 From 71b70d06485fa787f240637db4d136cdb64a03bc Mon Sep 17 00:00:00 2001 From: Maurice McCabe Date: Mon, 16 Dec 2019 15:12:11 -0800 Subject: [PATCH 6/7] Added diagnostic --- .cirrus.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.cirrus.yml b/.cirrus.yml index 9692534e..6795d058 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -24,6 +24,7 @@ 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: From dbdc597f6eef0976a5d87eda808574b3e5ba814e Mon Sep 17 00:00:00 2001 From: Maurice McCabe Date: Mon, 16 Dec 2019 15:18:08 -0800 Subject: [PATCH 7/7] Create named avd --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8660981b..0cde5ab3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -193,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