| Index: sdk/lib/_internal/pub/test/serve/web_socket/path_to_urls_test.dart
|
| diff --git a/sdk/lib/_internal/pub/test/serve/web_socket/path_to_urls_test.dart b/sdk/lib/_internal/pub/test/serve/web_socket/path_to_urls_test.dart
|
| index daa28243480abb5b6f7b6f26636e0b3650bfa805..d20eb00ca707b7502b087167f6ba8beaafa6bdd8 100644
|
| --- a/sdk/lib/_internal/pub/test/serve/web_socket/path_to_urls_test.dart
|
| +++ b/sdk/lib/_internal/pub/test/serve/web_socket/path_to_urls_test.dart
|
| @@ -15,14 +15,30 @@ main() {
|
| // TODO(rnystrom): Split into independent tests.
|
| initConfig();
|
| integration("pathToUrls converts asset ids to matching URL paths", () {
|
| + d.dir("foo", [
|
| + d.libPubspec("foo", "1.0.0"),
|
| + d.dir("lib", [
|
| + d.file("foo.dart", "foo() => null;")
|
| + ]),
|
| + d.dir("asset", [
|
| + d.file("foo.txt", "foo")
|
| + ]),
|
| + ]).create();
|
| +
|
| d.dir(appPath, [
|
| - d.appPubspec(),
|
| + d.appPubspec({"foo": {"path": "../foo"}}),
|
| d.dir("test", [
|
| d.file("index.html", "<body>"),
|
| d.dir("sub", [
|
| d.file("bar.html", "bar"),
|
| ])
|
| ]),
|
| + d.dir("lib", [
|
| + d.file("app.dart", "app() => null;")
|
| + ]),
|
| + d.dir("asset", [
|
| + d.file("app.txt", "app")
|
| + ]),
|
| d.dir("web", [
|
| d.file("index.html", "<body>"),
|
| d.dir("sub", [
|
| @@ -34,37 +50,115 @@ main() {
|
| ])
|
| ]).create();
|
|
|
| - pubServe(args: ["test", "web", "randomdir"]);
|
| -
|
| - schedule(() {
|
| - // Paths in web/.
|
| - expectWebSocketCall({
|
| - "command": "pathToUrls",
|
| - "path": p.join("web", "index.html")
|
| - }, replyEquals: {"urls": [getServerUrl("web", "index.html")]});
|
| -
|
| - expectWebSocketCall({
|
| - "command": "pathToUrls",
|
| - "path": p.join("web", "sub", "bar.html")
|
| - }, replyEquals: {"urls": [getServerUrl("web", "sub/bar.html")]});
|
| -
|
| - // Paths in test/.
|
| - expectWebSocketCall({
|
| - "command": "pathToUrls",
|
| - "path": p.join("test", "index.html")
|
| - }, replyEquals: {"urls": [getServerUrl("test", "index.html")]});
|
| -
|
| - expectWebSocketCall({
|
| - "command": "pathToUrls",
|
| - "path": p.join("test", "sub", "bar.html")
|
| - }, replyEquals: {"urls": [getServerUrl("test", "sub/bar.html")]});
|
| -
|
| - // A non-default directory.
|
| - expectWebSocketCall({
|
| - "command": "pathToUrls",
|
| - "path": p.join("randomdir", "index.html")
|
| - }, replyEquals: {"urls": [getServerUrl("randomdir", "index.html")]});
|
| - });
|
| + pubServe(args: ["test", "web", "randomdir"], shouldGetFirst: true);
|
| +
|
| + // Paths in web/.
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.join("web", "index.html")
|
| + }, replyEquals: {"urls": [getServerUrl("web", "index.html")]});
|
| +
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.join("web", "sub", "bar.html")
|
| + }, replyEquals: {"urls": [getServerUrl("web", "sub/bar.html")]});
|
| +
|
| + // Paths in test/.
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.join("test", "index.html")
|
| + }, replyEquals: {"urls": [getServerUrl("test", "index.html")]});
|
| +
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.join("test", "sub", "bar.html")
|
| + }, replyEquals: {"urls": [getServerUrl("test", "sub/bar.html")]});
|
| +
|
| + // A non-default directory.
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.join("randomdir", "index.html")
|
| + }, replyEquals: {"urls": [getServerUrl("randomdir", "index.html")]});
|
| +
|
| + // A path in lib/.
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.join("lib", "app.dart")
|
| + }, replyEquals: {"urls": [
|
| + getServerUrl("test", "packages/myapp/app.dart"),
|
| + getServerUrl("web", "packages/myapp/app.dart"),
|
| + getServerUrl("randomdir", "packages/myapp/app.dart")
|
| + ]});
|
| +
|
| + // A path in asset/.
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.join("asset", "app.txt")
|
| + }, replyEquals: {"urls": [
|
| + getServerUrl("test", "assets/myapp/app.txt"),
|
| + getServerUrl("web", "assets/myapp/app.txt"),
|
| + getServerUrl("randomdir", "assets/myapp/app.txt")
|
| + ]});
|
| +
|
| + // A path to this package in packages/.
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.join("packages", "myapp", "app.dart")
|
| + }, replyEquals: {"urls": [
|
| + getServerUrl("test", "packages/myapp/app.dart"),
|
| + getServerUrl("web", "packages/myapp/app.dart"),
|
| + getServerUrl("randomdir", "packages/myapp/app.dart")
|
| + ]});
|
| +
|
| + // A path to another package in packages/.
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.join("packages", "foo", "foo.dart")
|
| + }, replyEquals: {"urls": [
|
| + getServerUrl("test", "packages/foo/foo.dart"),
|
| + getServerUrl("web", "packages/foo/foo.dart"),
|
| + getServerUrl("randomdir", "packages/foo/foo.dart")
|
| + ]});
|
| +
|
| + // A relative path to another package's lib/ directory.
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.join("..", "foo", "lib", "foo.dart")
|
| + }, replyEquals: {"urls": [
|
| + getServerUrl("test", "packages/foo/foo.dart"),
|
| + getServerUrl("web", "packages/foo/foo.dart"),
|
| + getServerUrl("randomdir", "packages/foo/foo.dart")
|
| + ]});
|
| +
|
| + // An absolute path to another package's lib/ directory.
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.absolute(sandboxDir, "foo", "lib", "foo.dart")
|
| + }, replyEquals: {"urls": [
|
| + getServerUrl("test", "packages/foo/foo.dart"),
|
| + getServerUrl("web", "packages/foo/foo.dart"),
|
| + getServerUrl("randomdir", "packages/foo/foo.dart")
|
| + ]});
|
| +
|
| + // A relative path to another package's asset/ directory.
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.join("..", "foo", "asset", "foo.dart")
|
| + }, replyEquals: {"urls": [
|
| + getServerUrl("test", "assets/foo/foo.dart"),
|
| + getServerUrl("web", "assets/foo/foo.dart"),
|
| + getServerUrl("randomdir", "assets/foo/foo.dart")
|
| + ]});
|
| +
|
| + // An absolute path to another package's asset/ directory.
|
| + expectWebSocketCall({
|
| + "command": "pathToUrls",
|
| + "path": p.absolute(sandboxDir, "foo", "asset", "foo.dart")
|
| + }, replyEquals: {"urls": [
|
| + getServerUrl("test", "assets/foo/foo.dart"),
|
| + getServerUrl("web", "assets/foo/foo.dart"),
|
| + getServerUrl("randomdir", "assets/foo/foo.dart")
|
| + ]});
|
|
|
| endPubServe();
|
| });
|
|
|