Skip to content

Commit

Permalink
Add data asset test project (#1243)
Browse files Browse the repository at this point in the history
* Add data asset test project

* Change description

* Fix gitignore

* Add readme

* Rename to .txt

* Use .debug instead

* update manifest
  • Loading branch information
mosuem authored Jun 28, 2024
1 parent 739f12c commit 9d821f1
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkgs/native_assets_builder/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Use `HookConfig.targetIosSdk` and `HookConfig.targetMacosSdk` optional
values, and add examples to fail builds based on this.
- Add data asset test project.

## 0.7.0

Expand Down
5 changes: 5 additions & 0 deletions pkgs/native_assets_builder/test_data/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
- simple_link/hook/build.dart
- simple_link/hook/link.dart
- simple_link/pubspec.yaml
- simple_data_asset/pubspec.yaml
- simple_data_asset/asset/test_asset.txt
- simple_data_asset/README.md
- simple_data_asset/hook/build.dart
- simple_data_asset/bin/simple_data_asset.dart.debug
- some_dev_dep/bin/some_dev_dep.dart
- some_dev_dep/pubspec.yaml
- wrong_build_output_2/hook/build.dart
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
bin/simple_data_asset/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This sample adds and retrieves a data asset.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World!
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:asset';

Future<void> main(List<String> args) async {
print('Hello ${await getWorld()}');
}

Future<String> getWorld() async {
const asset = ByteAsset('package:simple_data_asset/assetId');
final byteBuffer = await asset.load();
return String.fromCharCodes(byteBuffer.asUint8List());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:native_assets_cli/native_assets_cli.dart';

void main(List<String> args) => build(
args,
(config, output) async {
output.addAsset(
DataAsset(
package: config.packageName,
name: 'assetId',
file: config.packageRoot.resolve('asset/test_asset.txt'),
),
);
output.addDependency(config.packageRoot.resolve('hook/build.dart'));
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: simple_data_asset
description: Add and retrieve a data asset.
version: 1.0.0

publish_to: none

environment:
sdk: ^3.0.0

dependencies:
logging: ^1.1.1
# native_assets_cli: ^0.6.0
native_assets_cli:
path: ../../../native_assets_cli/

dev_dependencies:
lints: ^3.0.0
test: ^1.24.0

0 comments on commit 9d821f1

Please sign in to comment.