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

Side by Side Diff: pkg/analysis_server/test/edit/format_test.dart

Issue 1080653003: Create a public API for contributing fixes and make fixes pluggable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Missed clean-up Created 5 years, 8 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
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.edit.format; 5 library test.edit.format;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/edit/edit_domain.dart'; 9 import 'package:analysis_server/src/edit/edit_domain.dart';
10 import 'package:analysis_server/src/plugin/server_plugin.dart';
10 import 'package:analysis_server/src/protocol.dart'; 11 import 'package:analysis_server/src/protocol.dart';
12 import 'package:analyzer/src/plugin/plugin_impl.dart';
11 import 'package:unittest/unittest.dart' hide ERROR; 13 import 'package:unittest/unittest.dart' hide ERROR;
12 14
13 import '../analysis_abstract.dart'; 15 import '../analysis_abstract.dart';
14 import '../reflective_tests.dart'; 16 import '../reflective_tests.dart';
15 17
16 main() { 18 main() {
17 groupSep = ' | '; 19 groupSep = ' | ';
18 runReflectiveTests(FormatTest); 20 runReflectiveTests(FormatTest);
19 } 21 }
20 22
21 @reflectiveTest 23 @reflectiveTest
22 class FormatTest extends AbstractAnalysisTest { 24 class FormatTest extends AbstractAnalysisTest {
23 @override 25 @override
24 void setUp() { 26 void setUp() {
25 super.setUp(); 27 super.setUp();
26 createProject(); 28 createProject();
27 handler = new EditDomainHandler(server); 29 ExtensionManager manager = new ExtensionManager();
30 ServerPlugin plugin = new ServerPlugin();
31 manager.processPlugins([plugin]);
32 handler = new EditDomainHandler(server, plugin);
33 }
34
35 Future test_formatNoOp() {
36 // Already formatted source
37 addTestFile('''
38 main() {
39 int x = 3;
40 }
41 ''');
42 return waitForTasksFinished().then((_) {
43 EditFormatResult formatResult = _formatAt(0, 3);
44 expect(formatResult.edits, isNotNull);
45 expect(formatResult.edits, hasLength(0));
46 });
28 } 47 }
29 48
30 Future test_formatSimple() { 49 Future test_formatSimple() {
31 addTestFile(''' 50 addTestFile('''
32 main() { int x = 3; } 51 main() { int x = 3; }
33 '''); 52 ''');
34 return waitForTasksFinished().then((_) { 53 return waitForTasksFinished().then((_) {
35 EditFormatResult formatResult = _formatAt(0, 3); 54 EditFormatResult formatResult = _formatAt(0, 3);
36 55
37 expect(formatResult.edits, isNotNull); 56 expect(formatResult.edits, isNotNull);
38 expect(formatResult.edits, hasLength(1)); 57 expect(formatResult.edits, hasLength(1));
39 58
40 SourceEdit edit = formatResult.edits[0]; 59 SourceEdit edit = formatResult.edits[0];
41 expect(edit.replacement, equals(''' 60 expect(edit.replacement, equals('''
42 main() { 61 main() {
43 int x = 3; 62 int x = 3;
44 } 63 }
45 ''')); 64 '''));
46 expect(formatResult.selectionOffset, equals(0)); 65 expect(formatResult.selectionOffset, equals(0));
47 expect(formatResult.selectionLength, equals(3)); 66 expect(formatResult.selectionLength, equals(3));
48 }); 67 });
49 } 68 }
50 69
51 Future test_formatNoOp() {
52 // Already formatted source
53 addTestFile('''
54 main() {
55 int x = 3;
56 }
57 ''');
58 return waitForTasksFinished().then((_) {
59 EditFormatResult formatResult = _formatAt(0, 3);
60 expect(formatResult.edits, isNotNull);
61 expect(formatResult.edits, hasLength(0));
62 });
63 }
64
65 EditFormatResult _formatAt(int selectionOffset, int selectionLength) { 70 EditFormatResult _formatAt(int selectionOffset, int selectionLength) {
66 Request request = new EditFormatParams( 71 Request request = new EditFormatParams(
67 testFile, selectionOffset, selectionLength).toRequest('0'); 72 testFile, selectionOffset, selectionLength).toRequest('0');
68 Response response = handleSuccessfulRequest(request); 73 Response response = handleSuccessfulRequest(request);
69 return new EditFormatResult.fromResponse(response); 74 return new EditFormatResult.fromResponse(response);
70 } 75 }
71 } 76 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/edit/fixes_test.dart ('k') | pkg/analysis_server/test/edit/refactoring_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698