22# Use of this source code is governed by a BSD-style license that can be
33# found in the LICENSE file.
44
5+ import (" //flutter/common/config.gni" )
56import (" //flutter/shell/gpu/gpu.gni" )
67import (" //flutter/testing/testing.gni" )
78
9+ if (is_fuchsia ) {
10+ import (" //build/fuchsia/sdk.gni" )
11+ import (" //flutter/tools/fuchsia/fuchsia_archive.gni" )
12+ }
13+
14+ config (" vulkan_config" ) {
15+ if (using_fuchsia_sdk ) {
16+ include_dirs = [ " $fuchsia_sdk_root /vulkan/include" ]
17+ } else if (is_fuchsia ) {
18+ include_dirs =
19+ [ " //third_party/vulkan_loader_and_validation_layers/include" ]
20+ } else {
21+ include_dirs = [ " //third_party/vulkan/src" ]
22+ }
23+
24+ if (is_fuchsia ) {
25+ defines = [ " VK_USE_PLATFORM_FUCHSIA=1" ]
26+ }
27+ }
28+
829# Template to generate a dart embedder resource.cc file.
930# Required invoker inputs:
1031# String output (name of output file)
@@ -143,12 +164,19 @@ template("shell_host_executable") {
143164 }
144165}
145166
146- if (current_toolchain == host_toolchain ) {
167+ if (enable_unittests ) {
168+ declare_args () {
169+ test_enable_vulkan = is_fuchsia
170+ test_enable_gl = ! is_fuchsia
171+ test_enable_software = true
172+ test_enable_metal = false
173+ }
174+
147175 shell_gpu_configuration (" shell_unittests_gpu_configuration" ) {
148- enable_software = true
149- enable_vulkan = false
150- enable_gl = true
151- enable_metal = false
176+ enable_software = test_enable_software
177+ enable_vulkan = test_enable_vulkan
178+ enable_gl = test_enable_gl
179+ enable_metal = test_enable_metal
152180 }
153181
154182 test_fixtures (" shell_unittests_fixtures" ) {
@@ -168,8 +196,6 @@ if (current_toolchain == host_toolchain) {
168196 " shell_test.h" ,
169197 " shell_test_platform_view.cc" ,
170198 " shell_test_platform_view.h" ,
171- " shell_test_platform_view_gl.cc" ,
172- " shell_test_platform_view_gl.h" ,
173199 " shell_unittests.cc" ,
174200 " vsync_waiters_test.cc" ,
175201 " vsync_waiters_test.h" ,
@@ -184,8 +210,63 @@ if (current_toolchain == host_toolchain) {
184210 " //flutter/lib/ui:ui" ,
185211 " //flutter/shell" ,
186212 " //flutter/testing:dart" ,
187- " //flutter/testing:opengl" ,
188213 ]
214+
215+ if (! defined (defines )) {
216+ defines = []
217+ }
218+
219+ # SwiftShader only supports x86/x64_64
220+ if (target_cpu == " x86" || target_cpu == " x64" ) {
221+ if (test_enable_gl ) {
222+ sources += [
223+ " shell_test_platform_view_gl.cc" ,
224+ " shell_test_platform_view_gl.h" ,
225+ ]
226+
227+ deps += [ " //flutter/testing:opengl" ]
228+
229+ defines += [ " SHELL_ENABLE_GL" ]
230+ }
231+
232+ if (test_enable_vulkan ) {
233+ sources += [
234+ " shell_test_platform_view_vulkan.cc" ,
235+ " shell_test_platform_view_vulkan.h" ,
236+ ]
237+
238+ deps += [
239+ " //flutter/testing:vulkan" ,
240+ " //flutter/vulkan" ,
241+ ]
242+
243+ defines += [ " SHELL_ENABLE_VULKAN" ]
244+ }
245+ }
246+ }
247+
248+ if (is_fuchsia ) {
249+ fuchsia_test_archive (" shell_tests" ) {
250+ deps = [
251+ " :shell_unittests" ,
252+ " :shell_unittests_fixtures" ,
253+ ]
254+
255+ binary = " shell_unittests"
256+
257+ # Right now we need to manually specify all the fixtures that are
258+ # declared in the test_fixtures() call above.
259+ resources = [
260+ {
261+ path = " $target_gen_dir /assets/kernel_blob.bin"
262+ dest = " assets/kernel_blob.bin"
263+ },
264+ {
265+ path = " $target_gen_dir /assets/shelltest_screenshot.png"
266+ dest = " assets/shelltest_screenshot.png"
267+ },
268+ ]
269+ }
189270 }
190271
191272 shell_host_executable (" shell_benchmarks" ) {
0 commit comments