OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import 'dart:async' show | |
6 Future; | |
7 | |
8 import '../../tests/service_tests/service_tests.dart' show | |
9 BuildSnapshotRule, | |
10 CcRule, | |
11 CompileServiceRule, | |
12 CopyRule, | |
13 MakeDirectoryRule, | |
14 RunSnapshotRule, | |
15 ServiceTest, | |
16 isMacOS, | |
17 javaHome, | |
18 JarRule, | |
19 JavaRule, | |
20 JavacRule; | |
21 | |
22 const String baseName = 'simple_todo'; | |
23 const String thisDirectory = 'samples/simple_todo'; | |
24 | |
25 abstract class TodoServiceTest extends ServiceTest { | |
26 TodoServiceTest(String type) | |
27 : super('${baseName}_${type}'); | |
28 | |
29 String get idlPath => '$thisDirectory/simple_todo.idl'; | |
30 String get servicePath => '$outputDirectory/simple_todo.dart'; | |
31 String get snapshotPath => '$outputDirectory/simple_todo.snapshot'; | |
32 String get executablePath => '$outputDirectory/simple_todo_sample'; | |
33 String get generatedDirectory => '$outputDirectory/generated'; | |
34 | |
35 List<String> get ccSources => <String>[ | |
36 '$thisDirectory/simple_todo_main.cc', | |
37 '$generatedDirectory/cc/struct.cc', | |
38 '$generatedDirectory/cc/unicode.cc', | |
39 '$generatedDirectory/cc/simple_todo.cc', | |
40 ]; | |
41 | |
42 prepareService() { | |
43 rules.add(new MakeDirectoryRule(generatedDirectory)); | |
44 rules.add(new CompileServiceRule(idlPath, generatedDirectory)); | |
45 } | |
46 | |
47 prepareSnapshot() { | |
48 rules.add(new CopyRule(thisDirectory, outputDirectory, [ | |
49 'simple_todo.dart', | |
50 'simple_todo_impl.dart', | |
51 'todo_model.dart', | |
52 ])); | |
53 rules.add(new BuildSnapshotRule(servicePath, snapshotPath)); | |
54 } | |
55 } | |
56 | |
57 class TodoServiceTestCc extends TodoServiceTest { | |
58 TodoServiceTestCc() | |
59 : super('cc'); | |
60 | |
61 Future<Null> prepare() async { | |
62 prepareService(); | |
63 prepareSnapshot(); | |
64 rules.add(new CcRule( | |
65 executable: executablePath, | |
66 includePaths: [outputDirectory], | |
67 sources: ccSources)); | |
68 rules.add(new RunSnapshotRule(executablePath, snapshotPath)); | |
69 } | |
70 } | |
71 | |
72 class TodoServiceTestJava extends TodoServiceTest { | |
73 TodoServiceTestJava() | |
74 : super('java'); | |
75 | |
76 String get javaDirectory => '$generatedDirectory/java'; | |
77 String get classesDirectory => '$generatedDirectory/classes'; | |
78 String get jarFile => '$outputDirectory/$baseName.jar'; | |
79 String get mainClass => 'SimpleTodo'; | |
80 | |
81 List<String> get javaSources => <String>[ | |
82 '$thisDirectory/java/SimpleTodo.java', | |
83 '$thisDirectory/java/SnapshotRunner.java', | |
84 '$thisDirectory/java/TodoController.java', | |
85 '$thisDirectory/java/TodoView.java', | |
86 ]; | |
87 | |
88 Future<Null> prepare() async { | |
89 prepareService(); | |
90 prepareSnapshot(); | |
91 | |
92 if (javaHome.isEmpty) return; | |
93 | |
94 rules.add(new CcRule( | |
95 sharedLibrary: '$outputDirectory/libdartino', | |
96 includePaths: [ | |
97 'include', | |
98 '$javaHome/include', | |
99 '$javaHome/include/${isMacOS ? "darwin" : "linux"}', | |
100 outputDirectory, | |
101 ], | |
102 sources: [ | |
103 '$javaDirectory/jni/dartino_api_wrapper.cc', | |
104 '$javaDirectory/jni/dartino_service_api_wrapper.cc', | |
105 '$javaDirectory/jni/${baseName}_wrapper.cc', | |
106 ]..addAll(ccSources))); | |
107 | |
108 rules.add(new MakeDirectoryRule(classesDirectory)); | |
109 | |
110 rules.add(new JavacRule( | |
111 warningAsError: false, | |
112 sources: ['$javaDirectory/dartino']..addAll(javaSources), | |
113 outputDirectory: classesDirectory)); | |
114 | |
115 rules.add(new JarRule( | |
116 jarFile, | |
117 sources: ['.'], | |
118 baseDirectory: classesDirectory)); | |
119 | |
120 rules.add(new JavaRule( | |
121 mainClass, | |
122 arguments: [snapshotPath], | |
123 classpath: [jarFile], | |
124 libraryPath: outputDirectory)); | |
125 } | |
126 } | |
127 | |
128 final List<ServiceTest> serviceTests = <ServiceTest>[ | |
129 new TodoServiceTestCc(), | |
130 new TodoServiceTestJava(), | |
131 ]; | |
OLD | NEW |