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

Side by Side Diff: pkg/barback/test/asset_graph/source_test.dart

Issue 19402003: Rename several classes in barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 5 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library barback.test.asset_graph.source_test;
6
7 import 'dart:async';
8
9 import 'package:barback/barback.dart';
10 import 'package:barback/src/asset_graph.dart';
11 import 'package:scheduled_test/scheduled_test.dart';
12
13 import '../utils.dart';
14
15 main() {
16 initConfig();
17 test("gets a source asset", () {
18 initGraph(["app|foo.txt"]);
19 updateSources(["app|foo.txt"]);
20 expectAsset("app|foo.txt");
21 });
22
23 test("doesn't get an unknown source", () {
24 initGraph();
25 expectNoAsset("app|unknown.txt");
26 });
27
28 test("doesn't get an unprovided source", () {
29 initGraph();
30 updateSources(["app|unknown.txt"]);
31 expectNoAsset("app|unknown.txt");
32 });
33
34 test("doesn't get an asset that isn't an updated source", () {
35 initGraph(["app|foo.txt"]);
36
37 // Sources must be explicitly made visible to barback by calling
38 // updateSources() on them. It isn't enough for the provider to be able
39 // to provide it.
40 //
41 // This lets you distinguish between sources that you want to be primaries
42 // and the larger set of inputs that those primaries are allowed to pull in.
43 expectNoAsset("app|foo.txt");
44 });
45
46 test("gets a source asset if not transformed", () {
47 initGraph(["app|foo.txt"], {"app": [
48 [new RewriteTransformer("nottxt", "whatever")]
49 ]});
50
51 updateSources(["app|foo.txt"]);
52 expectAsset("app|foo.txt");
53 });
54
55 test("doesn't get a removed source", () {
56 initGraph(["app|foo.txt"]);
57
58 updateSources(["app|foo.txt"]);
59 expectAsset("app|foo.txt");
60
61 schedule(() {
62 removeSources(["app|foo.txt"]);
63 });
64
65 expectNoAsset("app|foo.txt");
66 });
67
68 test("collapses redundant updates", () {
69 var transformer = new RewriteTransformer("blub", "blab");
70 initGraph(["app|foo.blub"], {"app": [[transformer]]});
71
72 schedule(() {
73 // Make a bunch of synchronous update calls.
74 updateSources(["app|foo.blub"]);
75 updateSources(["app|foo.blub"]);
76 updateSources(["app|foo.blub"]);
77 updateSources(["app|foo.blub"]);
78 });
79
80 expectAsset("app|foo.blab", "foo.blab");
81
82 schedule(() {
83 expect(transformer.numRuns, equals(1));
84 });
85 });
86
87 test("a removal cancels out an update", () {
88 initGraph(["app|foo.txt"]);
89
90 schedule(() {
91 updateSources(["app|foo.txt"]);
92 removeSources(["app|foo.txt"]);
93 });
94
95 expectNoAsset("app|foo.txt");
96 });
97
98 test("an update cancels out a removal", () {
99 initGraph(["app|foo.txt"]);
100
101 schedule(() {
102 removeSources(["app|foo.txt"]);
103 updateSources(["app|foo.txt"]);
104 });
105
106 expectAsset("app|foo.txt");
107 });
108
109 test("restarts a build if a source is updated while sources are loading", () {
110 var transformer = new RewriteTransformer("txt", "out");
111 initGraph(["app|foo.txt", "app|other.bar"], {"app": [[transformer]]});
112
113 // Run the whole graph so all nodes are clean.
114 updateSources(["app|foo.txt", "app|other.bar"]);
115 expectAsset("app|foo.out", "foo.out");
116 expectAsset("app|other.bar");
117
118 buildShouldSucceed();
119
120 // Make the provider slow to load a source.
121 pauseProvider();
122
123 schedule(() {
124 // Update an asset that doesn't trigger any transformers.
125 updateSources(["app|other.bar"]);
126 });
127
128 schedule(() {
129 // Now update an asset that does trigger a transformer.
130 updateSources(["app|foo.txt"]);
131 });
132
133 resumeProvider();
134
135 buildShouldSucceed();
136 waitForBuild();
137
138 schedule(() {
139 expect(transformer.numRuns, equals(2));
140 });
141 });
142 }
OLDNEW
« no previous file with comments | « pkg/barback/test/asset_graph/errors_test.dart ('k') | pkg/barback/test/asset_graph/transform_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698