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);
150 arguments:[NSNumber numberWithLongLong:20]];
152 __block
bool errored =
false;
159 [platformViewController handleMethodCall:methodCall result:result];
161 EXPECT_TRUE(errored);
168 withId:
@"MockPlatformView"];
171 const NSNumber* viewId = [NSNumber numberWithLongLong:2];
173 methodCallWithMethodName:
@"create"
174 arguments:@{
@"id" : viewId,
@"viewType" :
@"MockPlatformView"}];
175 __block
bool created =
false;
182 [platformViewController handleMethodCall:methodCallOnCreate result:resultOnCreate];
186 [
FlutterMethodCall methodCallWithMethodName:
@"acceptGesture" arguments:@{
@"id" : viewId}];
187 __block
bool acceptGestureCalled =
false;
191 acceptGestureCalled =
true;
194 [platformViewController handleMethodCall:methodCallAcceptGesture result:resultAcceptGesture];
196 EXPECT_TRUE(created);
197 EXPECT_TRUE(acceptGestureCalled);
204 withId:
@"MockPlatformView"];
211 __block
bool errored =
false;
217 [platformViewController handleMethodCall:methodCallAcceptGesture result:result];
219 EXPECT_TRUE(errored);
226 withId:
@"MockPlatformView"];
229 const NSNumber* viewId = [NSNumber numberWithLongLong:2];
231 methodCallWithMethodName:
@"create"
232 arguments:@{
@"id" : viewId,
@"viewType" :
@"MockPlatformView"}];
233 __block
bool created =
false;
240 [platformViewController handleMethodCall:methodCallOnCreate result:resultOnCreate];
244 [
FlutterMethodCall methodCallWithMethodName:
@"rejectGesture" arguments:@{
@"id" : viewId}];
245 __block
bool rejectGestureCalled =
false;
249 rejectGestureCalled =
true;
252 [platformViewController handleMethodCall:methodCallRejectGesture result:resultRejectGesture];
254 EXPECT_TRUE(created);
255 EXPECT_TRUE(rejectGestureCalled);
262 withId:
@"MockPlatformView"];
269 __block
bool errored =
false;
275 [platformViewController handleMethodCall:methodCallRejectGesture result:result];
277 EXPECT_TRUE(errored);