@@ -45,10 +45,6 @@ - (UIAccessibilityContrast)accessibilityContrast;
4545@end
4646#endif
4747
48- @interface FlutterViewController (Tests)
49- - (void )performOrientationUpdate : (UIInterfaceOrientationMask)new_preferences ;
50- @end
51-
5248@implementation FlutterViewControllerTest
5349
5450- (void )testBinaryMessenger {
@@ -256,179 +252,6 @@ - (void)testItReportsHighContrastWhenTraitCollectionRequestsIt {
256252 [mockTraitCollection stopMocking ];
257253}
258254
259- - (void )testPerformOrientationUpdateForcesOrientationChange {
260- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskPortrait
261- currentOrientation: UIInterfaceOrientationLandscapeLeft
262- didChangeOrientation: YES
263- resultingOrientation: UIInterfaceOrientationPortrait];
264-
265- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskPortrait
266- currentOrientation: UIInterfaceOrientationLandscapeRight
267- didChangeOrientation: YES
268- resultingOrientation: UIInterfaceOrientationPortrait];
269-
270- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskPortrait
271- currentOrientation: UIInterfaceOrientationPortraitUpsideDown
272- didChangeOrientation: YES
273- resultingOrientation: UIInterfaceOrientationPortrait];
274-
275- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskPortraitUpsideDown
276- currentOrientation: UIInterfaceOrientationLandscapeLeft
277- didChangeOrientation: YES
278- resultingOrientation: UIInterfaceOrientationPortraitUpsideDown];
279-
280- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskPortraitUpsideDown
281- currentOrientation: UIInterfaceOrientationLandscapeRight
282- didChangeOrientation: YES
283- resultingOrientation: UIInterfaceOrientationPortraitUpsideDown];
284-
285- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskPortraitUpsideDown
286- currentOrientation: UIInterfaceOrientationPortrait
287- didChangeOrientation: YES
288- resultingOrientation: UIInterfaceOrientationPortraitUpsideDown];
289-
290- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskLandscape
291- currentOrientation: UIInterfaceOrientationPortrait
292- didChangeOrientation: YES
293- resultingOrientation: UIInterfaceOrientationLandscapeLeft];
294-
295- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskLandscape
296- currentOrientation: UIInterfaceOrientationPortraitUpsideDown
297- didChangeOrientation: YES
298- resultingOrientation: UIInterfaceOrientationLandscapeLeft];
299-
300- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskLandscapeLeft
301- currentOrientation: UIInterfaceOrientationPortrait
302- didChangeOrientation: YES
303- resultingOrientation: UIInterfaceOrientationLandscapeLeft];
304-
305- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskLandscapeLeft
306- currentOrientation: UIInterfaceOrientationLandscapeRight
307- didChangeOrientation: YES
308- resultingOrientation: UIInterfaceOrientationLandscapeLeft];
309-
310- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskLandscapeLeft
311- currentOrientation: UIInterfaceOrientationPortraitUpsideDown
312- didChangeOrientation: YES
313- resultingOrientation: UIInterfaceOrientationLandscapeLeft];
314-
315- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskLandscapeRight
316- currentOrientation: UIInterfaceOrientationPortrait
317- didChangeOrientation: YES
318- resultingOrientation: UIInterfaceOrientationLandscapeRight];
319-
320- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskLandscapeRight
321- currentOrientation: UIInterfaceOrientationLandscapeLeft
322- didChangeOrientation: YES
323- resultingOrientation: UIInterfaceOrientationLandscapeRight];
324-
325- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskLandscapeRight
326- currentOrientation: UIInterfaceOrientationPortraitUpsideDown
327- didChangeOrientation: YES
328- resultingOrientation: UIInterfaceOrientationLandscapeRight];
329-
330- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskAllButUpsideDown
331- currentOrientation: UIInterfaceOrientationPortraitUpsideDown
332- didChangeOrientation: YES
333- resultingOrientation: UIInterfaceOrientationPortrait];
334- }
335-
336- - (void )testPerformOrientationUpdateDoesNotForceOrientationChange {
337- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskAll
338- currentOrientation: UIInterfaceOrientationPortrait
339- didChangeOrientation: NO
340- resultingOrientation: 0 ];
341-
342- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskAll
343- currentOrientation: UIInterfaceOrientationPortraitUpsideDown
344- didChangeOrientation: NO
345- resultingOrientation: 0 ];
346-
347- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskAll
348- currentOrientation: UIInterfaceOrientationLandscapeLeft
349- didChangeOrientation: NO
350- resultingOrientation: 0 ];
351-
352- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskAll
353- currentOrientation: UIInterfaceOrientationLandscapeRight
354- didChangeOrientation: NO
355- resultingOrientation: 0 ];
356-
357- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskAllButUpsideDown
358- currentOrientation: UIInterfaceOrientationPortrait
359- didChangeOrientation: NO
360- resultingOrientation: 0 ];
361-
362- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskAllButUpsideDown
363- currentOrientation: UIInterfaceOrientationLandscapeLeft
364- didChangeOrientation: NO
365- resultingOrientation: 0 ];
366-
367- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskAllButUpsideDown
368- currentOrientation: UIInterfaceOrientationLandscapeRight
369- didChangeOrientation: NO
370- resultingOrientation: 0 ];
371-
372- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskPortrait
373- currentOrientation: UIInterfaceOrientationPortrait
374- didChangeOrientation: NO
375- resultingOrientation: 0 ];
376-
377- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskPortraitUpsideDown
378- currentOrientation: UIInterfaceOrientationPortraitUpsideDown
379- didChangeOrientation: NO
380- resultingOrientation: 0 ];
381-
382- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskLandscape
383- currentOrientation: UIInterfaceOrientationLandscapeLeft
384- didChangeOrientation: NO
385- resultingOrientation: 0 ];
386-
387- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskLandscape
388- currentOrientation: UIInterfaceOrientationLandscapeRight
389- didChangeOrientation: NO
390- resultingOrientation: 0 ];
391-
392- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskLandscapeLeft
393- currentOrientation: UIInterfaceOrientationLandscapeLeft
394- didChangeOrientation: NO
395- resultingOrientation: 0 ];
396-
397- [self orientationTestWithOrientationUpdate: UIInterfaceOrientationMaskLandscapeRight
398- currentOrientation: UIInterfaceOrientationLandscapeRight
399- didChangeOrientation: NO
400- resultingOrientation: 0 ];
401- }
402-
403- // Perform an orientation update test that fails when the expected outcome
404- // for an orientation update is not met
405- - (void )orientationTestWithOrientationUpdate : (UIInterfaceOrientationMask)mask
406- currentOrientation : (UIInterfaceOrientation)currentOrientation
407- didChangeOrientation : (BOOL )didChange
408- resultingOrientation : (UIInterfaceOrientation)resultingOrientation {
409- id engine = OCMClassMock ([FlutterEngine class ]);
410-
411- id deviceMock = OCMPartialMock ([UIDevice currentDevice ]);
412- if (!didChange) {
413- OCMReject ([deviceMock setValue: [OCMArg any ] forKey: @" orientation" ]);
414- } else {
415- OCMExpect ([deviceMock setValue: @(resultingOrientation) forKey: @" orientation" ]);
416- }
417-
418- FlutterViewController* realVC = [[FlutterViewController alloc ] initWithEngine: engine
419- nibName: nil
420- bundle: nil ];
421- id mockApplication = OCMClassMock ([UIApplication class ]);
422- OCMStub ([mockApplication sharedApplication ]).andReturn (mockApplication);
423- OCMStub ([mockApplication statusBarOrientation ]).andReturn (currentOrientation);
424-
425- [realVC performOrientationUpdate: mask];
426- OCMVerifyAll (deviceMock);
427- [engine stopMocking ];
428- [deviceMock stopMocking ];
429- [mockApplication stopMocking ];
430- }
431-
432255// Creates a mocked UITraitCollection with nil values for everything except accessibilityContrast,
433256// which is set to the given "contrast".
434257- (UITraitCollection*)fakeTraitCollectionWithContrast : (UIAccessibilityContrast)contrast {
0 commit comments