Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2024-09-09 09:18:27 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
065ddf83f0c613dcf3656bfc238b625a93f15087
065ddf83
1 parent
603410ae
deprecate EncryptionType.none; fallback to EncryptionType.unknown for unrecognized values
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
9 deletions
lib/src/enums/encryption_type.dart
lib/src/objects/wifi.dart
test/enums/encryption_type_test.dart
lib/src/enums/encryption_type.dart
View file @
065ddf8
/// Wifi encryption type constants.
enum
EncryptionType
{
/// Unknown encryption type.
none
(
0
),
unknown
(
0
),
/// Not encrypted.
open
(
1
),
...
...
@@ -14,10 +14,13 @@ enum EncryptionType {
const
EncryptionType
(
this
.
rawValue
);
@Deprecated
(
'EncryptionType.none is deprecated. Use EncryptionType.unknown instead.'
)
static
const
EncryptionType
none
=
EncryptionType
.
unknown
;
factory
EncryptionType
.
fromRawValue
(
int
value
)
{
switch
(
value
)
{
case
0
:
return
EncryptionType
.
none
;
return
EncryptionType
.
unknown
;
case
1
:
return
EncryptionType
.
open
;
case
2
:
...
...
@@ -25,7 +28,7 @@ enum EncryptionType {
case
3
:
return
EncryptionType
.
wep
;
default
:
throw
ArgumentError
.
value
(
value
,
'value'
,
'Invalid raw value.'
)
;
return
EncryptionType
.
unknown
;
}
}
...
...
lib/src/objects/wifi.dart
View file @
065ddf8
...
...
@@ -5,7 +5,7 @@ import 'package:mobile_scanner/src/enums/encryption_type.dart';
class
WiFi
{
/// Construct a new [WiFi] instance.
const
WiFi
({
this
.
encryptionType
=
EncryptionType
.
none
,
this
.
encryptionType
=
EncryptionType
.
unknown
,
this
.
ssid
,
this
.
password
,
});
...
...
test/enums/encryption_type_test.dart
View file @
065ddf8
...
...
@@ -5,7 +5,7 @@ void main() {
group
(
'
$EncryptionType
tests'
,
()
{
test
(
'can be created from raw value'
,
()
{
const
values
=
<
int
,
EncryptionType
>{
0
:
EncryptionType
.
none
,
0
:
EncryptionType
.
unknown
,
1
:
EncryptionType
.
open
,
2
:
EncryptionType
.
wpa
,
3
:
EncryptionType
.
wep
,
...
...
@@ -18,20 +18,20 @@ void main() {
}
});
test
(
'invalid raw value
throws argument error
'
,
()
{
test
(
'invalid raw value
returns EncryptionType.unknown
'
,
()
{
const
int
negative
=
-
1
;
const
int
outOfRange
=
4
;
expect
(()
=>
EncryptionType
.
fromRawValue
(
negative
),
throwsArgumentError
);
expect
(()
=>
EncryptionType
.
fromRawValue
(
negative
),
EncryptionType
.
unknown
);
expect
(
()
=>
EncryptionType
.
fromRawValue
(
outOfRange
),
throwsArgumentError
,
EncryptionType
.
unknown
,
);
});
test
(
'can be converted to raw value'
,
()
{
const
values
=
<
EncryptionType
,
int
>{
EncryptionType
.
none
:
0
,
EncryptionType
.
unknown
:
0
,
EncryptionType
.
open
:
1
,
EncryptionType
.
wpa
:
2
,
EncryptionType
.
wep
:
3
,
...
...
Please
register
or
login
to post a comment