creativecreatorormaybenot
Committed by GitHub

Release wakelock_macos (#89)

* Release wakelock_macos

* Fix warnings

* macOS integration tests only on dev

* Correct syntax

* Add macOS test stub

* Update platforms

* Enable macOS in config

* Fix tests

* Correct private getter
@@ -30,6 +30,7 @@ jobs: @@ -30,6 +30,7 @@ jobs:
30 - 'dev' 30 - 'dev'
31 package: 31 package:
32 - 'wakelock' 32 - 'wakelock'
  33 + - 'wakelock_macos'
33 - 'wakelock_platform_interface' 34 - 'wakelock_platform_interface'
34 - 'wakelock_web' 35 - 'wakelock_web'
35 fail-fast: false 36 fail-fast: false
@@ -50,7 +51,7 @@ jobs: @@ -50,7 +51,7 @@ jobs:
50 test: 51 test:
51 timeout-minutes: 14 52 timeout-minutes: 14
52 runs-on: macos-latest 53 runs-on: macos-latest
53 - name: Testing of ${{ matrix.package }} (${{ matrix.channel }}; ${{ matrix.device }}) 54 + name: Testing of ${{ matrix.package }} (${{ matrix.channel }})
54 strategy: 55 strategy:
55 matrix: 56 matrix:
56 device: 57 device:
@@ -62,6 +63,7 @@ jobs: @@ -62,6 +63,7 @@ jobs:
62 - 'dev' 63 - 'dev'
63 package: 64 package:
64 - 'wakelock' 65 - 'wakelock'
  66 + - 'wakelock_macos'
65 - 'wakelock_platform_interface' 67 - 'wakelock_platform_interface'
66 # Web tests do not work for now. 68 # Web tests do not work for now.
67 # - 'wakelock_web' 69 # - 'wakelock_web'
@@ -92,10 +94,18 @@ jobs: @@ -92,10 +94,18 @@ jobs:
92 working-directory: ${{ matrix.package }} 94 working-directory: ${{ matrix.package }}
93 - name: Run unit tests (chrome) 95 - name: Run unit tests (chrome)
94 if: matrix.package == 'wakelock_web' 96 if: matrix.package == 'wakelock_web'
95 - run: flutter test --platform chrome 97 + run: |
  98 + flutter config --enable-web
  99 + flutter test --platform chrome
96 working-directory: ${{ matrix.package }} 100 working-directory: ${{ matrix.package }}
97 - name: Integration tests on iOS 101 - name: Integration tests on iOS
98 if: matrix.package == 'wakelock' 102 if: matrix.package == 'wakelock'
99 run: | 103 run: |
100 cd wakelock/example 104 cd wakelock/example
101 - flutter drive --driver=test_driver/integration_test.dart --target=integration_test/wakelock_test.dart --no-sound-null-safety 105 + flutter drive --driver=test_driver/integration_test.dart --target=integration_test/wakelock_test.dart
  106 + - name: Integration tests on macOS
  107 + if: matrix.package == 'wakelock_macos' && matrix.channel == 'dev'
  108 + run: |
  109 + cd wakelock/example
  110 + flutter config --enable-macos-desktop
  111 + flutter drive --driver=test_driver/integration_test.dart --target=integration_test/wakelock_test.dart -d macos
@@ -23,6 +23,7 @@ jobs: @@ -23,6 +23,7 @@ jobs:
23 matrix: 23 matrix:
24 package: 24 package:
25 - 'wakelock' 25 - 'wakelock'
  26 + - 'wakelock_macos'
26 - 'wakelock_platform_interface' 27 - 'wakelock_platform_interface'
27 - 'wakelock_web' 28 - 'wakelock_web'
28 fail-fast: false 29 fail-fast: false
@@ -13,10 +13,10 @@ jobs: @@ -13,10 +13,10 @@ jobs:
13 strategy: 13 strategy:
14 matrix: 14 matrix:
15 package: 15 package:
16 -# - 'wakelock'  
17 -# - 'wakelock_platform_interface'  
18 - - 'wakelock_web' 16 + - 'wakelock'
19 - 'wakelock_macos' 17 - 'wakelock_macos'
  18 + - 'wakelock_platform_interface'
  19 + - 'wakelock_web'
20 fail-fast: false 20 fail-fast: false
21 21
22 steps: 22 steps:
@@ -35,6 +35,7 @@ jobs: @@ -35,6 +35,7 @@ jobs:
35 matrix: 35 matrix:
36 package: 36 package:
37 - 'wakelock' 37 - 'wakelock'
  38 + - 'wakelock_macos'
38 - 'wakelock_platform_interface' 39 - 'wakelock_platform_interface'
39 - 'wakelock_web' 40 - 'wakelock_web'
40 fail-fast: false 41 fail-fast: false
@@ -52,19 +53,19 @@ jobs: @@ -52,19 +53,19 @@ jobs:
52 echo ::set-output name=changed::$? 53 echo ::set-output name=changed::$?
53 set -e 54 set -e
54 - name: Extract package version 55 - name: Extract package version
55 -# if: steps.pubspec.outputs.changed == 0 56 + if: steps.pubspec.outputs.changed == 0
56 run: | 57 run: |
57 cd ${{ matrix.package }} 58 cd ${{ matrix.package }}
58 echo "VERSION=$(awk '{if ($1 ~ /^version:/) print $2}' pubspec.yaml)" >> $GITHUB_ENV 59 echo "VERSION=$(awk '{if ($1 ~ /^version:/) print $2}' pubspec.yaml)" >> $GITHUB_ENV
59 - uses: sakebook/actions-flutter-pub-publisher@v1.3.1 60 - uses: sakebook/actions-flutter-pub-publisher@v1.3.1
60 -# if: steps.pubspec.outputs.changed == 0 61 + if: steps.pubspec.outputs.changed == 0
61 with: 62 with:
62 package_directory: ${{ matrix.package }} 63 package_directory: ${{ matrix.package }}
63 credential: ${{ secrets.PUB_CREDENTIALS }} 64 credential: ${{ secrets.PUB_CREDENTIALS }}
64 flutter_package: true 65 flutter_package: true
65 skip_test: true 66 skip_test: true
66 - name: Create Release 67 - name: Create Release
67 -# if: steps.pubspec.outputs.changed == 0 68 + if: steps.pubspec.outputs.changed == 0
68 id: create_release 69 id: create_release
69 uses: actions/create-release@v1.1.4 70 uses: actions/create-release@v1.1.4
70 env: 71 env:
  1 +## 0.4.0-nullsafety.0
  2 +
  3 +* Added macOS support 🚀
  4 +
1 ## 0.3.0-nullsafety.3 5 ## 0.3.0-nullsafety.3
2 6
3 * Add supported platforms to README. 7 * Add supported platforms to README.
@@ -19,10 +19,10 @@ EXTERNAL SOURCES: @@ -19,10 +19,10 @@ EXTERNAL SOURCES:
19 :path: ".symlinks/plugins/wakelock/ios" 19 :path: ".symlinks/plugins/wakelock/ios"
20 20
21 SPEC CHECKSUMS: 21 SPEC CHECKSUMS:
22 - Flutter: 0e3d915762c693b495b44d77113d4970485de6ec 22 + Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
23 integration_test: 5ed24a436eb7ec17b6a13046e9bf7ca4a404e59e 23 integration_test: 5ed24a436eb7ec17b6a13046e9bf7ca4a404e59e
24 wakelock: bfc7955c418d0db797614075aabbc58a39ab5107 24 wakelock: bfc7955c418d0db797614075aabbc58a39ab5107
25 25
26 PODFILE CHECKSUM: 8e679eca47255a8ca8067c4c67aab20e64cb974d 26 PODFILE CHECKSUM: 8e679eca47255a8ca8067c4c67aab20e64cb974d
27 27
28 -COCOAPODS: 1.9.3 28 +COCOAPODS: 1.10.0
@@ -150,7 +150,6 @@ @@ -150,7 +150,6 @@
150 97C146EC1CF9000F007C117D /* Resources */, 150 97C146EC1CF9000F007C117D /* Resources */,
151 9705A1C41CF9048500538489 /* Embed Frameworks */, 151 9705A1C41CF9048500538489 /* Embed Frameworks */,
152 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 152 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
153 - FAD6D21B222DFE9FB43C310E /* [CP] Embed Pods Frameworks */,  
154 ); 153 );
155 buildRules = ( 154 buildRules = (
156 ); 155 );
@@ -258,24 +257,6 @@ @@ -258,24 +257,6 @@
258 shellPath = /bin/sh; 257 shellPath = /bin/sh;
259 shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 258 shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
260 }; 259 };
261 - FAD6D21B222DFE9FB43C310E /* [CP] Embed Pods Frameworks */ = {  
262 - isa = PBXShellScriptBuildPhase;  
263 - buildActionMask = 2147483647;  
264 - files = (  
265 - );  
266 - inputPaths = (  
267 - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",  
268 - "${PODS_ROOT}/../Flutter/Flutter.framework",  
269 - );  
270 - name = "[CP] Embed Pods Frameworks";  
271 - outputPaths = (  
272 - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",  
273 - );  
274 - runOnlyForDeploymentPostprocessing = 0;  
275 - shellPath = /bin/sh;  
276 - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";  
277 - showEnvVarsInLog = 0;  
278 - };  
279 /* End PBXShellScriptBuildPhase section */ 260 /* End PBXShellScriptBuildPhase section */
280 261
281 /* Begin PBXSourcesBuildPhase section */ 262 /* Begin PBXSourcesBuildPhase section */
@@ -15,7 +15,7 @@ EXTERNAL SOURCES: @@ -15,7 +15,7 @@ EXTERNAL SOURCES:
15 15
16 SPEC CHECKSUMS: 16 SPEC CHECKSUMS:
17 FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 17 FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
18 - wakelock_macos: d4628428650258e4b7bcb43458408b2a83385ea1 18 + wakelock_macos: 493294b94b32c558d5ca409b3991a131c89c1970
19 19
20 PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c 20 PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
21 21
@@ -6,7 +6,10 @@ publish_to: 'none' @@ -6,7 +6,10 @@ publish_to: 'none'
6 version: 1.0.0+1 6 version: 1.0.0+1
7 7
8 environment: 8 environment:
9 - sdk: '>=2.12.0-0 <3.0.0' 9 + # Opt out of null safety on purpose because dependencies do not support sound null safety yet
  10 + # and flutter drive ignores the --no-sound-null-safety parameter.
  11 + # todo(creativecreatorormaybenot): switch to 2.12.0-0 lower bound.
  12 + sdk: '>=2.11.0 <3.0.0'
