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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.edit.format;
6
7 import 'dart:async';
8
9 import 'package:analysis_server/src/edit/edit_domain.dart';
10 import 'package:analysis_server/src/protocol.dart';
11 import 'package:unittest/unittest.dart' hide ERROR;
12
13 import '../analysis_abstract.dart';
14 import '../reflective_tests.dart';
15
16
17 main() {
18 groupSep = ' | ';
19 runReflectiveTests(FormatTest);
20 }
21
22
23 @reflectiveTest
24 class FormatTest extends AbstractAnalysisTest {
25 @override
26 void setUp() {
27 super.setUp();
28 createProject();
29 handler = new EditDomainHandler(server);
30 }
31
32 Future test_formatSimple() {
33 addTestFile('''
34 main() { int x = 3; }
35 ''');
36 return waitForTasksFinished().then((_) {
37
38 EditFormatResult formatResult = _formatAt(0, 3);
39
40 expect(formatResult.edits, isNotNull);
41 expect(formatResult.edits, hasLength(1));
42
43 SourceEdit edit = formatResult.edits[0];
44 expect(edit.replacement, equals('''
45 main() {
46 int x = 3;
47 }
48 '''));
49 expect(formatResult.selectionOffset, equals(0));
50 expect(formatResult.selectionLength, equals(3));
51 });
52 }
53
54 Future test_formatNoOp() {
55 // Already formatted source
56 addTestFile('''
57 main() {
58 int x = 3;
59 }
60 ''');
61 return waitForTasksFinished().then((_) {
62 EditFormatResult formatResult = _formatAt(0, 3);
63 expect(formatResult.edits, isNotNull);
64 expect(formatResult.edits, hasLength(0));
65 });
66 }
67
68 EditFormatResult _formatAt(int selectionOffset, int selectionLength) {
69 Request request = new EditFormatParams(
70 testFile,
71 selectionOffset,
72 selectionLength).toRequest('0');
73 Response response = handleSuccessfulRequest(request);
74 return new EditFormatResult.fromResponse(response);
75 }
76
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698