Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/flutter_tts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.7.0

* Return a boolean from `isLanguageAvailable` to match the behavior of other platforms.
* Add integration tests for the supported TTS APIs.

## 1.6.0

* Update flutter_tts 4.2.0 to 4.2.5.
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_tts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This package is not an _endorsed_ implementation of `flutter_tts`. Therefore, yo
```yaml
dependencies:
flutter_tts: ^4.2.5
flutter_tts_tizen: ^1.6.0
flutter_tts_tizen: ^1.7.0
```

Then you can import `flutter_tts` in your Dart code:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,90 @@ import 'package:integration_test/integration_test.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

testWidgets('Can speak', (WidgetTester tester) async {
final flutterTts = FlutterTts();
late FlutterTts flutterTts;

setUpAll(() async {
flutterTts = FlutterTts();
// Give the native TTS engine time to initialize.
await Future<void>.delayed(const Duration(seconds: 2));
var result = await flutterTts.speak('Hello, world!');
expect(result, 1);
});

tearDown(() async {
await flutterTts.stop();
});

testWidgets('speak returns 1', (WidgetTester tester) async {
expect(await flutterTts.speak('Hello, world!'), 1);
});

testWidgets('stop returns 1', (WidgetTester tester) async {
expect(await flutterTts.stop(), 1);
});

testWidgets('getLanguages returns a non-empty list', (
WidgetTester tester,
) async {
final languages = await flutterTts.getLanguages;
expect(languages, isNotNull);
expect(languages, isNotEmpty);
});

testWidgets('isLanguageAvailable is true for a supported language', (
WidgetTester tester,
) async {
final languages = (await flutterTts.getLanguages as List).cast<String>();
expect(languages, isNotEmpty);
expect(await flutterTts.isLanguageAvailable(languages.first), isTrue);
Comment thread
seungsoo47 marked this conversation as resolved.
});

testWidgets('setLanguage returns 1 for a supported language', (
WidgetTester tester,
) async {
final languages = (await flutterTts.getLanguages as List).cast<String>();
expect(languages, isNotEmpty);
expect(await flutterTts.setLanguage(languages.first), 1);
Comment thread
seungsoo47 marked this conversation as resolved.
});

testWidgets('getVoices returns a non-empty list', (
WidgetTester tester,
) async {
final voices = await flutterTts.getVoices;
expect(voices, isNotNull);
expect(voices, isNotEmpty);
Comment on lines +55 to +57

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just wondering, I think getVoices might not be available depending on the environment. (Currently, our target always has voice, but there could be multiple building blocks.) Is this test case valid? Usually, in cases like this, wouldn't you test by mocking getVoices?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integration tests run against real devices or specific emulators where the TTS engine is always present. If 'getVoices' returns empty, it means the device or emulator is not properly configured for TTS, which is a valid test failure.

});

testWidgets('getDefaultVoice returns a voice', (WidgetTester tester) async {
expect(await flutterTts.getDefaultVoice, isNotNull);
});

testWidgets('setVoice returns 1', (WidgetTester tester) async {
final voices = (await flutterTts.getVoices as List).cast<Map>();
expect(voices, isNotEmpty);
final voice = voices.first;
expect(
await flutterTts.setVoice(<String, String>{
'name': voice['name'].toString(),
'locale': voice['locale'].toString(),
}),
1,
);
Comment thread
seungsoo47 marked this conversation as resolved.
});

testWidgets('setSpeechRate returns 1', (WidgetTester tester) async {
expect(await flutterTts.setSpeechRate(0.5), 1);
});

testWidgets('setVolume returns 1', (WidgetTester tester) async {
expect(await flutterTts.setVolume(1), 1);
});

testWidgets('getMaxSpeechInputLength is positive', (
WidgetTester tester,
) async {
// tts_get_max_text_size requires the ready state; stop() ensures it.
await flutterTts.stop();
final maxLength = await flutterTts.getMaxSpeechInputLength;
expect(maxLength, isNotNull);
expect(maxLength, greaterThan(0));
});
}
2 changes: 1 addition & 1 deletion packages/flutter_tts/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_tts_tizen
description: The Tizen implementation of flutter_tts plugin.
homepage: https://github.com/flutter-tizen/plugins
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/flutter_tts
version: 1.6.0
version: 1.7.0

environment:
sdk: ">=3.1.0 <4.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter_tts/tizen/src/flutter_tts_tizen_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ class FlutterTtsTizenPlugin : public flutter::Plugin {
if (std::holds_alternative<std::string>(arguments)) {
std::string language = std::move(std::get<std::string>(arguments));
if (!language.empty() && tts_->IsLanguageAvailable(language)) {
SendResult(flutter::EncodableValue(1));
SendResult(flutter::EncodableValue(true));
return;
}
}
SendResult(flutter::EncodableValue(0));
SendResult(flutter::EncodableValue(false));
Comment on lines +301 to +305

@JSUYA JSUYA Jun 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this part is a change to the interface (Future<int> -> Future<Bool>), I think the version needs to be changed to 1.7.0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

void SendResult(const flutter::EncodableValue &result) {
Expand Down
Loading