10 13
11 dependencies: 14 dependencies:
12 flutter: 15 flutter:
@@ -5,9 +5,9 @@ @@ -5,9 +5,9 @@
5 Pod::Spec.new do |s| 5 Pod::Spec.new do |s|
6 s.name = 'wakelock' 6 s.name = 'wakelock'
7 s.version = '0.0.1' 7 s.version = '0.0.1'
8 - s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web.' 8 + s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.'
9 s.description = <<-DESC 9 s.description = <<-DESC
10 -Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web. 10 +Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.
11 DESC 11 DESC
12 s.homepage = 'http://example.com' 12 s.homepage = 'http://example.com'
13 s.license = { :file => '../LICENSE' } 13 s.license = { :file => '../LICENSE' }
@@ -4,7 +4,15 @@ import 'package:flutter/foundation.dart'; @@ -4,7 +4,15 @@ import 'package:flutter/foundation.dart';
4 import 'package:wakelock_macos/wakelock_macos.dart'; 4 import 'package:wakelock_macos/wakelock_macos.dart';
5 import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; 5 import 'package:wakelock_platform_interface/wakelock_platform_interface.dart';
6 6
7 -final _wakelockPlatformInstance = !kIsWeb && 7 +/// The [WakelockPlatformInterface] that is used by [Wakelock].
  8 +///
  9 +/// This needs to be exposed for testing as unit tests might run on macOS.
  10 +/// In that case, the "hacky" instance override that we use here would be
  11 +/// triggered for the unit tests, even though the unit tests should actually
  12 +/// test the `pigeon` method channel implementation. Therefore, we want to
  13 +/// override this in tests that run on macOS (where there is no actual device).
  14 +@visibleForTesting
  15 +var wakelockPlatformInstance = !kIsWeb &&
