|
| 1 | +// Copyright 2014 The Flutter 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 | + |
| 5 | +import 'package:flutter_tools/src/base/file_system.dart'; |
| 6 | +import 'package:flutter_tools/src/base/logger.dart'; |
| 7 | +import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart'; |
| 8 | +import 'package:flutter_tools/src/globals.dart' as globals; |
| 9 | + |
| 10 | +import '../src/common.dart'; |
| 11 | +import '../src/context.dart'; |
| 12 | + |
| 13 | +void main() { |
| 14 | + late BufferLogger logger; |
| 15 | + |
| 16 | + setUp(() { |
| 17 | + logger = BufferLogger.test(); |
| 18 | + }); |
| 19 | + |
| 20 | + testUsingContext('impellerc .iplr output has correct permissions', () async { |
| 21 | + if (globals.platform.isWindows) { |
| 22 | + return; |
| 23 | + } |
| 24 | + |
| 25 | + final String flutterRoot = getFlutterRoot(); |
| 26 | + final String inkSparklePath = globals.fs.path.join(flutterRoot, |
| 27 | + 'packages', 'flutter', 'lib', 'src', 'material', 'shaders', |
| 28 | + 'ink_sparkle.frag'); |
| 29 | + final Directory tmpDir = globals.fs.systemTempDirectory.createTempSync( |
| 30 | + 'shader_compiler_test.', |
| 31 | + ); |
| 32 | + final String inkSparkleOutputPath = globals.fs.path.join( |
| 33 | + tmpDir.path, 'ink_sparkle.frag', |
| 34 | + ); |
| 35 | + |
| 36 | + final ShaderCompiler shaderCompiler = ShaderCompiler( |
| 37 | + processManager: globals.processManager, |
| 38 | + logger: logger, |
| 39 | + fileSystem: globals.fs, |
| 40 | + artifacts: globals.artifacts!, |
| 41 | + ); |
| 42 | + final bool compileResult = await shaderCompiler.compileShader( |
| 43 | + input: globals.fs.file(inkSparklePath), |
| 44 | + outputPath: inkSparkleOutputPath, |
| 45 | + target: ShaderTarget.sksl, |
| 46 | + ); |
| 47 | + final File resultFile = globals.fs.file(inkSparkleOutputPath); |
| 48 | + |
| 49 | + |
| 50 | + expect(compileResult, true); |
| 51 | + expect(resultFile.existsSync(), true); |
| 52 | + |
| 53 | + final int expectedMode = int.parse('644', radix: 8); |
| 54 | + expect(resultFile.statSync().mode & expectedMode, equals(expectedMode)); |
| 55 | + }); |
| 56 | +} |
0 commit comments