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

Side by Side Diff: packages/initialize/test/initializer_custom_filter_test.dart

Issue 3014633002: Roll to pickup pool changes (Closed)
Patch Set: Created 3 years, 2 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // TODO(jakemac): swap this to @TestOn('pub-serve') once 5 // TODO(jakemac): swap this to @TestOn('pub-serve') once
6 // https://github.com/dart-lang/test/issues/388 is completed. 6 // https://github.com/dart-lang/test/issues/388 is completed.
7 @TestOn('!js') 7 @TestOn('!js')
8 library initialize.initializer_custom_filter_test; 8 library initialize.initializer_custom_filter_test;
9 9
10 import 'dart:async'; 10 import 'dart:async';
11 import 'package:initialize/initialize.dart'; 11 import 'package:initialize/initialize.dart';
12 import 'package:test/test.dart'; 12 import 'package:test/test.dart';
13 import 'package:initialize/src/initialize_tracker.dart'; 13 import 'package:initialize/src/initialize_tracker.dart';
14 14
15 main() { 15 main() {
16 test('filter option limits which types of annotations will be ran', () { 16 test('filter option limits which types of annotations will be ran', () {
17 var originalSize; 17 var originalSize;
18 return runPhase(1).then((_) { 18 return runPhase(1)
19 // Even though Baz extends Bar, only Baz should be run. 19 .then((_) {
20 expect(InitializeTracker.seen, [Baz]); 20 // Even though Baz extends Bar, only Baz should be run.
21 }).then((_) => runPhase(2)).then((_) { 21 expect(InitializeTracker.seen, [Baz]);
22 expect(InitializeTracker.seen, [Baz, foo]); 22 })
23 }).then((_) => runPhase(3)).then((_) { 23 .then((_) => runPhase(2))
24 expect(InitializeTracker.seen, [Baz, foo, Foo]); 24 .then((_) {
25 }).then((_) => runPhase(4)).then((_) { 25 expect(InitializeTracker.seen, [Baz, foo]);
26 expect(InitializeTracker.seen, [Baz, foo, Foo, Bar]); 26 })
27 }).then((_) { 27 .then((_) => runPhase(3))
28 originalSize = InitializeTracker.seen.length; 28 .then((_) {
29 }) 29 expect(InitializeTracker.seen, [Baz, foo, Foo]);
30 })
31 .then((_) => runPhase(4))
32 .then((_) {
33 expect(InitializeTracker.seen, [Baz, foo, Foo, Bar]);
34 })
35 .then((_) {
36 originalSize = InitializeTracker.seen.length;
37 })
30 .then((_) => runPhase(1)) 38 .then((_) => runPhase(1))
31 .then((_) => runPhase(2)) 39 .then((_) => runPhase(2))
32 .then((_) => runPhase(3)) 40 .then((_) => runPhase(3))
33 .then((_) => runPhase(4)) 41 .then((_) => runPhase(4))
34 .then((_) => run()) 42 .then((_) => run())
35 .then((_) { 43 .then((_) {
36 expect(InitializeTracker.seen.length, originalSize); 44 expect(InitializeTracker.seen.length, originalSize);
37 }); 45 });
38 }); 46 });
39 } 47 }
40 48
41 Future runPhase(int phase) => run( 49 Future runPhase(int phase) => run(
42 customFilter: (Initializer meta) => 50 customFilter: (Initializer meta) =>
43 meta is PhasedInitializer && meta.phase == phase); 51 meta is PhasedInitializer && meta.phase == phase);
44 52
45 @PhasedInitializer(3) 53 @PhasedInitializer(3)
46 class Foo {} 54 class Foo {}
47 55
48 @PhasedInitializer(2) 56 @PhasedInitializer(2)
49 foo() {} 57 foo() {}
50 58
51 @PhasedInitializer(4) 59 @PhasedInitializer(4)
52 class Bar {} 60 class Bar {}
53 61
54 @PhasedInitializer(1) 62 @PhasedInitializer(1)
55 class Baz extends Bar {} 63 class Baz extends Bar {}
56 64
57 // Initializer that has a phase associated with it, this can be used in 65 // Initializer that has a phase associated with it, this can be used in
58 // combination with a custom filter to run intialization in phases. 66 // combination with a custom filter to run intialization in phases.
59 class PhasedInitializer extends InitializeTracker { 67 class PhasedInitializer extends InitializeTracker {
60 final int phase; 68 final int phase;
61 69
62 const PhasedInitializer(this.phase); 70 const PhasedInitializer(this.phase);
63 } 71 }
OLDNEW
« no previous file with comments | « packages/initialize/test/deferred_library_test.dart ('k') | packages/initialize/test/initializer_cycle_error_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698