Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[quick_actions]refactor into smaller components and 100% unit test coverage#6212

Merged
auto-submit[bot] merged 5 commits intoflutter:mainfrom
hellohuanlin:quick_actions_refactor_with_100_coverage
Aug 10, 2022
Merged

[quick_actions]refactor into smaller components and 100% unit test coverage#6212
auto-submit[bot] merged 5 commits intoflutter:mainfrom
hellohuanlin:quick_actions_refactor_with_100_coverage

Conversation

@hellohuanlin
Copy link
Contributor

@hellohuanlin hellohuanlin commented Aug 5, 2022

  • Refactor shortcut related logics into a separate FLTShortcutStateManager which manages a list of all shortcut items. The FLTQuickActionsPlugin class does not directly depend on [UIApplication sharedApplication].shortcutItems anymore.
  • Also do not expose the launchingShortcutType.

This refactor allows us to reach 100% unit test coverage without exposing private APIs.

Screen Shot 2022-08-05 at 4 01 42 PM

List which issues are fixed by this PR. You must list at least one issue.

flutter/flutter#108750

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@hellohuanlin hellohuanlin force-pushed the quick_actions_refactor_with_100_coverage branch 2 times, most recently from 1866b73 to 0d7592a Compare August 5, 2022 23:08

@implementation FLTShortcutStateManager

- (void)setShortcutItems:(NSArray *)items {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these 2 functions are directly moved from FLTQuickActionsPlugin.m file.

@hellohuanlin hellohuanlin force-pushed the quick_actions_refactor_with_100_coverage branch from 0d7592a to d14a56b Compare August 5, 2022 23:13
@hellohuanlin hellohuanlin marked this pull request as ready for review August 5, 2022 23:14
@hellohuanlin hellohuanlin force-pushed the quick_actions_refactor_with_100_coverage branch from d14a56b to 79adeca Compare August 5, 2022 23:15
@hellohuanlin hellohuanlin changed the title [quick_actions]refactor plugin into smaller components and 100% unit test coverage [quick_actions]refactor into smaller components and 100% unit test coverage Aug 5, 2022
@hellohuanlin hellohuanlin force-pushed the quick_actions_refactor_with_100_coverage branch from a73edd9 to 317b356 Compare August 6, 2022 18:54
@hellohuanlin hellohuanlin requested a review from jmagman August 8, 2022 22:36
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

LGTM with nit about fixtures files.
@stuartmorgan do you think this is worth a version bump?

// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "Fixtures.h"
Copy link
Member

Choose a reason for hiding this comment

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

Instead of making a class for this can you just instantiate them in the tests that need them? I would rather it be repeated than to need to swap between files to see the expected and actual results. And I definitely don't care if it's repeated between test files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To clarify, there are 3 options here:

  1. put these data under a separate fixtures file (to be reused by all)
  2. put these data as helpers in each test file (to be reused by tests within the test file)
  3. put these data inside each test function (no reuse)

Are you referring to option 2 or 3?

I don't have a strong preference here (art, not science).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

^ feel free to chime in @cyanglaz and @stuartmorgan. Let's decide on a convention and use it onwards.

Copy link
Member

Choose a reason for hiding this comment

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

I was referring to 2 but if I were writing these myself I would do 3. Art not science, as you say. I don't have a preference, I just think they should be in the same file to avoid

“OK, this is a FrobberTest, where’s that defined … oh, this file. Great.”

but when expectations fail to be able to easily see what the actual vs expectation is.

Copy link
Contributor

Choose a reason for hiding this comment

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

Personal opinion. What I usually do is asking myself: "Does having the result inline break the readability of the test? ". For example, if the result of the test is a huge json (e.g. 100+lines) and there are a lot of these jsons, i would put the jsons in a different file; if the result is about 5 lines, i would put them inline or in the same file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will put them inside each function then

@hellohuanlin hellohuanlin added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 10, 2022
@hellohuanlin hellohuanlin force-pushed the quick_actions_refactor_with_100_coverage branch from 8ed7a12 to 9bc4b46 Compare August 10, 2022 17:42
@auto-submit auto-submit bot merged commit 00e73a4 into flutter:main Aug 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 11, 2022
yutaaraki-toydium pushed a commit to yutaaraki-toydium/plugins that referenced this pull request Aug 12, 2022
moisefeelin pushed a commit to feelinproject/plugins that referenced this pull request Aug 26, 2022
mauricioluz pushed a commit to mauricioluz/plugins that referenced this pull request Jan 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App p: quick_actions platform-ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants