1# Copyright 2014 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build/config/android/rules.gni")
6
7group("system") {
8  testonly = true
9  deps = [
10    ":mojo_javatests",
11    ":mojo_test_apk",
12    ":system_impl_java",
13  ]
14}
15
16generate_jni("jni_headers") {
17  sources = [
18    "javatests/src/org/chromium/mojo/MojoTestRule.java",
19    "javatests/src/org/chromium/mojo/bindings/ValidationTestUtil.java",
20  ]
21  public_deps = [
22    ":system_impl_java_jni_headers",
23  ]
24
25  jni_package = "mojo"
26}
27
28generate_jni("system_impl_java_jni_headers") {
29  sources = [
30    "src/org/chromium/mojo/system/impl/BaseRunLoop.java",
31    "src/org/chromium/mojo/system/impl/CoreImpl.java",
32    "src/org/chromium/mojo/system/impl/WatcherImpl.java",
33  ]
34
35  jni_package = "mojo"
36}
37
38source_set("native_support") {
39  sources = [
40    "base_run_loop.cc",
41    "core_impl.cc",
42    "watcher_impl.cc",
43  ]
44
45  deps = [
46    ":system_impl_java_jni_headers",
47    "//base",
48    "//mojo/public/c/system",
49    "//mojo/public/cpp/system",
50  ]
51}
52
53android_library("system_impl_java") {
54  java_files = [
55    "src/org/chromium/mojo/system/impl/BaseRunLoop.java",
56    "src/org/chromium/mojo/system/impl/CoreImpl.java",
57    "src/org/chromium/mojo/system/impl/DataPipeConsumerHandleImpl.java",
58    "src/org/chromium/mojo/system/impl/DataPipeProducerHandleImpl.java",
59    "src/org/chromium/mojo/system/impl/HandleBase.java",
60    "src/org/chromium/mojo/system/impl/MessagePipeHandleImpl.java",
61    "src/org/chromium/mojo/system/impl/SharedBufferHandleImpl.java",
62    "src/org/chromium/mojo/system/impl/UntypedHandleImpl.java",
63    "src/org/chromium/mojo/system/impl/WatcherImpl.java",
64  ]
65
66  deps = [
67    "//base:base_java",
68    "//mojo/public/java:system_java",
69  ]
70}
71
72# Targets should also depend on :test_support for the native side.
73android_library("test_support_java") {
74  testonly = true
75  java_files = [ "javatests/src/org/chromium/mojo/MojoTestRule.java" ]
76  deps = [
77    "//base:base_java",
78    "//third_party/junit",
79  ]
80}
81
82source_set("test_support") {
83  testonly = true
84  sources = [
85    "javatests/mojo_test_rule.cc",
86  ]
87  deps = [
88    ":jni_headers",
89    "//base",
90    "//base/test:test_support",
91    "//mojo/core/embedder",
92  ]
93  defines = [ "UNIT_TEST" ]
94}
95
96android_library("mojo_javatests") {
97  testonly = true
98  java_files = [
99    "javatests/src/org/chromium/mojo/HandleMock.java",
100    "javatests/src/org/chromium/mojo/TestUtils.java",
101    "javatests/src/org/chromium/mojo/bindings/BindingsHelperTest.java",
102    "javatests/src/org/chromium/mojo/bindings/BindingsTest.java",
103    "javatests/src/org/chromium/mojo/bindings/BindingsTestUtils.java",
104    "javatests/src/org/chromium/mojo/bindings/BindingsVersioningTest.java",
105    "javatests/src/org/chromium/mojo/bindings/CallbacksTest.java",
106    "javatests/src/org/chromium/mojo/bindings/ConnectorTest.java",
107    "javatests/src/org/chromium/mojo/bindings/ExecutorFactoryTest.java",
108    "javatests/src/org/chromium/mojo/bindings/InterfacesTest.java",
109    "javatests/src/org/chromium/mojo/bindings/MessageHeaderTest.java",
110    "javatests/src/org/chromium/mojo/bindings/NameGeneratorTest.java",
111    "javatests/src/org/chromium/mojo/bindings/ReadAndDispatchMessageTest.java",
112    "javatests/src/org/chromium/mojo/bindings/RouterTest.java",
113    "javatests/src/org/chromium/mojo/bindings/SerializationTest.java",
114    "javatests/src/org/chromium/mojo/bindings/test/mojom/mojo/IntegrationTestInterfaceTestHelper.java",
115    "javatests/src/org/chromium/mojo/bindings/ValidationTest.java",
116    "javatests/src/org/chromium/mojo/bindings/ValidationTestUtil.java",
117    "javatests/src/org/chromium/mojo/bindings/ValidationTestUtilTest.java",
118    "javatests/src/org/chromium/mojo/system/impl/CoreImplTest.java",
119    "javatests/src/org/chromium/mojo/system/impl/WatcherImplTest.java",
120  ]
121
122  deps = [
123    ":system_impl_java",
124    ":test_support_java",
125    "//base:base_java",
126    "//base:base_java_test_support",
127    "//mojo/public/interfaces/bindings/tests:test_interfaces_java",
128    "//mojo/public/interfaces/bindings/tests:test_mojom_import2_java",
129    "//mojo/public/interfaces/bindings/tests:test_mojom_import_java",
130    "//mojo/public/java:bindings_java",
131    "//mojo/public/java:system_java",
132    "//third_party/android_support_test_runner:runner_java",
133    "//third_party/junit",
134  ]
135
136  data = [
137    "//mojo/public/interfaces/bindings/tests/data/validation/",
138  ]
139}
140
141shared_library("mojo_java_unittests") {
142  testonly = true
143
144  sources = [
145    "javatests/init_library.cc",
146    "javatests/validation_test_util.cc",
147  ]
148
149  deps = [
150    ":jni_headers",
151    ":native_support",
152    ":system_impl_java_jni_headers",
153    ":test_support",
154    "//base",
155    "//base/test:test_support",
156    "//mojo/core/embedder",
157    "//mojo/public/cpp/bindings/tests:mojo_public_bindings_test_utils",
158    "//mojo/public/cpp/test_support:test_utils",
159  ]
160  defines = [ "UNIT_TEST" ]
161  configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
162  configs += [ "//build/config/android:hide_all_but_jni" ]
163}
164
165instrumentation_test_apk("mojo_test_apk") {
166  deps = [
167    ":mojo_javatests",
168    ":system_impl_java",
169    "//base:base_java",
170    "//mojo/public/interfaces/bindings/tests:test_interfaces",
171    "//mojo/public/java:bindings_java",
172    "//third_party/android_support_test_runner:runner_java",
173  ]
174  shared_libraries = [ ":mojo_java_unittests" ]
175  apk_name = "MojoTest"
176  android_manifest = "javatests/AndroidManifest.xml"
177}
178