Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/quick_actions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
## 0.3.4

* Add missing documentation. Some of the public methods should have been
annotated as `@visibleForTesting` previously and were not, so the annotations
have been added now.

## 0.3.3+1

* Update and migrate iOS example project by removing flutter_assets, change
* Update and migrate iOS example project by removing flutter_assets, change
"English" to "en", remove extraneous xcconfigs, update to Xcode 11 build
settings, and remove ARCHS and DEVELOPMENT_TEAM.

Expand Down
11 changes: 0 additions & 11 deletions packages/quick_actions/analysis_options.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions packages/quick_actions/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: public_member_api_docs

import 'package:flutter/material.dart';
import 'package:quick_actions/quick_actions.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
final String result =
await driver.requestData(null, timeout: const Duration(minutes: 1));
driver.close();
await driver.close();
exit(result == 'pass' ? 0 : 1);
}
16 changes: 16 additions & 0 deletions packages/quick_actions/lib/quick_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ typedef void QuickActionHandler(String type);

/// Home screen quick-action shortcut item.
class ShortcutItem {
/// Constructs an instance with the given [type], [localizedTitle], and
/// [icon].
///
/// Only [icon] should be nullable. It will remain `null` if unset.
const ShortcutItem({
@required this.type,
@required this.localizedTitle,
Expand All @@ -36,14 +40,21 @@ class ShortcutItem {

/// Quick actions plugin.
class QuickActions {
/// Gets an instance of the plugin with the default methodChannel.
///
/// [initialize] should be called before using any other methods.
factory QuickActions() => _instance;

/// This is a test-only constructor. Do not call this, it can break at any
/// time.
@visibleForTesting
QuickActions.withMethodChannel(this.channel);

static final QuickActions _instance =
QuickActions.withMethodChannel(_kChannel);

/// This is a test-only accessor. Do not call this, it can break at any time.
@visibleForTesting
final MethodChannel channel;

/// Initializes this plugin.
Expand All @@ -54,9 +65,14 @@ class QuickActions {
assert(call.method == 'launch');
handler(call.arguments);
});
// ignore: deprecated_member_use_from_same_package
runLaunchAction(handler);
}

/// This is only exposed for the unit tests. Do not rely on it, it may break
/// without warning in the future.
@visibleForTesting
@deprecated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@collinjackson @diesersamat as far as I can tell this method isn't intended to be part of the public API, but I'm not sure if I'm misunderstanding the original intent here. From what I could tell reading through the codebase this looks like it's purely a helper method for intialize, and users of the plugin are never expected to call this on its own. I think it was originally added to help with testing. If my reading is wrong, what's the intended use case of this and calling getLaunchAction outside of initialize? It was added in #1800. if that helps.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're making a breaking change anyway (removing channel) and this is a pre-1.0 plugin I think that we can probably skip the deprecated step and just remove this from the public API.

void runLaunchAction(QuickActionHandler handler) async {
final String action = await channel.invokeMethod<String>('getLaunchAction');
if (action != null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/quick_actions/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for creating shortcuts on home screen, also known as
Quick Actions on iOS and App Shortcuts on Android.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/quick_actions
version: 0.3.3+1
version: 0.3.4
Comment thread
mklim marked this conversation as resolved.
Outdated

flutter:
plugin:
Expand Down
24 changes: 21 additions & 3 deletions packages/quick_actions/test/quick_actions_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:quick_actions/quick_actions.dart';
Expand All @@ -16,7 +18,7 @@ void main() {
quickActions.channel.setMockMethodCallHandler(
(MethodCall methodCall) async {
log.add(methodCall);
return null;
return 'non empty response';
},
);
});
Expand Down Expand Up @@ -59,14 +61,30 @@ void main() {
log.clear();
});

test('runLaunchAction', () {
quickActions.runLaunchAction(null);
test('initialize', () async {
final Completer<bool> quickActionsHandler = Completer<bool>();
quickActions.initialize((String _) => quickActionsHandler.complete(true));
Comment thread
mklim marked this conversation as resolved.
Outdated
expect(
log,
<Matcher>[
isMethodCall('getLaunchAction', arguments: null),
],
);
log.clear();

await expectLater(await quickActionsHandler.future, isTrue);
Comment thread
mklim marked this conversation as resolved.
Outdated
});

test('Shortcut item can be constructed', () {
const String type = 'type';
const String localizedTitle = 'title';
const String icon = 'foo';

const ShortcutItem item =
ShortcutItem(type: type, localizedTitle: localizedTitle, icon: icon);

expect(item.type, type);
expect(item.localizedTitle, localizedTitle);
expect(item.icon, icon);
});
}