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

Side by Side Diff: pkg/http_server/test/virtual_directory_test.dart

Issue 125003002: Fix Directory path in VirtualDirectory, so it always ends with a platform-specific seperator. That'… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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
« no previous file with comments | « pkg/http_server/lib/src/virtual_directory.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import "package:http_server/http_server.dart"; 8 import "package:http_server/http_server.dart";
9 import 'package:path/path.dart' as pathos; 9 import 'package:path/path.dart' as pathos;
10 import "package:unittest/unittest.dart"; 10 import "package:unittest/unittest.dart";
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 request.response.close(); 206 request.response.close();
207 }; 207 };
208 208
209 virDir.serve(server); 209 virDir.serve(server);
210 210
211 return getAsString(server.port, '/') 211 return getAsString(server.port, '/')
212 .then((result) { 212 .then((result) {
213 expect(result, 'My handler /'); 213 expect(result, 'My handler /');
214 }); 214 });
215 }); 215 });
216
217 _testVirDir('index-1', (server, dir) {
218 new File('${dir.path}/index.html').writeAsStringSync('index file');
219 var virDir = new VirtualDirectory(dir.path);
220 virDir.allowDirectoryListing = true;
221 virDir.directoryHandler = (dir2, request) {
222 // Redirect directory-requests to index.html files.
223 var indexUri = new Uri.file(dir2.path).resolve('index.html');
224 virDir.serveFile(new File(indexUri.toFilePath()), request);
225 };
226 virDir.serve(server);
227 return getAsString(server.port, '/')
228 .then((result) {
229 expect(result, 'index file');
230 });
231 });
232
233 _testVirDir('index-2', (server, dir) {
234 new File('${dir.path}/dir/index.html')
235 ..createSync(recursive: true)
236 ..writeAsStringSync('index file');
237 var virDir = new VirtualDirectory(dir.path);
238 virDir.allowDirectoryListing = true;
239 virDir.directoryHandler = (dir2, request) {
240 // Redirect directory-requests to index.html files.
241 var indexUri = new Uri.file(dir2.path).resolve('index.html');
242 virDir.serveFile(new File(indexUri.toFilePath()), request);
243 };
244 virDir.serve(server);
245 return getAsString(server.port, '/dir')
246 .then((result) {
247 expect(result, 'index file');
248 });
249 });
216 }); 250 });
217 }); 251 });
218 252
219 group('links', () { 253 group('links', () {
220 if (!Platform.isWindows) { 254 if (!Platform.isWindows) {
221 group('follow-links', () { 255 group('follow-links', () {
222 _testVirDir('dir-link', (server, dir) { 256 _testVirDir('dir-link', (server, dir) {
223 var dir2 = new Directory('${dir.path}/dir2')..createSync(); 257 var dir2 = new Directory('${dir.path}/dir2')..createSync();
224 var link = new Link('${dir.path}/dir3')..createSync('dir2'); 258 var link = new Link('${dir.path}/dir3')..createSync('dir2');
225 var file = new File('${dir2.path}/file')..createSync(); 259 var file = new File('${dir2.path}/file')..createSync();
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 609
576 virDir.serve(server); 610 virDir.serve(server);
577 611
578 return getAsString(server.port, '/') 612 return getAsString(server.port, '/')
579 .then((result) { 613 .then((result) {
580 expect(result, 'file contents'); 614 expect(result, 'file contents');
581 }); 615 });
582 }); 616 });
583 }); 617 });
584 } 618 }
OLDNEW
« no previous file with comments | « pkg/http_server/lib/src/virtual_directory.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698