12 changed files with 104 additions and 189 deletions
@ -1,5 +1,5 @@ |
|||||
class NWApi { |
class NWApi { |
||||
// static const baseApi = "https://www.deapsound.com"; |
// static const baseApi = "https://www.deapsound.com"; |
||||
static const baseApi = "https://api.deapsound.com"; |
static const baseApi = "https://api.deapsound.com"; |
||||
//static const baseApi = "https://api.ideapsound.com"; |
// static const baseApi = "https://api.ideapsound.com"; |
||||
} |
} |
||||
|
|||||
@ -1,132 +0,0 @@ |
|||||
import 'package:flutter_test/flutter_test.dart'; |
|
||||
import 'package:get/get.dart'; |
|
||||
import 'package:deep_voice/modules/agent/controllers/agent_controller.dart'; |
|
||||
import 'package:deep_voice/data/services/music_manager.dart'; |
|
||||
|
|
||||
void main() { |
|
||||
group('音乐功能测试', () { |
|
||||
late AgentController controller; |
|
||||
|
|
||||
setUp(() { |
|
||||
// 初始化GetX |
|
||||
Get.testMode = true; |
|
||||
|
|
||||
// 模拟MusicManager |
|
||||
Get.put<MusicManager>(MockMusicManager()); |
|
||||
|
|
||||
// 创建控制器 |
|
||||
controller = AgentController(); |
|
||||
}); |
|
||||
|
|
||||
tearDown(() { |
|
||||
Get.reset(); |
|
||||
}); |
|
||||
|
|
||||
test('播放进度状态初始化', () { |
|
||||
expect(controller.currentPosition.value, 0); |
|
||||
expect(controller.duration.value, 0); |
|
||||
expect(controller.progress.value, 0.0); |
|
||||
expect(controller.isPlaying.value, false); |
|
||||
expect(controller.currentUrl.value, ""); |
|
||||
}); |
|
||||
|
|
||||
test('播放音乐时状态更新', () { |
|
||||
final song = { |
|
||||
'id': 'test_id', |
|
||||
'title': 'Test Song', |
|
||||
'url': 'https://example.com/song.mp3', |
|
||||
'artist': 'Test Artist', |
|
||||
'coverUrl': 'https://example.com/cover.jpg', |
|
||||
}; |
|
||||
|
|
||||
controller.musicPlay(song); |
|
||||
|
|
||||
expect(controller.isPlaying.value, true); |
|
||||
expect(controller.currentUrl.value, song['url']); |
|
||||
}); |
|
||||
|
|
||||
test('暂停音乐时状态更新', () { |
|
||||
// 先播放 |
|
||||
final song = { |
|
||||
'id': 'test_id', |
|
||||
'title': 'Test Song', |
|
||||
'url': 'https://example.com/song.mp3', |
|
||||
'artist': 'Test Artist', |
|
||||
'coverUrl': 'https://example.com/cover.jpg', |
|
||||
}; |
|
||||
controller.musicPlay(song); |
|
||||
|
|
||||
// 然后暂停 |
|
||||
controller.musicPause(); |
|
||||
|
|
||||
expect(controller.isPlaying.value, false); |
|
||||
}); |
|
||||
|
|
||||
test('恢复播放时状态更新', () { |
|
||||
// 先播放然后暂停 |
|
||||
final song = { |
|
||||
'id': 'test_id', |
|
||||
'title': 'Test Song', |
|
||||
'url': 'https://example.com/song.mp3', |
|
||||
'artist': 'Test Artist', |
|
||||
'coverUrl': 'https://example.com/cover.jpg', |
|
||||
}; |
|
||||
controller.musicPlay(song); |
|
||||
controller.musicPause(); |
|
||||
|
|
||||
// 恢复播放 |
|
||||
controller.musicResume(); |
|
||||
|
|
||||
expect(controller.isPlaying.value, true); |
|
||||
}); |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
// 模拟MusicManager用于测试 |
|
||||
class MockMusicManager extends GetxService implements MusicManager { |
|
||||
@override |
|
||||
Future<void> play(Map<String, String> song) async { |
|
||||
// 模拟播放 |
|
||||
} |
|
||||
|
|
||||
@override |
|
||||
Future<void> pause() async { |
|
||||
// 模拟暂停 |
|
||||
} |
|
||||
|
|
||||
@override |
|
||||
Future<void> resume() async { |
|
||||
// 模拟恢复 |
|
||||
} |
|
||||
|
|
||||
@override |
|
||||
Future<Map<String, dynamic>> getStatus() async { |
|
||||
return { |
|
||||
'isPlaying': false, |
|
||||
'url': '', |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
@override |
|
||||
Future<Map<String, dynamic>> getProgress() async { |
|
||||
return { |
|
||||
'currentPosition': 0, |
|
||||
'duration': 0, |
|
||||
'progress': 0.0, |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
@override |
|
||||
Future<void> seekTo(int positionMs) async { |
|
||||
// 模拟跳转 |
|
||||
} |
|
||||
|
|
||||
@override |
|
||||
void onInit() {} |
|
||||
|
|
||||
@override |
|
||||
void onClose() {} |
|
||||
|
|
||||
@override |
|
||||
Future<void> requestNotificationPermission() async {} |
|
||||
} |
|
||||
Loading…
Reference in new issue