Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7298f9ca
Unverified
Commit
7298f9ca
authored
Nov 10, 2017
by
Mikkel Nygaard Ravn
Committed by
GitHub
Nov 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose isMethodCall matcher in flutter_test (#12942)
parent
aefc62f8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
82 deletions
+66
-82
haptic_feedback_test.dart
packages/flutter/test/services/haptic_feedback_test.dart
+1
-3
message_codecs_utils.dart
packages/flutter/test/services/message_codecs_utils.dart
+0
-68
system_chrome_test.dart
packages/flutter/test/services/system_chrome_test.dart
+0
-2
system_navigator_test.dart
packages/flutter/test/services/system_navigator_test.dart
+1
-3
system_sound_test.dart
packages/flutter/test/services/system_sound_test.dart
+1
-3
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+0
-1
title_test.dart
packages/flutter/test/widgets/title_test.dart
+0
-2
matchers.dart
packages/flutter_test/lib/src/matchers.dart
+63
-0
No files found.
packages/flutter/test/services/haptic_feedback_test.dart
View file @
7298f9ca
...
...
@@ -3,9 +3,7 @@
// found in the LICENSE file.
import
'package:flutter/services.dart'
;
import
'package:test/test.dart'
;
import
'message_codecs_utils.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'Haptic feedback control test'
,
()
async
{
...
...
packages/flutter/test/services/message_codecs_utils.dart
deleted
100644 → 0
View file @
aefc62f8
// 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
'package:flutter/services.dart'
show
MethodCall
;
import
'package:meta/meta.dart'
;
import
'package:test/test.dart'
;
class
_IsMethodCall
extends
Matcher
{
const
_IsMethodCall
(
this
.
name
,
this
.
arguments
);
final
String
name
;
final
dynamic
arguments
;
@override
bool
matches
(
dynamic
item
,
Map
<
dynamic
,
dynamic
>
matchState
)
{
if
(
item
is
!
MethodCall
)
return
false
;
if
(
item
.
method
!=
name
)
return
false
;
return
_deepEquals
(
item
.
arguments
,
arguments
);
}
bool
_deepEquals
(
dynamic
a
,
dynamic
b
)
{
if
(
a
==
b
)
return
true
;
if
(
a
is
List
)
return
b
is
List
&&
_deepEqualsList
(
a
,
b
);
if
(
a
is
Map
)
return
b
is
Map
&&
_deepEqualsMap
(
a
,
b
);
return
false
;
}
bool
_deepEqualsList
(
List
<
dynamic
>
a
,
List
<
dynamic
>
b
)
{
if
(
a
.
length
!=
b
.
length
)
return
false
;
for
(
int
i
=
0
;
i
<
a
.
length
;
i
++)
{
if
(!
_deepEquals
(
a
[
i
],
b
[
i
]))
return
false
;
}
return
true
;
}
bool
_deepEqualsMap
(
Map
<
dynamic
,
dynamic
>
a
,
Map
<
dynamic
,
dynamic
>
b
)
{
if
(
a
.
length
!=
b
.
length
)
return
false
;
for
(
dynamic
key
in
a
.
keys
)
{
if
(!
b
.
containsKey
(
key
)
||
!
_deepEquals
(
a
[
key
],
b
[
key
]))
return
false
;
}
return
true
;
}
@override
Description
describe
(
Description
description
)
{
return
description
.
add
(
'has method name: '
).
addDescriptionOf
(
name
)
.
add
(
' with arguments: '
).
addDescriptionOf
(
arguments
);
}
}
/// Returns a matcher that matches [MethodCall] instances with the specified
/// method name and arguments.
///
/// Arguments checking implements deep equality for [List] and [Map] types.
Matcher
isMethodCall
(
String
name
,
{
@required
dynamic
arguments
})
{
return
new
_IsMethodCall
(
name
,
arguments
);
}
packages/flutter/test/services/system_chrome_test.dart
View file @
7298f9ca
...
...
@@ -7,8 +7,6 @@ import 'dart:typed_data';
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'message_codecs_utils.dart'
;
void
main
(
)
{
testWidgets
(
'SystemChrome overlay style test'
,
(
WidgetTester
tester
)
async
{
// The first call is a cache miss and will queue a microtask
...
...
packages/flutter/test/services/system_navigator_test.dart
View file @
7298f9ca
...
...
@@ -3,9 +3,7 @@
// found in the LICENSE file.
import
'package:flutter/services.dart'
;
import
'package:test/test.dart'
;
import
'message_codecs_utils.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'System navigator control test'
,
()
async
{
...
...
packages/flutter/test/services/system_sound_test.dart
View file @
7298f9ca
...
...
@@ -3,9 +3,7 @@
// found in the LICENSE file.
import
'package:flutter/services.dart'
;
import
'package:test/test.dart'
;
import
'message_codecs_utils.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'System sound control test'
,
()
async
{
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
7298f9ca
...
...
@@ -10,7 +10,6 @@ import 'package:flutter/material.dart';
import
'package:flutter/widgets.dart'
;
import
'package:flutter/services.dart'
;
import
'../services/message_codecs_utils.dart'
;
import
'semantics_tester.dart'
;
void
main
(
)
{
...
...
packages/flutter/test/widgets/title_test.dart
View file @
7298f9ca
...
...
@@ -6,8 +6,6 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:flutter/widgets.dart'
;
import
'package:flutter/services.dart'
;
import
'../services/message_codecs_utils.dart'
;
void
main
(
)
{
testWidgets
(
'toString control test'
,
(
WidgetTester
tester
)
async
{
final
Widget
widget
=
new
Title
(
...
...
packages/flutter_test/lib/src/matchers.dart
View file @
7298f9ca
...
...
@@ -5,6 +5,7 @@
import
'dart:math'
as
math
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:meta/meta.dart'
;
import
'package:test/test.dart'
;
...
...
@@ -216,6 +217,14 @@ Matcher equalsIgnoringHashCodes(String value) {
return
new
_EqualsIgnoringHashCodes
(
value
);
}
/// A matcher for [MethodCall]s, asserting that it has the specified
/// method [name] and [arguments].
///
/// Arguments checking implements deep equality for [List] and [Map] types.
Matcher
isMethodCall
(
String
name
,
{
@required
dynamic
arguments
})
{
return
new
_IsMethodCall
(
name
,
arguments
);
}
class
_FindsWidgetMatcher
extends
Matcher
{
const
_FindsWidgetMatcher
(
this
.
min
,
this
.
max
);
...
...
@@ -686,3 +695,57 @@ class _MoreOrLessEquals extends Matcher {
@override
Description
describe
(
Description
description
)
=>
description
.
add
(
'
$value
(±
$epsilon
)'
);
}
class
_IsMethodCall
extends
Matcher
{
const
_IsMethodCall
(
this
.
name
,
this
.
arguments
);
final
String
name
;
final
dynamic
arguments
;
@override
bool
matches
(
dynamic
item
,
Map
<
dynamic
,
dynamic
>
matchState
)
{
if
(
item
is
!
MethodCall
)
return
false
;
if
(
item
.
method
!=
name
)
return
false
;
return
_deepEquals
(
item
.
arguments
,
arguments
);
}
bool
_deepEquals
(
dynamic
a
,
dynamic
b
)
{
if
(
a
==
b
)
return
true
;
if
(
a
is
List
)
return
b
is
List
&&
_deepEqualsList
(
a
,
b
);
if
(
a
is
Map
)
return
b
is
Map
&&
_deepEqualsMap
(
a
,
b
);
return
false
;
}
bool
_deepEqualsList
(
List
<
dynamic
>
a
,
List
<
dynamic
>
b
)
{
if
(
a
.
length
!=
b
.
length
)
return
false
;
for
(
int
i
=
0
;
i
<
a
.
length
;
i
++)
{
if
(!
_deepEquals
(
a
[
i
],
b
[
i
]))
return
false
;
}
return
true
;
}
bool
_deepEqualsMap
(
Map
<
dynamic
,
dynamic
>
a
,
Map
<
dynamic
,
dynamic
>
b
)
{
if
(
a
.
length
!=
b
.
length
)
return
false
;
for
(
dynamic
key
in
a
.
keys
)
{
if
(!
b
.
containsKey
(
key
)
||
!
_deepEquals
(
a
[
key
],
b
[
key
]))
return
false
;
}
return
true
;
}
@override
Description
describe
(
Description
description
)
{
return
description
.
add
(
'has method name: '
).
addDescriptionOf
(
name
)
.
add
(
' with arguments: '
).
addDescriptionOf
(
arguments
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment