Skip to content

Commit

Permalink
Release 2.2.4 (#459)
Browse files Browse the repository at this point in the history
* Fix capitalization style for UUID and constant names (#437)

* Fix capitalization of UUID in Service

* Fix capitalization of UUID in ScanResult

* Fix capitalization of UUID in Peripheral

* Rename bytes to value

* Fix capitalization of UUID in metadata strings in ScanResult

* Fix constants capitalization in BleError

* Revert "Fix capitalization of UUID in metadata strings in ScanResult"

This reverts commit 08516ec.

* Fix capitalization of UUID in managers for classes

* Fix capitalization of UUID for InternalBleManager

* Fix capitalization of UUID in CharacteristicsMixin

* Fix capitalization of UUID in DevicesMixin

* Rename bytes to value in internal classes

* Add unit tests for Service (#439)

* unit test for BleManager

* [descriptor] override equals & hashcode functions

* [tests] add: mock classes for managers

* [service] add: service tests

* [tests] create characteristics and descriptors using separate generators

* [service][tests] cover generating transactionId when it's not specified

* [service][tests] clear mocks interactions after each test

* [service][tests] add missing test for getting all descriptors for specified characteristic

Co-authored-by: Paweł Byszewski <[email protected]>

* Descriptor unit tests (#441)

* unit test for BleManager

* [descriptor] override equals & hashcode functions

* [tests] add: mock classes for managers

* [tests] create characteristics and descriptors using separate generators

* [descriptor] add: tests

* [descriptor] fix: test names

* [tests] move all mocks declarations to one aggregate file

* [ble-manager][test] add matcher to always check objects' references

* [descriptor][test] add tests that check uniquity of transactionId

Co-authored-by: pawelByszewski <[email protected]>

* [iOS] Fixed casting of Bool arguments received from dart (#451)

* Remove root level `Flutter User Facing API.dart` (#455) 

* rename root level file

naming interfered with certain build_runner code generators

* remove flutter_user_facing_api.dart

* Release 2.2.4

Co-authored-by: Łukasz Rejman <[email protected]>
Co-authored-by: Bartosz Wilk <[email protected]>
Co-authored-by: Paweł Byszewski <[email protected]>
Co-authored-by: pawelByszewski <[email protected]>
Co-authored-by: Tomasz Bogusz <[email protected]>
Co-authored-by: Dustin Graham <[email protected]>
  • Loading branch information
7 people authored May 7, 2020
1 parent 47d12e1 commit 7d55135
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 116 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.2.4

* Fix issue where `withResponse` argument was always true when writing to a characteristic on iOS
* Remove unnecessary file that was interfering with analyzer

## 2.2.3

* Fix issue with duplicated or malformed notification values
Expand Down
100 changes: 0 additions & 100 deletions Flutter User Facing API.dart

This file was deleted.

2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.polidea.flutter_ble_lib'
version '2.2.3'
version '2.2.4'

buildscript {
repositories {
Expand Down
8 changes: 4 additions & 4 deletions ios/Classes/FlutterBleLibPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ - (void)isDeviceConnected:(FlutterMethodCall *)call result:(FlutterResult)result
}

- (void)observeConnectionState:(FlutterMethodCall *)call result:(FlutterResult)result {
BOOL emitCurrentValue = (BOOL)call.arguments[ARGUMENT_KEY_EMIT_CURRENT_VALUE];
BOOL emitCurrentValue = ((NSNumber *)call.arguments[ARGUMENT_KEY_EMIT_CURRENT_VALUE]).boolValue;
if (emitCurrentValue == YES) {
Resolve resolve = ^(id isConnected) {
if ((BOOL)isConnected == YES) {
Expand Down Expand Up @@ -343,7 +343,7 @@ - (void)writeCharacteristicForDevice:(FlutterMethodCall *)call result:(FlutterRe
serviceUUID:call.arguments[ARGUMENT_KEY_SERVICE_UUID]
characteristicUUID:call.arguments[ARGUMENT_KEY_CHARACTERISTIC_UUID]
valueBase64:[self base64encodedStringFromBytes:call.arguments[ARGUMENT_KEY_VALUE]]
response:(BOOL)call.arguments[ARGUMENT_KEY_WITH_RESPONSE]
response:((NSNumber *)call.arguments[ARGUMENT_KEY_WITH_RESPONSE]).boolValue
transactionId:[ArgumentHandler stringOrNil:call.arguments[ARGUMENT_KEY_TRANSACTION_ID]]
resolve:[self resolveForReadWriteCharacteristic:result
transactionId:[ArgumentHandler stringOrNil:call.arguments[ARGUMENT_KEY_TRANSACTION_ID]]]
Expand All @@ -354,7 +354,7 @@ - (void)writeCharacteristicForService:(FlutterMethodCall *)call result:(FlutterR
[_adapter writeCharacteristicForService:[call.arguments[ARGUMENT_KEY_SERVICE_ID] doubleValue]
characteristicUUID:call.arguments[ARGUMENT_KEY_CHARACTERISTIC_UUID]
valueBase64:[self base64encodedStringFromBytes:call.arguments[ARGUMENT_KEY_VALUE]]
response:(BOOL)call.arguments[ARGUMENT_KEY_WITH_RESPONSE]
response:((NSNumber *)call.arguments[ARGUMENT_KEY_WITH_RESPONSE]).boolValue
transactionId:[ArgumentHandler stringOrNil:call.arguments[ARGUMENT_KEY_TRANSACTION_ID]]
resolve:[self resolveForReadWriteCharacteristic:result
transactionId:[ArgumentHandler stringOrNil:call.arguments[ARGUMENT_KEY_TRANSACTION_ID]]]
Expand All @@ -364,7 +364,7 @@ - (void)writeCharacteristicForService:(FlutterMethodCall *)call result:(FlutterR
- (void)writeCharacteristic:(FlutterMethodCall *)call result:(FlutterResult)result {
[_adapter writeCharacteristic:[call.arguments[ARGUMENT_KEY_CHARACTERISTIC_IDENTIFIER] doubleValue]
valueBase64:[self base64encodedStringFromBytes:call.arguments[ARGUMENT_KEY_VALUE]]
response:(BOOL)call.arguments[ARGUMENT_KEY_WITH_RESPONSE]
response:((NSNumber *)call.arguments[ARGUMENT_KEY_WITH_RESPONSE]).boolValue
transactionId:[ArgumentHandler stringOrNil:call.arguments[ARGUMENT_KEY_TRANSACTION_ID]]
resolve:[self resolveForReadWriteCharacteristic:result
transactionId:[ArgumentHandler stringOrNil:call.arguments[ARGUMENT_KEY_TRANSACTION_ID]]]
Expand Down
4 changes: 2 additions & 2 deletions ios/flutter_ble_lib.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'flutter_ble_lib'
s.version = '2.2.3'
s.version = '2.2.4'
s.summary = 'A new flutter plugin project.'
s.description = <<-DESC
A new flutter plugin project.
Expand All @@ -16,7 +16,7 @@ A new flutter plugin project.
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.swift_versions = ['4.0', '4.2', '5.0']
s.dependency 'MultiplatformBleAdapter', '0.1.5'
s.dependency 'MultiplatformBleAdapter', '~> 0.1.5'

s.ios.deployment_target = '8.0'
end
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_ble_lib
description: FlutterBle Library is a flutter library that supports BLE operations. It uses MultiPlatformBleAdapter as a native backend..
version: 2.2.3
version: 2.2.4
author: "Polidea <[email protected]>"
homepage: https://github.com/Polidea/FlutterBleLib

Expand Down
2 changes: 1 addition & 1 deletion test/ble_manager_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ void main() {
final secondInstanceOfBleManager = BleManager();

//then
expect(secondInstanceOfBleManager, firstInstanceOfBlemanager);
expect(secondInstanceOfBleManager, same(firstInstanceOfBlemanager));
});
}
118 changes: 118 additions & 0 deletions test/descriptor_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import 'dart:async';
import 'dart:typed_data';

import 'package:flutter_ble_lib/flutter_ble_lib.dart';
import 'package:flutter_ble_lib/src/_managers_for_classes.dart';
import 'package:mockito/mockito.dart';
import 'package:test/test.dart';

import 'mock/mocks.dart';
import 'test_util/descriptor_generator.dart';

void main() {
ManagerForDescriptor managerForDescriptor = ManagerForDescriptorMock();
DescriptorGenerator descriptorGenerator =
DescriptorGenerator(managerForDescriptor);

DescriptorWithValue createDescriptor(int seed) =>
descriptorGenerator.create(seed, CharacteristicMock());

Descriptor descriptor = createDescriptor(123);

tearDown(() {
clearInteractions(managerForDescriptor);
});

test("read returns expected value", () async {
//given
when(managerForDescriptor.readDescriptorForIdentifier(descriptor, "456"))
.thenAnswer((_) => Future.value(Uint8List.fromList([1, 2, 3, 4])));

//when
var value = await descriptor.read(transactionId: "456");

//then
expect(value, equals(Uint8List.fromList([1, 2, 3, 4])));
});

test(
"read invokes manager with expected params when transactionId is specified",
() {
//when
descriptor.read(transactionId: "456");

//then
verify(
managerForDescriptor.readDescriptorForIdentifier(descriptor, "456"),
);
});

test(
"read invokes manager with expected params when transactionId is not specified",
() {
//when
descriptor.read();

//then
verify(
managerForDescriptor.readDescriptorForIdentifier(
descriptor, argThat(isNotNull)),
);
});

test(
"read invokes manager with unique transactionId when transactionId is not specified",
() {
//when
descriptor.read();
descriptor.read();

//then
var transactionIds = verify(
managerForDescriptor.readDescriptorForIdentifier(
descriptor, captureThat(isNotNull)),
).captured;
expect(transactionIds[0], isNot(equals(transactionIds[1])));
});

test(
"write invokes manager with expected params when transactionId is specified",
() {
//when
descriptor.write(Uint8List.fromList([1, 2, 3, 4]), transactionId: "456");

//then
verify(
managerForDescriptor.writeDescriptorForIdentifier(
descriptor, Uint8List.fromList([1, 2, 3, 4]), "456"),
);
});

test(
"write invokes manager with expected params when transactionId is not specified",
() {
//when
descriptor.write(Uint8List.fromList([1, 2, 3, 4]));

//then
verify(
managerForDescriptor.writeDescriptorForIdentifier(
descriptor, Uint8List.fromList([1, 2, 3, 4]), argThat(isNotNull)),
);
});

test(
"write invokes manager with unique transactionId when transactionId is not specified",
() {
//when
descriptor.write(Uint8List.fromList([1, 2, 3, 4]));
descriptor.write(Uint8List.fromList([1, 2, 3, 4]));

//then
var transactionIds = verify(
managerForDescriptor.writeDescriptorForIdentifier(descriptor,
Uint8List.fromList([1, 2, 3, 4]), captureThat(isNotNull)))
.captured;
expect(transactionIds[0], isNot(equals(transactionIds[1])));
});
}
4 changes: 0 additions & 4 deletions test/mock/mock_peripheral.dart

This file was deleted.

7 changes: 7 additions & 0 deletions test/mock/manager_mock.dart → test/mock/mocks.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter_ble_lib/flutter_ble_lib.dart';
import 'package:flutter_ble_lib/src/_managers_for_classes.dart';
import 'package:mockito/mockito.dart';

Expand All @@ -6,3 +7,9 @@ class ManagerForServiceMock extends Mock implements ManagerForService {}
class ManagerForCharacteristicMock extends Mock implements ManagerForCharacteristic {}

class ManagerForDescriptorMock extends Mock implements ManagerForDescriptor {}

class ServiceMock extends Mock implements Service {}

class PeripheralMock extends Mock implements Peripheral {}

class CharacteristicMock extends Mock implements Characteristic {}
3 changes: 1 addition & 2 deletions test/service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import 'package:flutter_ble_lib/src/_managers_for_classes.dart';
import 'package:mockito/mockito.dart';
import 'package:test/test.dart';

import 'mock/manager_mock.dart';
import 'mock/mock_peripheral.dart';
import 'mock/mocks.dart';
import 'test_util/characteristic_generator.dart';
import 'test_util/descriptor_generator.dart';

Expand Down
2 changes: 1 addition & 1 deletion test/src/bridge/lib_core_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import 'package:flutter_ble_lib/src/_constants.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';

import '../../mock/mock_peripheral.dart';
import '../../json/ble_error_jsons.dart';
import '../../mock/mocks.dart';

const flutterBleLibMethodChannelName = 'flutter_ble_lib';
const monitorCharacteristicEventChannelName =
Expand Down

0 comments on commit 7d55135

Please sign in to comment.