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

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

Issue 402333006: Implementation of the 'edit.getFixes' API in server. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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.fixes;
6
7 import 'dart:async';
8
9 import 'package:analysis_server/src/computer/element.dart';
10 import 'package:analysis_server/src/computer/error.dart';
11 import 'package:analysis_server/src/constants.dart';
12 import 'package:analysis_server/src/edit/edit_domain.dart';
13 import 'package:analysis_server/src/edit/fix.dart';
14 import 'package:analysis_server/src/protocol.dart';
15 import 'package:analysis_services/constants.dart';
16 import 'package:analysis_services/correction/change.dart';
17 import 'package:analysis_testing/reflective_tests.dart';
18 import 'package:unittest/unittest.dart';
19
20 import '../analysis_abstract.dart';
21
22
23 main() {
24 groupSep = ' | ';
25 group('getFixes', () {
26 runReflectiveTests(FixesTest);
27 });
28 }
29
30
31 @ReflectiveTestCase()
32 class FixesTest extends AbstractAnalysisTest {
33 @override
34 void setUp() {
35 super.setUp();
36 createProject();
37 handler = new EditDomainHandler(server);
38 }
39
40 Future test_hasFixes() {
41 addTestFile('''
42 main() {
43 print(42)
44 }
45 ''');
46 return waitForTasksFinished().then((_) {
47 Request request = new Request('0', EDIT_GET_FIXES);
48 request.setParameter(FILE, testFile);
49 request.setParameter(OFFSET, findOffset('print'));
50 Response response = handleSuccessfulRequest(request);
51 List<Map<String, Object>> errorFixesJsonList = response.getResult(FIXES);
52 List<ErrorFixes> errorFixesList = errorFixesJsonList.map(ErrorFixes.fromJs on).toList();
53 expect(errorFixesList, hasLength(1));
54 {
55 ErrorFixes errorFixes = errorFixesList[0];
56 {
57 AnalysisError error = errorFixes.error;
58 expect(error.severity, 'ERROR');
59 expect(error.type, 'SYNTACTIC_ERROR');
60 expect(error.message, "Expected to find ';'");
61 {
62 Location location = error.location;
63 expect(location.file, testFile);
64 expect(location.offset, 19);
65 expect(location.length, 1);
66 expect(location.startLine, 2);
67 expect(location.startColumn, 11);
68 }
69 }
70 expect(errorFixes.fixes, hasLength(1));
71 {
72 Change change = errorFixes.fixes[0];
73 expect(change.message, "Insert ';'");
74 expect(change.edits, hasLength(1));
75 {
76 FileEdit fileEdit = change.edits[0];
77 expect(fileEdit.file, testFile);
78 expect(
79 fileEdit.edits.toString(),
80 "[Edit(offset=20, length=0, replacement=:>;<:)]");
81 }
82 }
83 }
84 });
85 }
86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698