10 #include "flutter/testing/testing.h"
22 @"viewType" :
@"FlutterPlatformViewMock"
25 __block
bool errored =
false;
32 [platformViewController handleMethodCall:methodCall result:result];
44 [platformViewController registerViewFactory:factory withId:
@"MockPlatformView"];
46 NSDictionary* creationArgs = @{
47 @"album" :
@"スコットとリバース",
48 @"releaseYear" : @2013,
49 @"artists" : @[
@"Scott Murphy",
@"Rivers Cuomo" ],
50 @"playlist" : @[
@"おかしいやつ",
@"ほどけていたんだ" ],
52 NSObject<FlutterMessageCodec>* codec = [factory createArgsCodec];
60 @"viewType" :
@"MockPlatformView",
61 @"params" : creationArgsData,
64 __block
bool success =
false;
71 [platformViewController handleMethodCall:methodCall result:result];
77 ASSERT_TRUE(view != nil);
78 ASSERT_TRUE(view.
args != nil);
81 NSString* album = [view.
args objectForKey:
@"album"];
82 EXPECT_TRUE([album isEqualToString:
@"スコットとリバース"]);
85 NSNumber* releaseYear = [view.
args objectForKey:
@"releaseYear"];
86 EXPECT_EQ(releaseYear.intValue, 2013);
89 NSArray* artists = [view.
args objectForKey:
@"artists"];
90 ASSERT_TRUE(artists != nil);
91 ASSERT_EQ(artists.count, 2ul);
92 EXPECT_TRUE([artists[0] isEqualToString:
@"Scott Murphy"]);
93 EXPECT_TRUE([artists[1] isEqualToString:
@"Rivers Cuomo"]);
95 NSArray* playlist = [view.
args objectForKey:
@"playlist"];
96 ASSERT_EQ(playlist.count, 2ul);
97 EXPECT_TRUE([playlist[0] isEqualToString:
@"おかしいやつ"]);
98 EXPECT_TRUE([playlist[1] isEqualToString:
@"ほどけていたんだ"]);
107 [platformViewController registerViewFactory:factory withId:
@"MockPlatformView"];
113 @"viewType" :
@"MockPlatformView"
116 __block
bool created =
false;
124 [platformViewController handleMethodCall:methodCallOnCreate result:resultOnCreate];
128 arguments:[NSNumber numberWithLongLong:2]];
130 __block
bool disposed =
false;
138 [platformViewController handleMethodCall:methodCallOnDispose result:resultOnDispose];
140 EXPECT_TRUE(created);
141 EXPECT_TRUE(disposed);
149 [platformViewController registerViewFactory:factory withId:
@"MockPlatformView"];
151 __block
bool created =
false;
166 @"viewType" :
@"MockPlatformView"
169 [platformViewController handleMethodCall:methodCallOnCreate0 result:resultOnCreate];
170 EXPECT_TRUE(created);
176 @"viewType" :
@"MockPlatformView"
178 [platformViewController handleMethodCall:methodCallOnCreate1 result:resultOnCreate];
179 EXPECT_TRUE(created);
185 EXPECT_TRUE(view != nil);
187 EXPECT_TRUE(view != nil);
190 [platformViewController reset];
193 EXPECT_TRUE(view == nil);
195 EXPECT_TRUE(view == nil);
204 arguments:[NSNumber numberWithLongLong:20]];
206 __block
bool errored =
false;
213 [platformViewController handleMethodCall:methodCall result:result];
215 EXPECT_TRUE(errored);
222 withId:
@"MockPlatformView"];
225 const NSNumber* viewId = [NSNumber numberWithLongLong:2];
227 methodCallWithMethodName:
@"create"
228 arguments:@{
@"id" : viewId,
@"viewType" :
@"MockPlatformView"}];
229 __block
bool created =
false;
236 [platformViewController handleMethodCall:methodCallOnCreate result:resultOnCreate];
240 [
FlutterMethodCall methodCallWithMethodName:
@"acceptGesture" arguments:@{
@"id" : viewId}];
241 __block
bool acceptGestureCalled =
false;
245 acceptGestureCalled =
true;
248 [platformViewController handleMethodCall:methodCallAcceptGesture result:resultAcceptGesture];
250 EXPECT_TRUE(created);
251 EXPECT_TRUE(acceptGestureCalled);
258 withId:
@"MockPlatformView"];
265 __block
bool errored =
false;
271 [platformViewController handleMethodCall:methodCallAcceptGesture result:result];
273 EXPECT_TRUE(errored);
280 withId:
@"MockPlatformView"];
283 const NSNumber* viewId = [NSNumber numberWithLongLong:2];
285 methodCallWithMethodName:
@"create"
286 arguments:@{
@"id" : viewId,
@"viewType" :
@"MockPlatformView"}];
287 __block
bool created =
false;
294 [platformViewController handleMethodCall:methodCallOnCreate result:resultOnCreate];
298 [
FlutterMethodCall methodCallWithMethodName:
@"rejectGesture" arguments:@{
@"id" : viewId}];
299 __block
bool rejectGestureCalled =
false;
303 rejectGestureCalled =
true;
306 [platformViewController handleMethodCall:methodCallRejectGesture result:resultRejectGesture];
308 EXPECT_TRUE(created);
309 EXPECT_TRUE(rejectGestureCalled);
316 withId:
@"MockPlatformView"];
323 __block
bool errored =
false;
329 [platformViewController handleMethodCall:methodCallRejectGesture result:result];
331 EXPECT_TRUE(errored);