| 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.analysis.notification.implemented; | 5 library test.analysis.notification.implemented; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 10 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 * Validates that there is an [ImplementedClass] at the offset of [search]. | 30 * Validates that there is an [ImplementedClass] at the offset of [search]. |
| 31 * | 31 * |
| 32 * If [length] is not specified explicitly, then length of an identifier | 32 * If [length] is not specified explicitly, then length of an identifier |
| 33 * from [search] is used. | 33 * from [search] is used. |
| 34 */ | 34 */ |
| 35 void assertHasImplementedClass(String search, [int length = -1]) { | 35 void assertHasImplementedClass(String search, [int length = -1]) { |
| 36 int offset = findOffset(search); | 36 int offset = findOffset(search); |
| 37 if (length == -1) { | 37 if (length == -1) { |
| 38 length = findIdentifierLength(search); | 38 length = findIdentifierLength(search); |
| 39 } | 39 } |
| 40 if (implementedClasses == null) { |
| 41 fail('No notification of impemented classes was received'); |
| 42 } |
| 40 for (ImplementedClass clazz in implementedClasses) { | 43 for (ImplementedClass clazz in implementedClasses) { |
| 41 if (clazz.offset == offset && clazz.length == length) { | 44 if (clazz.offset == offset && clazz.length == length) { |
| 42 return; | 45 return; |
| 43 } | 46 } |
| 44 } | 47 } |
| 45 fail('Expect to find an implemented class at $offset' | 48 fail('Expect to find an implemented class at $offset' |
| 46 ' in $implementedClasses'); | 49 ' in $implementedClasses'); |
| 47 } | 50 } |
| 48 | 51 |
| 49 /** | 52 /** |
| 50 * Validates that there is an [ImplementedClass] at the offset of [search]. | 53 * Validates that there is an [ImplementedClass] at the offset of [search]. |
| 51 * | 54 * |
| 52 * If [length] is not specified explicitly, then length of an identifier | 55 * If [length] is not specified explicitly, then length of an identifier |
| 53 * from [search] is used. | 56 * from [search] is used. |
| 54 */ | 57 */ |
| 55 void assertHasImplementedMember(String search, [int length = -1]) { | 58 void assertHasImplementedMember(String search, [int length = -1]) { |
| 56 int offset = findOffset(search); | 59 int offset = findOffset(search); |
| 57 if (length == -1) { | 60 if (length == -1) { |
| 58 length = findIdentifierLength(search); | 61 length = findIdentifierLength(search); |
| 59 } | 62 } |
| 63 if (implementedMembers == null) { |
| 64 fail('No notification of impemented members was received'); |
| 65 } |
| 60 for (ImplementedMember member in implementedMembers) { | 66 for (ImplementedMember member in implementedMembers) { |
| 61 if (member.offset == offset && member.length == length) { | 67 if (member.offset == offset && member.length == length) { |
| 62 return; | 68 return; |
| 63 } | 69 } |
| 64 } | 70 } |
| 65 fail('Expect to find an implemented member at $offset' | 71 fail('Expect to find an implemented member at $offset' |
| 66 ' in $implementedMembers'); | 72 ' in $implementedMembers'); |
| 67 } | 73 } |
| 68 | 74 |
| 69 /** | 75 /** |
| 70 * Validates that there is no an [ImplementedClass] at the offset of [search]. | 76 * Validates that there is no an [ImplementedClass] at the offset of [search]. |
| 71 * | 77 * |
| 72 * If [length] is not specified explicitly, then length of an identifier | 78 * If [length] is not specified explicitly, then length of an identifier |
| 73 * from [search] is used. | 79 * from [search] is used. |
| 74 */ | 80 */ |
| 75 void assertNoImplementedMember(String search, [int length = -1]) { | 81 void assertNoImplementedMember(String search, [int length = -1]) { |
| 76 int offset = findOffset(search); | 82 int offset = findOffset(search); |
| 77 if (length == -1) { | 83 if (length == -1) { |
| 78 length = findIdentifierLength(search); | 84 length = findIdentifierLength(search); |
| 79 } | 85 } |
| 86 if (implementedMembers == null) { |
| 87 fail('No notification of impemented members was received'); |
| 88 } |
| 80 for (ImplementedMember member in implementedMembers) { | 89 for (ImplementedMember member in implementedMembers) { |
| 81 if (member.offset == offset) { | 90 if (member.offset == offset) { |
| 82 fail('Unexpected implemented member at $offset' | 91 fail('Unexpected implemented member at $offset' |
| 83 ' in $implementedMembers'); | 92 ' in $implementedMembers'); |
| 84 } | 93 } |
| 85 } | 94 } |
| 86 } | 95 } |
| 87 | 96 |
| 88 @override | 97 @override |
| 89 Index createIndex() { | 98 Index createIndex() { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 Future waitForNotification(int times) { | 319 Future waitForNotification(int times) { |
| 311 if (times == 0 || implementedClasses != null) { | 320 if (times == 0 || implementedClasses != null) { |
| 312 return new Future.value(); | 321 return new Future.value(); |
| 313 } | 322 } |
| 314 return new Future.delayed( | 323 return new Future.delayed( |
| 315 new Duration(milliseconds:1), () => waitForNotification(times - 1)); | 324 new Duration(milliseconds:1), () => waitForNotification(times - 1)); |
| 316 } | 325 } |
| 317 return waitForNotification(30000); | 326 return waitForNotification(30000); |
| 318 } | 327 } |
| 319 } | 328 } |
| OLD | NEW |