|
| 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 | +// @dart = 2.8 |
| 6 | + |
| 7 | +import 'package:file/file.dart'; |
| 8 | +import 'package:file/memory.dart'; |
| 9 | +import 'package:flutter_tools/src/base/logger.dart'; |
| 10 | +import 'package:flutter_tools/src/isolated/mustache_template.dart'; |
| 11 | +import 'package:flutter_tools/src/template.dart'; |
| 12 | + |
| 13 | +import '../../src/common.dart'; |
| 14 | + |
| 15 | +void main() { |
| 16 | + |
| 17 | + testWithoutContext('kotlin reserved keywords', () { |
| 18 | + final FileSystem fileSystem = MemoryFileSystem.test(); |
| 19 | + final BufferLogger logger = BufferLogger.test(); |
| 20 | + final Directory rootDir = fileSystem.systemTempDirectory.createTempSync('flutter_template_test.'); |
| 21 | + final Directory templateSource = rootDir.childDirectory('src'); |
| 22 | + final Directory baseDir = templateSource; |
| 23 | + final Directory imageSourceDir = templateSource; |
| 24 | + final Directory destination = rootDir.childDirectory('dest'); |
| 25 | + |
| 26 | + const String outputClass = 'SomeClass.kt'; |
| 27 | + |
| 28 | + final File sourceFile = templateSource.childFile('$outputClass.tmpl'); |
| 29 | + |
| 30 | + templateSource.createSync(); |
| 31 | + sourceFile.writeAsStringSync('package {{androidIdentifier}};'); |
| 32 | + |
| 33 | + final Template template = Template( |
| 34 | + templateSource, |
| 35 | + baseDir, |
| 36 | + imageSourceDir, |
| 37 | + fileSystem: fileSystem, |
| 38 | + logger: logger, |
| 39 | + templateRenderer: const MustacheTemplateRenderer(), |
| 40 | + templateManifest: null |
| 41 | + ); |
| 42 | + |
| 43 | + final Map<String, Object> context = <String, Object>{ |
| 44 | + 'androidIdentifier': 'in.when.there' |
| 45 | + }; |
| 46 | + template.render(destination, context); |
| 47 | + |
| 48 | + final File destinationFile = destination.childFile(outputClass); |
| 49 | + expect(destinationFile.readAsStringSync(), equals('package `in`.`when`.there;')); |
| 50 | + }); |
| 51 | + |
| 52 | +} |
0 commit comments