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

Unified Diff: sdk/lib/_internal/pub/test/serve/web_socket/path_to_urls_test.dart

Issue 203413004: Provide URLs for assets from lib/ and asset/ in pub's websocket API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix some small bugs Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/pub/test/serve/web_socket/path_to_urls_errors_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
});
« no previous file with comments | « sdk/lib/_internal/pub/test/serve/web_socket/path_to_urls_errors_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698