| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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.services.correction.status; | 5 library test.services.correction.status; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol_server.dart' hide Element; | 7 import 'package:analysis_server/src/protocol_server.dart' hide Element; |
| 8 import 'package:analysis_server/src/services/correction/source_range.dart'; | 8 import 'package:analysis_server/src/services/correction/source_range.dart'; |
| 9 import 'package:analysis_server/src/services/correction/status.dart'; | 9 import 'package:analysis_server/src/services/correction/status.dart'; |
| 10 import 'package:analysis_server/src/services/search/search_engine.dart'; | 10 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 11 import 'package:analyzer/src/generated/ast.dart'; | 11 import 'package:analyzer/src/generated/ast.dart'; |
| 12 import 'package:analyzer/src/generated/element.dart'; | 12 import 'package:analyzer/src/generated/element.dart'; |
| 13 import 'package:analyzer/src/generated/source.dart'; | 13 import 'package:analyzer/src/generated/source.dart'; |
| 14 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
| 15 | 15 |
| 16 import '../../abstract_single_unit.dart'; | 16 import '../../abstract_single_unit.dart'; |
| 17 import '../../reflective_tests.dart'; | 17 import '../../reflective_tests.dart'; |
| 18 | 18 |
| 19 | 19 |
| 20 main() { | 20 main() { |
| 21 groupSep = ' | '; | 21 groupSep = ' | '; |
| 22 runReflectiveTests(RefactoringLocationTest); | 22 runReflectiveTests(RefactoringLocationTest); |
| 23 runReflectiveTests(RefactoringStatusTest); | 23 runReflectiveTests(RefactoringStatusTest); |
| 24 } | 24 } |
| 25 | 25 |
| 26 | 26 |
| 27 @ReflectiveTestCase() | 27 @reflectiveTest |
| 28 class RefactoringLocationTest extends AbstractSingleUnitTest { | 28 class RefactoringLocationTest extends AbstractSingleUnitTest { |
| 29 void test_createLocation_forElement() { | 29 void test_createLocation_forElement() { |
| 30 resolveTestUnit('class MyClass {}'); | 30 resolveTestUnit('class MyClass {}'); |
| 31 Element element = findElement('MyClass'); | 31 Element element = findElement('MyClass'); |
| 32 // check | 32 // check |
| 33 Location location = newLocation_fromElement(element); | 33 Location location = newLocation_fromElement(element); |
| 34 expect(location.file, '/test.dart'); | 34 expect(location.file, '/test.dart'); |
| 35 expect(location.offset, 6); | 35 expect(location.offset, 6); |
| 36 expect(location.length, 7); | 36 expect(location.length, 7); |
| 37 expect(location.startLine, 1); | 37 expect(location.startLine, 1); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 68 SourceRange range = rangeStartLength(10, 20); | 68 SourceRange range = rangeStartLength(10, 20); |
| 69 // check | 69 // check |
| 70 Location location = newLocation_fromUnit(testUnit, range); | 70 Location location = newLocation_fromUnit(testUnit, range); |
| 71 expect(location.file, '/test.dart'); | 71 expect(location.file, '/test.dart'); |
| 72 expect(location.offset, range.offset); | 72 expect(location.offset, range.offset); |
| 73 expect(location.length, range.length); | 73 expect(location.length, range.length); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 | 77 |
| 78 @ReflectiveTestCase() | 78 @reflectiveTest |
| 79 class RefactoringStatusTest { | 79 class RefactoringStatusTest { |
| 80 void test_addError() { | 80 void test_addError() { |
| 81 RefactoringStatus refactoringStatus = new RefactoringStatus(); | 81 RefactoringStatus refactoringStatus = new RefactoringStatus(); |
| 82 // initial state | 82 // initial state |
| 83 expect(refactoringStatus.severity, null); | 83 expect(refactoringStatus.severity, null); |
| 84 // add ERROR | 84 // add ERROR |
| 85 refactoringStatus.addError('msg'); | 85 refactoringStatus.addError('msg'); |
| 86 expect(refactoringStatus.severity, RefactoringProblemSeverity.ERROR); | 86 expect(refactoringStatus.severity, RefactoringProblemSeverity.ERROR); |
| 87 expect(refactoringStatus.isOK, isFalse); | 87 expect(refactoringStatus.isOK, isFalse); |
| 88 expect(refactoringStatus.hasFatalError, isFalse); | 88 expect(refactoringStatus.hasFatalError, isFalse); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 expect(refactoringStatus.severity, RefactoringProblemSeverity.FATAL); | 220 expect(refactoringStatus.severity, RefactoringProblemSeverity.FATAL); |
| 221 expect(refactoringStatus.message, 'msg'); | 221 expect(refactoringStatus.message, 'msg'); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void test_newWarning() { | 224 void test_newWarning() { |
| 225 RefactoringStatus refactoringStatus = new RefactoringStatus.warning('msg'); | 225 RefactoringStatus refactoringStatus = new RefactoringStatus.warning('msg'); |
| 226 expect(refactoringStatus.severity, RefactoringProblemSeverity.WARNING); | 226 expect(refactoringStatus.severity, RefactoringProblemSeverity.WARNING); |
| 227 expect(refactoringStatus.message, 'msg'); | 227 expect(refactoringStatus.message, 'msg'); |
| 228 } | 228 } |
| 229 } | 229 } |
| OLD | NEW |