Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for scanning for mock devices using ScanSettings and Scan… #703

Merged
merged 26 commits into from Jul 28, 2020

Conversation

nrbrook
Copy link
Contributor

@nrbrook nrbrook commented Jul 21, 2020

…Filter(s)

Added implementation and unit tests

@CLAassistant
Copy link

CLAassistant commented Jul 21, 2020

CLA assistant check
All committers have signed the CLA.

@dariuszseweryn
Copy link
Owner

Hello,
This PR looks awesome. I will look into the code in a moment.
There are some checkstyle rule violations could you address them?

Copy link
Owner

@dariuszseweryn dariuszseweryn left a comment

Choose a reason for hiding this comment

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

Some comments for discussion

return bb.array();
}

private static boolean filterDevice(RxBleDevice rxBleDevice, ScanFilter... scanFilters) {
Copy link
Owner

Choose a reason for hiding this comment

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

I am not sure why it is RxBleDevice here where it is clearly meant for RxBleDeviceMock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Me neither...copied from the original method private static boolean filterDevice(RxBleDevice rxBleDevice, @Nullable UUID[] filterServiceUUIDs) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do I need to change this? I don't think it matters really.

@nrbrook nrbrook mentioned this pull request Jul 24, 2020
@nrbrook
Copy link
Contributor Author

nrbrook commented Jul 24, 2020

PR #706 is based on this PR and would be preferred instead of this PR to avoid creating new APIs that are later deprecated, although if both are merged between releases it wouldn't really matter.

Copy link
Owner

@dariuszseweryn dariuszseweryn left a comment

Choose a reason for hiding this comment

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

I thought I have posted this review before the weekend but it turned out I didn't :/

To not be overwhelmed by stacked changes I would like to merge your PRs sequentially starting with this one and proceeding with next.

@nrbrook
Copy link
Contributor Author

nrbrook commented Jul 27, 2020

To not be overwhelmed by stacked changes I would like to merge your PRs sequentially starting with this one and proceeding with next.

This PR is merged into #706, and that is merged into #707 already

@dariuszseweryn
Copy link
Owner

To not be overwhelmed by stacked changes I would like to merge your PRs sequentially starting with this one and proceeding with next.

This PR is merged into #706, and that is merged into #707 already

I know, unfortunately partial code reviews are not currying and I would like to first merge this one before starting review of the next — this way #706 will show only differences with master (now it is showing both this and next changes)

@nrbrook
Copy link
Contributor Author

nrbrook commented Jul 27, 2020

Oh sorry yes that's fine – I misread your comment and thought you wanted me to do some merging. I was only concerned about having to maintain deprecated constructors if releases were made between PRs.

Copy link
Contributor Author

@nrbrook nrbrook left a comment

Choose a reason for hiding this comment

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

Like this? eb7d009

@dariuszseweryn
Copy link
Owner

Like this? eb7d009

Also move the implements ScanResultInterface from ScanResult onto RxBleScanResultMock.java

@dariuszseweryn
Copy link
Owner

ScanFilter.matches uses the interface to accept ScanResult and RxBleInternalScanResult objects

Correct. If you would move the interface from ScanResult to RxBleScanResultMock then ScanFilter.matches would accept RxBleScanResultMock and RxBleInternalScanResult which would be convenient and would not change ScanResult API at all :) Or am I wrong?

@nrbrook
Copy link
Contributor Author

nrbrook commented Jul 27, 2020

ScanFilter.matches uses the interface to accept ScanResult and RxBleInternalScanResult objects

Correct. If you would move the interface from ScanResult to RxBleScanResultMock then ScanFilter.matches would accept RxBleScanResultMock and RxBleInternalScanResult which would be convenient and would not change ScanResult API at all :) Or am I wrong?

Got it, see latest commit. Got confused for a minute there!

Copy link
Owner

@dariuszseweryn dariuszseweryn left a comment

Choose a reason for hiding this comment

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

Almost there :)

Copy link
Owner

@dariuszseweryn dariuszseweryn left a comment

Choose a reason for hiding this comment

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

Awesome 👍 🚀


class ScanFilterTest extends Specification {
@Config(manifest = Config.NONE, constants = BuildConfig, sdk = Build.VERSION_CODES.LOLLIPOP)
public class ScanFilterTest extends ElectricSpecification {
Copy link
Owner

Choose a reason for hiding this comment

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

Yeah. I totally forgot about it. 👍

@dariuszseweryn dariuszseweryn merged commit da9692e into dariuszseweryn:master Jul 28, 2020
@rfrowe
Copy link

rfrowe commented Mar 3, 2021

I'd love to have this for my unit tests. However, there hasn't been a release in nearly a year. Is another planned soon?

@nrbrook
Copy link
Contributor Author

nrbrook commented Mar 3, 2021

@rfrowe It seems Polidea was bought out - I’m trying to reach out to Dariusz to see what’s happening and if he’ll continue maintaining it. If not I’ll look at maintaining and releasing a fork as we need this to work for commercial projects.

@rfrowe
Copy link

rfrowe commented Mar 3, 2021

@nrbrook oof did this happen quite recently? I figured this project was still active when I chose to use it, since the last commit was in January. For now, I set Gradle to install this library from git via JitPack so I can use this change, but if you do end up forking and releasing to Maven, let me know :)

@nrbrook
Copy link
Contributor Author

nrbrook commented Mar 3, 2021

Nice I didn’t know you could do that via jitpack. Acquired February 8th according to linked in.

@rfrowe
Copy link

rfrowe commented Mar 3, 2021

@nrbrook if you're interested:

testImplementation "com.github.Polidea.RxAndroidBle:rxandroidble:$rx_android_ble_version"
testImplementation "com.github.Polidea.RxAndroidBle:mockclient:$rx_android_ble_version"

where rx_android_ble_version is master-SNAPSHOT and you must have:

repositories {
    maven { url 'https://jitpack.io' }
}

@dariuszseweryn
Copy link
Owner

There is now a 1.12.0-SNAPSHOT release available (see readme for snapshots)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants