My app shows a splash screen. How can I make my test wait for the main screen?

jdis

My app shows a splash screen. How can I make my test wait for the main screen to appear? Without waits my test fails immediately after app launch.

// in application:didFinishLaunchingWithOptions: of my AppDelegate...
SplashViewController *splashVC = [[SplashViewController alloc] init];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = splashVC;
[self.window makeKeyAndVisible];

NSTimeInterval splashScreenDuration = 0.5;
[NSTimer scheduledTimerWithTimeInterval:splashScreenDuration
                               target:self
                             selector:@selector(hideSpashScreenAndDisplayMainViewController)
                             userInfo:nil
                              repeats:NO];

// hideSpashScreenAndDisplayMainViewController method simply sets self.window.rootViewController to the main view controller.
gran_profaci

EarlGrey provides the GREYCondition API that you can use in your setup method or the beginning of your specific test to make EarlGrey wait while you wait for the splash screen to disappear. You can do this using code similar to what they have in their faq page.

// Wait for the main view controller to become the root view controller.
  BOOL success = [[GREYCondition conditionWithName:@"Wait for main root view controller"
                                             block:^{
    id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate;
    UIViewController *rootViewController = appDelegate.window.rootViewController;
    return [rootViewController isKindOfClass:[MainViewController class]];
  }] waitWithTimeout:5];

  GREYAssertTrue(success, @"Main view controller should appear within 5 seconds.");

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can i add UIActivityIndicator to Splash screen of my app?

From Dev

How can i make that my splash screen will start and finish according to the file downloading time?

From Dev

How can I make an Android splash screen with text & background color that changes if my phone is in light or dark mode?

From Dev

How can I use my own image for the boot splash screen?

From Java

How can I make a callback to a class through my homepage when it is already contextualised through my main screen?

From Dev

Can I make my iphone app use only a portion of the screen

From Dev

Swing: How can I display a Splash Screen before the main class?

From Dev

How can I make tableview the default view screen for my iOS app?

From Dev

My app splash screen remains white

From Dev

My app splash screen remains white

From Dev

No Actionbar after making splash screen in my app

From Java

How can I make my picture display on a half of the screen?

From Dev

how can I make my box respond to any screen size

From Dev

I am not getting splash screen in my app, only blank white screen is coming after that second activity is running

From Dev

How can I make Ubuntu not lock my screen when I close my laptop?

From Java

How do I make a splash screen?

From Dev

How can I record my screen?

From Dev

How can i center these images on my screen

From Dev

How can I increase my screen resolution?

From Dev

How can I record my screen?

From Dev

How can I landscape my laptop screen, with a LCD screen

From Dev

How to make VGA output display above my main screen by default?

From Dev

How can i make my advertisement be displayed on the home screen of my phone?

From Dev

how can i make my iphone app to Supporting Multiple iOS Versions and Devices in swift programmatically using device screen size

From Dev

How can I make my main form wait for a result from a custom dialog that I have created?

From Dev

My content leaves my screen, how can I prevent this?

From Dev

How can I get a transparent background in my iOS app so I can see the Home Screen wallpaper?

From Dev

Titanium SDK 3.2.0 - My Android app's STOP at splash screen

From Dev

Is there something I can do to my screen to make it less reflective?

Related Related

  1. 1

    How can i add UIActivityIndicator to Splash screen of my app?

  2. 2

    How can i make that my splash screen will start and finish according to the file downloading time?

  3. 3

    How can I make an Android splash screen with text & background color that changes if my phone is in light or dark mode?

  4. 4

    How can I use my own image for the boot splash screen?

  5. 5

    How can I make a callback to a class through my homepage when it is already contextualised through my main screen?

  6. 6

    Can I make my iphone app use only a portion of the screen

  7. 7

    Swing: How can I display a Splash Screen before the main class?

  8. 8

    How can I make tableview the default view screen for my iOS app?

  9. 9

    My app splash screen remains white

  10. 10

    My app splash screen remains white

  11. 11

    No Actionbar after making splash screen in my app

  12. 12

    How can I make my picture display on a half of the screen?

  13. 13

    how can I make my box respond to any screen size

  14. 14

    I am not getting splash screen in my app, only blank white screen is coming after that second activity is running

  15. 15

    How can I make Ubuntu not lock my screen when I close my laptop?

  16. 16

    How do I make a splash screen?

  17. 17

    How can I record my screen?

  18. 18

    How can i center these images on my screen

  19. 19

    How can I increase my screen resolution?

  20. 20

    How can I record my screen?

  21. 21

    How can I landscape my laptop screen, with a LCD screen

  22. 22

    How to make VGA output display above my main screen by default?

  23. 23

    How can i make my advertisement be displayed on the home screen of my phone?

  24. 24

    how can i make my iphone app to Supporting Multiple iOS Versions and Devices in swift programmatically using device screen size

  25. 25

    How can I make my main form wait for a result from a custom dialog that I have created?

  26. 26

    My content leaves my screen, how can I prevent this?

  27. 27

    How can I get a transparent background in my iOS app so I can see the Home Screen wallpaper?

  28. 28

    Titanium SDK 3.2.0 - My Android app's STOP at splash screen

  29. 29

    Is there something I can do to my screen to make it less reflective?

HotTag

Archive