@@ -6,9 +6,8 @@ import 'package:clock/clock.dart';
6
6
import 'package:flutter/services.dart' ;
7
7
import 'package:flutter_test/flutter_test.dart' ;
8
8
import 'package:flutter/material.dart' ;
9
- import 'package:plugin_platform_interface/plugin_platform_interface.dart' ;
10
- import 'package:video_player_platform_interface/video_player_platform_interface.dart' ;
11
9
import 'package:video_player/video_player.dart' ;
10
+ import 'package:video_player_platform_interface/video_player_platform_interface.dart' ;
12
11
import 'package:zulip/api/model/events.dart' ;
13
12
import 'package:zulip/api/model/model.dart' ;
14
13
import 'package:zulip/model/localizations.dart' ;
@@ -32,16 +31,14 @@ const kTestVideoUrl = "https://a/video.mp4";
32
31
const kTestUnsupportedVideoUrl = "https://a/unsupported.mp4" ;
33
32
const kTestVideoDuration = Duration (seconds: 10 );
34
33
35
- class FakeVideoPlayerPlatform extends Fake
36
- with MockPlatformInterfaceMixin
37
- implements VideoPlayerPlatform {
34
+ class FakeVideoPlayerPlatform extends VideoPlayerPlatform {
38
35
static final FakeVideoPlayerPlatform instance = FakeVideoPlayerPlatform ();
39
36
40
37
static void registerWith () {
41
38
VideoPlayerPlatform .instance = instance;
42
39
}
43
40
44
- static const int _kTextureId = 0xffffffff ;
41
+ static const int _kPlayerId = 0xffffffff ;
45
42
46
43
StreamController <VideoEvent > _streamController = StreamController <VideoEvent >();
47
44
bool _hasError = false ;
@@ -104,21 +101,21 @@ class FakeVideoPlayerPlatform extends Fake
104
101
Future <void > init () async {}
105
102
106
103
@override
107
- Future <void > dispose (int textureId ) async {
104
+ Future <void > dispose (int playerId ) async {
108
105
if (_hasError) {
109
106
assert (! initialized);
110
- assert (textureId == VideoPlayerController .kUninitializedTextureId );
107
+ assert (playerId == VideoPlayerController .kUninitializedPlayerId );
111
108
return ;
112
109
}
113
110
114
111
assert (initialized);
115
- assert (textureId == _kTextureId );
112
+ assert (playerId == _kPlayerId );
116
113
}
117
114
118
115
@override
119
- Future <int ?> create ( DataSource dataSource ) async {
116
+ Future <int ?> createWithOptions ( VideoCreationOptions options ) async {
120
117
assert (! initialized);
121
- if (dataSource.uri == kTestUnsupportedVideoUrl) {
118
+ if (options. dataSource.uri == kTestUnsupportedVideoUrl) {
122
119
_hasError = true ;
123
120
_streamController.addError (
124
121
PlatformException (
@@ -135,24 +132,24 @@ class FakeVideoPlayerPlatform extends Fake
135
132
size: const Size (100 , 100 ),
136
133
rotationCorrection: 0 ,
137
134
));
138
- return _kTextureId ;
135
+ return _kPlayerId ;
139
136
}
140
137
141
138
@override
142
- Stream <VideoEvent > videoEventsFor (int textureId ) {
143
- assert (textureId == _kTextureId );
139
+ Stream <VideoEvent > videoEventsFor (int playerId ) {
140
+ assert (playerId == _kPlayerId );
144
141
return _streamController.stream;
145
142
}
146
143
147
144
@override
148
- Future <void > setLooping (int textureId , bool looping) async {
149
- assert (textureId == _kTextureId );
145
+ Future <void > setLooping (int playerId , bool looping) async {
146
+ assert (playerId == _kPlayerId );
150
147
assert (! looping);
151
148
}
152
149
153
150
@override
154
- Future <void > play (int textureId ) async {
155
- assert (textureId == _kTextureId );
151
+ Future <void > play (int playerId ) async {
152
+ assert (playerId == _kPlayerId );
156
153
_stopwatch? .start ();
157
154
_streamController.add (VideoEvent (
158
155
eventType: VideoEventType .isPlayingStateUpdate,
@@ -161,8 +158,8 @@ class FakeVideoPlayerPlatform extends Fake
161
158
}
162
159
163
160
@override
164
- Future <void > pause (int textureId ) async {
165
- assert (textureId == _kTextureId );
161
+ Future <void > pause (int playerId ) async {
162
+ assert (playerId == _kPlayerId );
166
163
_stopwatch? .stop ();
167
164
_streamController.add (VideoEvent (
168
165
eventType: VideoEventType .isPlayingStateUpdate,
@@ -171,33 +168,33 @@ class FakeVideoPlayerPlatform extends Fake
171
168
}
172
169
173
170
@override
174
- Future <void > setVolume (int textureId , double volume) async {
175
- assert (textureId == _kTextureId );
171
+ Future <void > setVolume (int playerId , double volume) async {
172
+ assert (playerId == _kPlayerId );
176
173
}
177
174
178
175
@override
179
- Future <void > seekTo (int textureId , Duration pos) async {
176
+ Future <void > seekTo (int playerId , Duration pos) async {
180
177
_callLog.add ('seekTo' );
181
- assert (textureId == _kTextureId );
178
+ assert (playerId == _kPlayerId );
182
179
183
180
_lastSetPosition = pos >= kTestVideoDuration ? kTestVideoDuration : pos;
184
181
_stopwatch? .reset ();
185
182
}
186
183
187
184
@override
188
- Future <void > setPlaybackSpeed (int textureId , double speed) async {
189
- assert (textureId == _kTextureId );
185
+ Future <void > setPlaybackSpeed (int playerId , double speed) async {
186
+ assert (playerId == _kPlayerId );
190
187
}
191
188
192
189
@override
193
- Future <Duration > getPosition (int textureId ) async {
194
- assert (textureId == _kTextureId );
190
+ Future <Duration > getPosition (int playerId ) async {
191
+ assert (playerId == _kPlayerId );
195
192
return position;
196
193
}
197
194
198
195
@override
199
- Widget buildView ( int textureId ) {
200
- assert (textureId == _kTextureId );
196
+ Widget buildViewWithOptions ( VideoViewOptions options ) {
197
+ assert (options.playerId == _kPlayerId );
201
198
return const SizedBox (width: 100 , height: 100 );
202
199
}
203
200
}
0 commit comments