| 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.physical.resource.provider; | 5 library test.physical.resource.provider; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/resource.dart'; | 10 import 'package:analysis_server/src/resource.dart'; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 new io.File(path).writeAsStringSync('contents'); | 143 new io.File(path).writeAsStringSync('contents'); |
| 144 expect(file.exists, isTrue); | 144 expect(file.exists, isTrue); |
| 145 }); | 145 }); |
| 146 }); | 146 }); |
| 147 | 147 |
| 148 test('fullName', () { | 148 test('fullName', () { |
| 149 expect(file.path, path); | 149 expect(file.path, path); |
| 150 }); | 150 }); |
| 151 | 151 |
| 152 test('hashCode', () { | 152 test('hashCode', () { |
| 153 file.hashCode; | 153 new io.File(path).writeAsStringSync('contents'); |
| 154 File file2 = PhysicalResourceProvider.INSTANCE.getResource(path); |
| 155 expect(file.hashCode, equals(file2.hashCode)); |
| 156 }); |
| 157 |
| 158 test('equality', () { |
| 159 new io.File(path).writeAsStringSync('contents'); |
| 160 File file2 = PhysicalResourceProvider.INSTANCE.getResource(path); |
| 161 expect(file == file2, isTrue); |
| 154 }); | 162 }); |
| 155 | 163 |
| 156 test('shortName', () { | 164 test('shortName', () { |
| 157 expect(file.shortName, 'file.txt'); | 165 expect(file.shortName, 'file.txt'); |
| 158 }); | 166 }); |
| 159 | 167 |
| 160 test('toString', () { | 168 test('toString', () { |
| 161 expect(file.toString(), path); | 169 expect(file.toString(), path); |
| 162 }); | 170 }); |
| 163 | 171 |
| 164 test('parent', () { | 172 test('parent', () { |
| 165 Resource parent = file.parent; | 173 Resource parent = file.parent; |
| 166 expect(parent, new isInstanceOf<Folder>()); | 174 expect(parent, new isInstanceOf<Folder>()); |
| 167 expect(parent.path, equals(tempPath)); | 175 expect(parent.path, equals(tempPath)); |
| 168 }); | 176 }); |
| 169 }); | 177 }); |
| 170 | 178 |
| 171 group('Folder', () { | 179 group('Folder', () { |
| 172 String path; | 180 String path; |
| 173 Folder folder; | 181 Folder folder; |
| 174 | 182 |
| 175 setUp(() { | 183 setUp(() { |
| 176 path = join(tempPath, 'folder'); | 184 path = join(tempPath, 'folder'); |
| 177 new io.Directory(path).createSync(); | 185 new io.Directory(path).createSync(); |
| 178 folder = PhysicalResourceProvider.INSTANCE.getResource(path); | 186 folder = PhysicalResourceProvider.INSTANCE.getResource(path); |
| 179 }); | 187 }); |
| 180 | 188 |
| 189 test('hashCode', () { |
| 190 Folder folder2 = PhysicalResourceProvider.INSTANCE.getResource(path); |
| 191 expect(folder.hashCode, equals(folder2.hashCode)); |
| 192 }); |
| 193 |
| 194 test('equality', () { |
| 195 Folder folder2 = PhysicalResourceProvider.INSTANCE.getResource(path); |
| 196 expect(folder == folder2, isTrue); |
| 197 }); |
| 198 |
| 181 group('getChild', () { | 199 group('getChild', () { |
| 182 test('does not exist', () { | 200 test('does not exist', () { |
| 183 var child = folder.getChild('no-such-resource'); | 201 var child = folder.getChild('no-such-resource'); |
| 184 expect(child, isNotNull); | 202 expect(child, isNotNull); |
| 185 expect(child.exists, isFalse); | 203 expect(child.exists, isFalse); |
| 186 }); | 204 }); |
| 187 | 205 |
| 188 test('file', () { | 206 test('file', () { |
| 189 new io.File(join(path, 'myFile')).createSync(); | 207 new io.File(join(path, 'myFile')).createSync(); |
| 190 var child = folder.getChild('myFile'); | 208 var child = folder.getChild('myFile'); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 expect(folder.canonicalizePath(join('.', 'baz')), equals(join(path, 'b
az'))); | 271 expect(folder.canonicalizePath(join('.', 'baz')), equals(join(path, 'b
az'))); |
| 254 expect(folder.canonicalizePath(join(path2, '.', 'baz')), equals(join(p
ath2, 'baz'))); | 272 expect(folder.canonicalizePath(join(path2, '.', 'baz')), equals(join(p
ath2, 'baz'))); |
| 255 }); | 273 }); |
| 256 }); | 274 }); |
| 257 }); | 275 }); |
| 258 } | 276 } |
| 259 | 277 |
| 260 var _isFile = new isInstanceOf<File>(); | 278 var _isFile = new isInstanceOf<File>(); |
| 261 var _isFolder = new isInstanceOf<Folder>(); | 279 var _isFolder = new isInstanceOf<Folder>(); |
| 262 var _isMemoryResourceException = new isInstanceOf<MemoryResourceException>(); | 280 var _isMemoryResourceException = new isInstanceOf<MemoryResourceException>(); |
| OLD | NEW |