Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Release wakelock_macos (#89)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
creativecreatorormaybenot committed Jan 18, 2021
1 parent 9f80b2e commit 269fb74
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 43 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- 'dev'
package:
- 'wakelock'
- 'wakelock_macos'
- 'wakelock_platform_interface'
- 'wakelock_web'
fail-fast: false
Expand All @@ -50,7 +51,7 @@ jobs:
test:
timeout-minutes: 14
runs-on: macos-latest
name: Testing of ${{ matrix.package }} (${{ matrix.channel }}; ${{ matrix.device }})
name: Testing of ${{ matrix.package }} (${{ matrix.channel }})
strategy:
matrix:
device:
Expand All @@ -62,6 +63,7 @@ jobs:
- 'dev'
package:
- 'wakelock'
- 'wakelock_macos'
- 'wakelock_platform_interface'
# Web tests do not work for now.
# - 'wakelock_web'
Expand Down Expand Up @@ -92,10 +94,18 @@ jobs:
working-directory: ${{ matrix.package }}
- name: Run unit tests (chrome)
if: matrix.package == 'wakelock_web'
run: flutter test --platform chrome
run: |
flutter config --enable-web
flutter test --platform chrome
working-directory: ${{ matrix.package }}
- name: Integration tests on iOS
if: matrix.package == 'wakelock'
run: |
cd wakelock/example
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/wakelock_test.dart --no-sound-null-safety
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/wakelock_test.dart
- name: Integration tests on macOS
if: matrix.package == 'wakelock_macos' && matrix.channel == 'dev'
run: |
cd wakelock/example
flutter config --enable-macos-desktop
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/wakelock_test.dart -d macos
1 change: 1 addition & 0 deletions .github/workflows/pana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
matrix:
package:
- 'wakelock'
- 'wakelock_macos'
- 'wakelock_platform_interface'
- 'wakelock_web'
fail-fast: false
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
strategy:
matrix:
package:
# - 'wakelock'
# - 'wakelock_platform_interface'
- 'wakelock_web'
- 'wakelock'
- 'wakelock_macos'
- 'wakelock_platform_interface'
- 'wakelock_web'
fail-fast: false

steps:
Expand All @@ -35,6 +35,7 @@ jobs:
matrix:
package:
- 'wakelock'
- 'wakelock_macos'
- 'wakelock_platform_interface'
- 'wakelock_web'
fail-fast: false
Expand All @@ -52,19 +53,19 @@ jobs:
echo ::set-output name=changed::$?
set -e
- name: Extract package version
# if: steps.pubspec.outputs.changed == 0
if: steps.pubspec.outputs.changed == 0
run: |
cd ${{ matrix.package }}
echo "VERSION=$(awk '{if ($1 ~ /^version:/) print $2}' pubspec.yaml)" >> $GITHUB_ENV
- uses: sakebook/actions-flutter-pub-publisher@v1.3.1
# if: steps.pubspec.outputs.changed == 0
if: steps.pubspec.outputs.changed == 0
with:
package_directory: ${{ matrix.package }}
credential: ${{ secrets.PUB_CREDENTIALS }}
flutter_package: true
skip_test: true
- name: Create Release
# if: steps.pubspec.outputs.changed == 0
if: steps.pubspec.outputs.changed == 0
id: create_release
uses: actions/create-release@v1.1.4
env:
Expand Down
4 changes: 4 additions & 0 deletions wakelock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.0-nullsafety.0

* Added macOS support 🚀

## 0.3.0-nullsafety.3

* Add supported platforms to README.
Expand Down
4 changes: 2 additions & 2 deletions wakelock/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/wakelock/ios"

SPEC CHECKSUMS:
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
integration_test: 5ed24a436eb7ec17b6a13046e9bf7ca4a404e59e
wakelock: bfc7955c418d0db797614075aabbc58a39ab5107

PODFILE CHECKSUM: 8e679eca47255a8ca8067c4c67aab20e64cb974d

COCOAPODS: 1.9.3
COCOAPODS: 1.10.0
19 changes: 0 additions & 19 deletions wakelock/example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
FAD6D21B222DFE9FB43C310E /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -258,24 +257,6 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
FAD6D21B222DFE9FB43C310E /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../Flutter/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
2 changes: 1 addition & 1 deletion wakelock/example/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
wakelock_macos: d4628428650258e4b7bcb43458408b2a83385ea1
wakelock_macos: 493294b94b32c558d5ca409b3991a131c89c1970

PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

Expand Down
5 changes: 4 additions & 1 deletion wakelock/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ publish_to: 'none'
version: 1.0.0+1

environment:
sdk: '>=2.12.0-0 <3.0.0'
# Opt out of null safety on purpose because dependencies do not support sound null safety yet
# and flutter drive ignores the --no-sound-null-safety parameter.
# todo(creativecreatorormaybenot): switch to 2.12.0-0 lower bound.
sdk: '>=2.11.0 <3.0.0'

dependencies:
flutter:
Expand Down
4 changes: 2 additions & 2 deletions wakelock/ios/wakelock.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
Pod::Spec.new do |s|
s.name = 'wakelock'
s.version = '0.0.1'
s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web.'
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.'
s.description = <<-DESC
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web.
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
Expand Down
14 changes: 11 additions & 3 deletions wakelock/lib/wakelock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ import 'package:flutter/foundation.dart';
import 'package:wakelock_macos/wakelock_macos.dart';
import 'package:wakelock_platform_interface/wakelock_platform_interface.dart';

final _wakelockPlatformInstance = !kIsWeb &&
/// The [WakelockPlatformInterface] that is used by [Wakelock].
///
/// This needs to be exposed for testing as unit tests might run on macOS.
/// In that case, the "hacky" instance override that we use here would be
/// triggered for the unit tests, even though the unit tests should actually
/// test the `pigeon` method channel implementation. Therefore, we want to
/// override this in tests that run on macOS (where there is no actual device).
@visibleForTesting
var wakelockPlatformInstance = !kIsWeb &&
// Assigning the macOS platform instance like this is not optimal.
// Ideally, we would use the default method channel instance on macOS,
// however, it is not yet entirely clear how to integrate with pigeon.
Expand Down Expand Up @@ -66,7 +74,7 @@ class Wakelock {
static Future<void> toggle({
required bool enable,
}) {
return _wakelockPlatformInstance.toggle(enable: enable);
return wakelockPlatformInstance.toggle(enable: enable);
}

/// Returns whether the wakelock is currently enabled or not.
Expand All @@ -77,5 +85,5 @@ class Wakelock {
/// ```dart
/// bool wakelockEnabled = await Wakelock.enabled;
/// ```
static Future<bool> get enabled => _wakelockPlatformInstance.enabled;
static Future<bool> get enabled => wakelockPlatformInstance.enabled;
}
5 changes: 2 additions & 3 deletions wakelock/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: wakelock
description: >-2
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on
Android, iOS, and web.
version: 0.3.0-nullsafety.3
Android, iOS, macOS, and web.
version: 0.4.0-nullsafety.0
homepage: https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock

environment:
Expand All @@ -15,7 +15,6 @@ dependencies:

meta: ^1.2.0

# Include in a followup version when wakelock_macos has been published.
wakelock_macos: ^0.1.0-nullsafety.0
wakelock_platform_interface: ^0.2.0-nullsafety.2
wakelock_web: ^0.2.0-nullsafety.0
Expand Down
9 changes: 9 additions & 0 deletions wakelock/test/wakelock_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'dart:io';

import 'package:flutter_test/flutter_test.dart';
import 'package:wakelock/wakelock.dart';
import 'package:wakelock_platform_interface/messages.dart';
import 'package:wakelock_platform_interface/wakelock_platform_interface.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
Expand All @@ -9,6 +12,12 @@ void main() {
late FakeWakelockApi fakeWakelock;

setUpAll(() {
if (Platform.isMacOS) {
// See the member documentation for the reason behind this.
// todo(creativecreatorormaybenot): remove this once macOS is migrated
// todo| to pigeon.
wakelockPlatformInstance = WakelockPlatformInterface.instance;
}
fakeWakelock = FakeWakelockApi();
});

Expand Down
4 changes: 2 additions & 2 deletions wakelock_macos/macos/wakelock_macos.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
Pod::Spec.new do |s|
s.name = 'wakelock_macos'
s.version = '0.0.1'
s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web.'
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.'
s.description = <<-DESC
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web.
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.
DESC
s.homepage = 'https://github.com/creativecreatorormaybenot/wakelock/tree/master/packages/wakelock_macos'
s.license = { :type => 'BSD', :file => '../LICENSE' }
Expand Down
5 changes: 4 additions & 1 deletion wakelock_macos/test/wakelock_macos_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
Expand All @@ -12,4 +11,8 @@ void main() {
// example app.
// Consequently, the macOS implementation will be tested in CI via the
// example integration test running on -d macos.
test('stub', () {
final acceptUnitTestingDefeat = true;
expect(acceptUnitTestingDefeat, isTrue);
});
}

0 comments on commit 269fb74

Please sign in to comment.