From d5cb9781e1754c94018fd0d188c4c0fab42fa05f Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Wed, 22 Nov 2017 15:15:37 -0800 Subject: [PATCH] Eliminate unused matcher_util in flutter_driver (#13159) Use of this file was eliminated in e7657b9462a8b2c3ed421b98ad68799799972248. --- .../flutter_driver/lib/src/matcher_util.dart | 82 ------------------- packages/flutter_driver/pubspec.yaml | 2 +- .../test/src/matcher_util_test.dart | 53 ------------ 3 files changed, 1 insertion(+), 136 deletions(-) delete mode 100644 packages/flutter_driver/lib/src/matcher_util.dart delete mode 100644 packages/flutter_driver/test/src/matcher_util_test.dart diff --git a/packages/flutter_driver/lib/src/matcher_util.dart b/packages/flutter_driver/lib/src/matcher_util.dart deleted file mode 100644 index 5632f6741a..0000000000 --- a/packages/flutter_driver/lib/src/matcher_util.dart +++ /dev/null @@ -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 matchState = {}; - 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 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'; -} diff --git a/packages/flutter_driver/pubspec.yaml b/packages/flutter_driver/pubspec.yaml index ef2a1a1a3b..97068d7bfd 100644 --- a/packages/flutter_driver/pubspec.yaml +++ b/packages/flutter_driver/pubspec.yaml @@ -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 diff --git a/packages/flutter_driver/test/src/matcher_util_test.dart b/packages/flutter_driver/test/src/matcher_util_test.dart deleted file mode 100644 index 04fb1e2612..0000000000 --- a/packages/flutter_driver/test/src/matcher_util_test.dart +++ /dev/null @@ -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, 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 matchState1; - Map matchState2; - - _TestMatcher(this.expected); - - @override - bool matches(dynamic item, Map matchState) { - matchState1 = matchState; - return item == expected; - } - - @override - Description describeMismatch(dynamic item, Description mismatchDescription, Map matchState, bool verbose) { - matchState2 = matchState; - mismatchDescription.add('mismatch!'); - return mismatchDescription; - } - - @override - Description describe(Description description) { - throw 'not implemented'; - } -}