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

Unified Diff: pkg/analysis_server/test/integration/integration_tests.dart

Issue 405473006: Three new analysis server integration tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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/integration/integration_tests.dart
diff --git a/pkg/analysis_server/test/integration/integration_tests.dart b/pkg/analysis_server/test/integration/integration_tests.dart
index 554a42973be43c987b0dafccde521f904847c9e9..cdc5d1b2fb17545b21e7692e0b4598ca33a1fc4b 100644
--- a/pkg/analysis_server/test/integration/integration_tests.dart
+++ b/pkg/analysis_server/test/integration/integration_tests.dart
@@ -142,11 +142,8 @@ abstract class AbstractAnalysisServerIntegrationTest {
// ==========================================================
// TODO(paulberry): add more matchers.
-const Matcher isString = const isInstanceOf<String>('String');
-
-const Matcher isInt = const isInstanceOf<int>('int');
-
-const Matcher isBool = const isInstanceOf<bool>('bool');
+// Matchers common to all domains
+// ------------------------------
const Matcher isResultResponse = const MatchesJsonObject('result response',
const {
@@ -180,29 +177,37 @@ const Matcher isNotification = const MatchesJsonObject('notification', const {
'params': isMap
});
+// Matchers for specific responses and notifications
+// -------------------------------------------------
+
+// server.getVersion
const Matcher isServerGetVersionResult = const MatchesJsonObject(
'server.getVersion result', const {
'version': isString
});
+// server.status
const Matcher isServerStatusParams = const MatchesJsonObject(
'server.status params', null, optionalFields: const {
'analysis': isAnalysisStatus
});
-final Matcher isErrorSeverity = isIn(['INFO', 'WARNING', 'ERROR']);
+// analysis.getHover
+final Matcher isAnalysisGetHoverResult = new MatchesJsonObject(
+ 'analysis.getHover result', {
+ 'hovers': isListOf(isHoverInformation)
+});
-final Matcher isErrorType = isIn(['COMPILE_TIME_ERROR', 'HINT',
- 'STATIC_TYPE_WARNING', 'STATIC_WARNING', 'SYNTACTIC_ERROR', 'TODO']);
+// Matchers for data types used in responses and notifications
+// -----------------------------------------------------------
-const Matcher isLocation = const MatchesJsonObject('Location', const {
- 'file': isString,
- 'offset': isInt,
- 'length': isInt,
- 'startLine': isInt,
- 'startColumn': isInt
-});
+const Matcher isString = const isInstanceOf<String>('String');
+
+const Matcher isInt = const isInstanceOf<int>('int');
+
+const Matcher isBool = const isInstanceOf<bool>('bool');
+// AnalysisError
final Matcher isAnalysisError = new MatchesJsonObject('AnalysisError', {
'severity': isErrorSeverity,
'type': isErrorType,
@@ -212,6 +217,7 @@ final Matcher isAnalysisError = new MatchesJsonObject('AnalysisError', {
'correction': isString
});
+// AnalysisStatus
const Matcher isAnalysisStatus = const MatchesJsonObject('AnalysisStatus', const
{
'analyzing': isBool
@@ -219,6 +225,38 @@ const Matcher isAnalysisStatus = const MatchesJsonObject('AnalysisStatus', const
'analysisTarget': isString
});
+// ErrorSeverity
+final Matcher isErrorSeverity = isIn(['INFO', 'WARNING', 'ERROR']);
+
+// ErrorType
+final Matcher isErrorType = isIn(['COMPILE_TIME_ERROR', 'HINT',
+ 'STATIC_TYPE_WARNING', 'STATIC_WARNING', 'SYNTACTIC_ERROR', 'TODO']);
+
+// HoverInformation
+const Matcher isHoverInformation = const MatchesJsonObject('HoverInformation',
+ const {
+ 'offset': isInt,
+ 'length': isInt
+}, optionalFields: const {
+ 'containingLibraryPath': isString,
+ 'containingLibraryName': isString,
+ 'dartdoc': isString,
+ 'elementDescription': isString,
+ 'elementKind': isString,
+ 'parameter': isString,
+ 'propagatedType': isString,
+ 'staticType': isString
+});
+
+// Location
+const Matcher isLocation = const MatchesJsonObject('Location', const {
+ 'file': isString,
+ 'offset': isInt,
+ 'length': isInt,
+ 'startLine': isInt,
+ 'startColumn': isInt
+});
+
/**
* Type of closures used by MatchesJsonObject to record field mismatches.
@@ -343,6 +381,52 @@ class MatchesJsonObject extends Matcher {
}
/**
+ * Matcher that matches a list of objects, each of which satisfies the given
+ * matcher.
+ */
+class _ListOf extends Matcher {
+ /**
+ * Matcher which every element of the list must satisfy.
+ */
+ final Matcher elementMatcher;
+
+ /**
+ * Iterable matcher which we use to test the contents of the list.
+ */
+ final Matcher iterableMatcher;
+
+ _ListOf(elementMatcher)
+ : elementMatcher = elementMatcher,
+ iterableMatcher = everyElement(elementMatcher);
+
+ @override
+ bool matches(item, Map matchState) {
+ if (item is! List) {
+ return false;
+ }
+ return iterableMatcher.matches(item, matchState);
+ }
+
+ @override
+ Description describe(Description description) => description.add('List of '
+ ).addDescriptionOf(elementMatcher);
+
+ @override
+ Description describeMismatch(item, Description mismatchDescription, Map
+ matchState, bool verbose) {
+ if (item is! List) {
+ return super.describeMismatch(item, mismatchDescription, matchState,
+ verbose);
+ } else {
+ return iterableMatcher.describeMismatch(item, mismatchDescription,
+ matchState, verbose);
+ }
+ }
+}
+
+Matcher isListOf(Matcher elementMatcher) => new _ListOf(elementMatcher);
+
+/**
* Instances of the class [Server] manage a connection to a server process, and
* facilitate communication to and from the server.
*/

Powered by Google App Engine
This is Rietveld 408576698