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

Unified Diff: pkg/analysis_server/test/edit/format_test.dart

Issue 833903005: Analysis server format service wiring (and protocol doc update). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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/edit/format_test.dart
===================================================================
--- pkg/analysis_server/test/edit/format_test.dart (revision 0)
+++ pkg/analysis_server/test/edit/format_test.dart (revision 0)
@@ -0,0 +1,77 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test.edit.format;
+
+import 'dart:async';
+
+import 'package:analysis_server/src/edit/edit_domain.dart';
+import 'package:analysis_server/src/protocol.dart';
+import 'package:unittest/unittest.dart' hide ERROR;
+
+import '../analysis_abstract.dart';
+import '../reflective_tests.dart';
+
+
+main() {
+ groupSep = ' | ';
+ runReflectiveTests(FormatTest);
+}
+
+
+@reflectiveTest
+class FormatTest extends AbstractAnalysisTest {
+ @override
+ void setUp() {
+ super.setUp();
+ createProject();
+ handler = new EditDomainHandler(server);
+ }
+
+ Future test_formatSimple() {
+ addTestFile('''
+main() { int x = 3; }
+''');
+ return waitForTasksFinished().then((_) {
+
+ EditFormatResult formatResult = _formatAt(0, 3);
+
+ expect(formatResult.edits, isNotNull);
+ expect(formatResult.edits, hasLength(1));
+
+ SourceEdit edit = formatResult.edits[0];
+ expect(edit.replacement, equals('''
+main() {
+ int x = 3;
+}
+'''));
+ expect(formatResult.selectionOffset, equals(0));
+ expect(formatResult.selectionLength, equals(3));
+ });
+ }
+
+ Future test_formatNoOp() {
+ // Already formatted source
+ addTestFile('''
+main() {
+ int x = 3;
+}
+''');
+ return waitForTasksFinished().then((_) {
+ EditFormatResult formatResult = _formatAt(0, 3);
+ expect(formatResult.edits, isNotNull);
+ expect(formatResult.edits, hasLength(0));
+ });
+ }
+
+ EditFormatResult _formatAt(int selectionOffset, int selectionLength) {
+ Request request = new EditFormatParams(
+ testFile,
+ selectionOffset,
+ selectionLength).toRequest('0');
+ Response response = handleSuccessfulRequest(request);
+ return new EditFormatResult.fromResponse(response);
+ }
+
+}

Powered by Google App Engine
This is Rietveld 408576698