Eliminate unused matcher_util in flutter_driver (#13159)
Use of this file was eliminated in e7657b9462a8b2c3ed421b98ad68799799972248.
This commit is contained in:
parent
34ba6be93a
commit
d5cb9781e1
@ -1,82 +0,0 @@
|
||||
// Copyright 2016 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:matcher/matcher.dart';
|
||||
|
||||
/// Matches [value] against the [matcher].
|
||||
MatchResult match(dynamic value, Matcher matcher) {
|
||||
final Map<dynamic, dynamic> matchState = <dynamic, dynamic>{};
|
||||
if (matcher.matches(value, matchState)) {
|
||||
return new MatchResult._matched();
|
||||
} else {
|
||||
final Description description = matcher.describeMismatch(
|
||||
value, new _TextDescription(), matchState, false,
|
||||
);
|
||||
return new MatchResult._mismatched(description.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/// Result of matching a value against a matcher.
|
||||
class MatchResult {
|
||||
MatchResult._matched()
|
||||
: hasMatched = true,
|
||||
mismatchDescription = null;
|
||||
|
||||
MatchResult._mismatched(this.mismatchDescription)
|
||||
: hasMatched = false;
|
||||
|
||||
/// Whether the match succeeded.
|
||||
final bool hasMatched;
|
||||
|
||||
/// If the match did not succeed, this field contains the explanation.
|
||||
final String mismatchDescription;
|
||||
}
|
||||
|
||||
/// Writes description into a string.
|
||||
class _TextDescription implements Description {
|
||||
final StringBuffer _text = new StringBuffer();
|
||||
|
||||
@override
|
||||
int get length => _text.length;
|
||||
|
||||
@override
|
||||
Description add(String text) {
|
||||
_text.write(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
@override
|
||||
Description replace(String text) {
|
||||
_text.clear();
|
||||
_text.write(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
@override
|
||||
Description addDescriptionOf(dynamic value) {
|
||||
if (value is Matcher) {
|
||||
value.describe(this);
|
||||
return this;
|
||||
} else {
|
||||
return add('$value');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Description addAll(String start, String separator, String end, Iterable<dynamic> list) {
|
||||
add(start);
|
||||
if (list.isNotEmpty) {
|
||||
addDescriptionOf(list.first);
|
||||
for (dynamic item in list.skip(1)) {
|
||||
add(separator);
|
||||
addDescriptionOf(item);
|
||||
}
|
||||
}
|
||||
add(end);
|
||||
return this;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => '$_text';
|
||||
}
|
@ -10,7 +10,6 @@ environment:
|
||||
dependencies:
|
||||
file: 2.3.4
|
||||
json_rpc_2: 2.0.4
|
||||
matcher: 0.12.1+4
|
||||
meta: 1.1.1
|
||||
path: 1.4.2
|
||||
web_socket_channel: 1.0.6
|
||||
@ -40,6 +39,7 @@ dev_dependencies:
|
||||
intl: 0.15.2 # TRANSITIVE DEPENDENCY
|
||||
io: 0.3.0 # TRANSITIVE DEPENDENCY
|
||||
js: 0.6.1 # TRANSITIVE DEPENDENCY
|
||||
matcher: 0.12.1+4 # TRANSITIVE DEPENDENCY
|
||||
mime: 0.9.4 # TRANSITIVE DEPENDENCY
|
||||
node_preamble: 1.4.0 # TRANSITIVE DEPENDENCY
|
||||
package_config: 1.0.3 # TRANSITIVE DEPENDENCY
|
||||
|
@ -1,53 +0,0 @@
|
||||
// Copyright 2016 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:test/test.dart';
|
||||
import 'package:flutter_driver/src/matcher_util.dart';
|
||||
|
||||
void main() {
|
||||
group('match', () {
|
||||
test('matches', () {
|
||||
final _TestMatcher matcher = new _TestMatcher(1);
|
||||
final MatchResult ok = match(1, matcher);
|
||||
expect(ok.hasMatched, isTrue);
|
||||
expect(ok.mismatchDescription, isNull);
|
||||
expect(matcher.matchState1 is Map<dynamic, dynamic>, isTrue);
|
||||
expect(matcher.matchState2, isNull);
|
||||
});
|
||||
|
||||
test('mismatches', () {
|
||||
final _TestMatcher matcher = new _TestMatcher(2);
|
||||
final MatchResult fail = match(1, matcher);
|
||||
expect(fail.hasMatched, isFalse);
|
||||
expect(fail.mismatchDescription, 'mismatch!');
|
||||
expect(matcher.matchState1, matcher.matchState2);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class _TestMatcher extends Matcher {
|
||||
int expected;
|
||||
Map<dynamic, dynamic> matchState1;
|
||||
Map<dynamic, dynamic> matchState2;
|
||||
|
||||
_TestMatcher(this.expected);
|
||||
|
||||
@override
|
||||
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
|
||||
matchState1 = matchState;
|
||||
return item == expected;
|
||||
}
|
||||
|
||||
@override
|
||||
Description describeMismatch(dynamic item, Description mismatchDescription, Map<dynamic, dynamic> matchState, bool verbose) {
|
||||
matchState2 = matchState;
|
||||
mismatchDescription.add('mismatch!');
|
||||
return mismatchDescription;
|
||||
}
|
||||
|
||||
@override
|
||||
Description describe(Description description) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user