4

I want to test that some functionality works in a split/a slide over view.

My current ui test opens the dock panel and tries to drag the iMessage app to the right border of a simulator's screen.

Looks like that any interaction doesn't work with elements which are not related to my app.

Is it possible to move an app to a split view or a slider over view programmatically inside ui test after an app running?

Eugene
  • 53
  • 7

1 Answers1

0

It is possible on older iOS versions. However, it will need to be done manually using coordinates as far as I'm aware. There is an existing helper repo I found here that might help (I've not used it though) https://github.com/superz515/UITestingMultitaskingHelper.

iOS 15 makes this slightly easier with the multi-task support UI.

enter image description here enter image description here enter image description here

If you observe the springboard application in XCUITest process you will see:

Default state:

Button, 0x600001a02d80, {{1004.5, 667.0}, {14.0, 32.0}}, identifier: 'top-affordance:XCUITestSplit', label: 'XCUITestSplit, Multitasking controls'

After tapping the control:

Button, 0x600001431340, {{968.0, 609.0}, {40.0, 40.0}}, identifier: 'top-affordance-full-screen-button', label: 'Full screen', Selected
Button, 0x600001431500, {{968.0, 663.0}, {40.0, 40.0}}, identifier: 'top-affordance-split-view-button', label: 'Split view'
Button, 0x6000014316c0, {{968.0, 717.0}, {40.0, 40.0}}, identifier: 'top-affordance-slide-over-button', label: 'Slide over'

After tapping an option:

BannerNotification, 0x600001a38000, {{966.0, 574.5}, {50.0, 217.5}}
    Button, 0x600001a380e0, {{966.0, 574.5}, {50.0, 217.5}}, label: 'Split View, Choose another app'

Icons example

Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'Files', label: 'Files'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'Reminders', label: 'Reminders'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'News', label: 'News'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'Calendar', label: 'Calendar'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'Reminders', label: 'Reminders'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'Maps', label: 'Maps'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'News', label: 'News'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'Settings', label: 'Settings'
Icon, {{810.5, 155.0}, {95.5, 77.0}}, identifier: 'Shortcuts', label: 'Create XCUITestSplit split view with Shortcuts'
Icon, {{810.5, 353.0}, {95.5, 72.5}}, identifier: 'Contacts', label: 'Create XCUITestSplit split view with Contacts'
Icon, {{810.5, 548.0}, {95.5, 75.0}}, identifier: 'Magnifier', label: 'Create XCUITestSplit split view with Magnifier'

Example

The above can get you in split view pretty quickly. However more control over how many columns requires moving the divider which is a bit more work (as I mentioned earlier), and you also need to consider resetting the state so the app doesn't launch again in split view.

func testExample() throws {
    let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
    let app = XCUIApplication()

    app.launch()
    springboard.buttons["top-affordance:XCUITestSplit"].tap()
    springboard.buttons["top-affordance-split-view-button"].tap()
    springboard.icons["Shortcuts"].firstMatch.tap()
}

Gif (tap to watch, forgive orientation) Example

lacking-cypher
  • 483
  • 4
  • 16