8 // Assigning the macOS platform instance like this is not optimal. 16 // Assigning the macOS platform instance like this is not optimal.
9 // Ideally, we would use the default method channel instance on macOS, 17 // Ideally, we would use the default method channel instance on macOS,
10 // however, it is not yet entirely clear how to integrate with pigeon. 18 // however, it is not yet entirely clear how to integrate with pigeon.
@@ -66,7 +74,7 @@ class Wakelock { @@ -66,7 +74,7 @@ class Wakelock {
66 static Future<void> toggle({ 74 static Future<void> toggle({
67 required bool enable, 75 required bool enable,
68 }) { 76 }) {
69 - return _wakelockPlatformInstance.toggle(enable: enable); 77 + return wakelockPlatformInstance.toggle(enable: enable);
70 } 78 }
71 79
72 /// Returns whether the wakelock is currently enabled or not. 80 /// Returns whether the wakelock is currently enabled or not.
@@ -77,5 +85,5 @@ class Wakelock { @@ -77,5 +85,5 @@ class Wakelock {
77 /// ```dart 85 /// ```dart
78 /// bool wakelockEnabled = await Wakelock.enabled; 86 /// bool wakelockEnabled = await Wakelock.enabled;
79 /// ``` 87 /// ```
80 - static Future<bool> get enabled => _wakelockPlatformInstance.enabled; 88 + static Future<bool> get enabled => wakelockPlatformInstance.enabled;
81 } 89 }
1 name: wakelock 1 name: wakelock
2 description: >-2 2 description: >-2
3 Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on 3 Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on
4 - Android, iOS, and web.  
5 -version: 0.3.0-nullsafety.3 4 + Android, iOS, macOS, and web.
  5 +version: 0.4.0-nullsafety.0
6 homepage: https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock 6 homepage: https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock
7 7
8 environment: 8 environment:
@@ -15,7 +15,6 @@ dependencies: @@ -15,7 +15,6 @@ dependencies:
15 15
16 meta: ^1.2.0 16 meta: ^1.2.0
17 17
18 - # Include in a followup version when wakelock_macos has been published.  
19 wakelock_macos: ^0.1.0-nullsafety.0 18 wakelock_macos: ^0.1.0-nullsafety.0
20 wakelock_platform_interface: ^0.2.0-nullsafety.2 19 wakelock_platform_interface: ^0.2.0-nullsafety.2
21 wakelock_web: ^0.2.0-nullsafety.0 20 wakelock_web: ^0.2.0-nullsafety.0
  1 +import 'dart:io';
  2 +
1 import 'package:flutter_test/flutter_test.dart'; 3 import 'package:flutter_test/flutter_test.dart';
2 import 'package:wakelock/wakelock.dart'; 4 import 'package:wakelock/wakelock.dart';
3 import 'package:wakelock_platform_interface/messages.dart'; 5 import 'package:wakelock_platform_interface/messages.dart';
  6 +import 'package:wakelock_platform_interface/wakelock_platform_interface.dart';
4 7
5 void main() { 8 void main() {
6 TestWidgetsFlutterBinding.ensureInitialized(); 9 TestWidgetsFlutterBinding.ensureInitialized();
@@ -9,6 +12,12 @@ void main() { @@ -9,6 +12,12 @@ void main() {
9 late FakeWakelockApi fakeWakelock; 12 late FakeWakelockApi fakeWakelock;
10 13
11 setUpAll(() { 14 setUpAll(() {
  15 + if (Platform.isMacOS) {
  16 + // See the member documentation for the reason behind this.
  17 + // todo(creativecreatorormaybenot): remove this once macOS is migrated
  18 + // todo| to pigeon.
  19 + wakelockPlatformInstance = WakelockPlatformInterface.instance;
  20 + }
12 fakeWakelock = FakeWakelockApi(); 21 fakeWakelock = FakeWakelockApi();
13 }); 22 });
14 23
@@ -4,9 +4,9 @@ @@ -4,9 +4,9 @@
4 Pod::Spec.new do |s| 4 Pod::Spec.new do |s|
5 s.name = 'wakelock_macos' 5 s.name = 'wakelock_macos'
6 s.version = '0.0.1' 6 s.version = '0.0.1'
7 - s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web.' 7 + s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.'
8 s.description = <<-DESC 8 s.description = <<-DESC
9 - Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web. 9 + Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.
10 DESC 10 DESC
11 s.homepage = 'https://github.com/creativecreatorormaybenot/wakelock/tree/master/packages/wakelock_macos' 11 s.homepage = 'https://github.com/creativecreatorormaybenot/wakelock/tree/master/packages/wakelock_macos'
12 s.license = { :type => 'BSD', :file => '../LICENSE' } 12 s.license = { :type => 'BSD', :file => '../LICENSE' }
1 -import 'package:flutter/services.dart';  
2 import 'package:flutter_test/flutter_test.dart'; 1 import 'package:flutter_test/flutter_test.dart';
3 2
4 void main() { 3 void main() {
@@ -12,4 +11,8 @@ void main() { @@ -12,4 +11,8 @@ void main() {
12 // example app. 11 // example app.
13 // Consequently, the macOS implementation will be tested in CI via the 12 // Consequently, the macOS implementation will be tested in CI via the
14 // example integration test running on -d macos. 13 // example integration test running on -d macos.
  14 + test('stub', () {
  15 + final acceptUnitTestingDefeat = true;
  16 + expect(acceptUnitTestingDefeat, isTrue);
  17 + });
15 } 18 }