Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: pkg/analysis_server/test/mocks.dart

Issue 300023004: Partial implementation of the 'setAnalysisRoots' API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/mocks.dart
diff --git a/pkg/analysis_server/test/mocks.dart b/pkg/analysis_server/test/mocks.dart
index 2940115619166587ef346e0661790d39c600cc14..1d0082ceb999cfe4605c4b955cadb3129499e026 100644
--- a/pkg/analysis_server/test/mocks.dart
+++ b/pkg/analysis_server/test/mocks.dart
@@ -203,3 +203,85 @@ class MockAnalysisContext extends Mock implements AnalysisContext {
class MockSource extends Mock implements Source {
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
+
+
+/**
+ * A [Matcher] that check that the given [Response] has an expected identifier
+ * and no error.
+ */
+Matcher isResponseSuccess(String id) => new _IsResponseSuccess(id);
+
+/**
+ * A [Matcher] that check that there are no `error` in a given [Response].
+ */
+class _IsResponseSuccess extends Matcher {
+ final String _id;
+
+ _IsResponseSuccess(this._id);
+
+ @override
+ Description describe(Description description) {
+ return description.addDescriptionOf(
+ 'response with identifier "$_id" and without error');
+ }
+
+ @override
+ bool matches(item, Map matchState) {
+ Response response = item;
+ return response.id == _id && response.error == null;
+ }
+
+ @override
+ Description describeMismatch(item, Description mismatchDescription,
+ Map matchState, bool verbose) {
+ Response response = item;
+ var id = response.id;
+ RequestError error = response.error;
+ mismatchDescription.add('has identifier "$id"');
+ if (error != null) {
+ mismatchDescription.add(' and has error $error');
+ }
+ return mismatchDescription;
+ }
+}
+
+
+/**
+ * A [Matcher] that check that the given [Response] has an expected identifier
+ * and has an error.
+ */
+Matcher isResponseFailure(String id) => new _IsResponseFailure(id);
+
+/**
+ * A [Matcher] that check that there are no `error` in a given [Response].
+ */
+class _IsResponseFailure extends Matcher {
+ final String _id;
+
+ _IsResponseFailure(this._id);
+
+ @override
+ Description describe(Description description) {
+ return description.addDescriptionOf(
+ 'response with identifier "$_id" and an error');
+ }
+
+ @override
+ bool matches(item, Map matchState) {
+ Response response = item;
+ return response.id == _id && response.error != null;
+ }
+
+ @override
+ Description describeMismatch(item, Description mismatchDescription,
+ Map matchState, bool verbose) {
+ Response response = item;
+ var id = response.id;
+ RequestError error = response.error;
+ mismatchDescription.add('has identifier "$id"');
+ if (error == null) {
+ mismatchDescription.add(' and has no error');
+ }
+ return mismatchDescription;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698