| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680 |
- /*
- * Copyright 2017 Google
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- import XCTest
- class InAppMessaging_Example_iOS_SwiftUITests: XCTestCase {
- override func setUp() {
- super.setUp()
- continueAfterFailure = false
- let app = XCUIApplication()
- setupSnapshot(app)
- app.launch()
- }
- override func tearDown() {
- // Put teardown code here. This method is called after the invocation of each test method in the class.
- XCUIDevice.shared.orientation = .portrait
- super.tearDown()
- }
- func waitForElementToAppear(_ element: XCUIElement, _ timeoutInSeconds: TimeInterval = 5) {
- let existsPredicate = NSPredicate(format: "exists == true")
- expectation(for: existsPredicate, evaluatedWith: element, handler: nil)
- waitForExpectations(timeout: timeoutInSeconds, handler: nil)
- }
- func waitForElementToDisappear(_ element: XCUIElement, _ timeoutInSeconds: TimeInterval = 5) {
- let existsPredicate = NSPredicate(format: "exists == false")
- expectation(for: existsPredicate, evaluatedWith: element, handler: nil)
- waitForExpectations(timeout: timeoutInSeconds, handler: nil)
- }
- func childFrameWithinParentBound(parent: XCUIElement, child: XCUIElement) -> Bool {
- return parent.frame.contains(child.frame)
- }
- func isUIElementWithinUIWindow(_ uiElement: XCUIElement) -> Bool {
- let app = XCUIApplication()
- let window = app.windows.element(boundBy: 0)
- return window.frame.contains(uiElement.frame)
- }
- func isElementExistentAndHavingSize(_ uiElement: XCUIElement) -> Bool {
- // on iOS 9.3 for a XCUIElement whose height or width <=0, uiElement.exists still returns true
- // on iOS 10.3, for such an element uiElement.exists returns false
- // this function is to handle the existence (in our semanatic visible) testing for both cases
- return uiElement.exists && uiElement.frame.size.height > 0 && uiElement.frame.size.width > 0
- }
- func testNormalModalView() {
- let app = XCUIApplication()
- app.tabBars.buttons["Modal Messages"].tap()
- let messageCardView = app.otherElements["message-card-view"]
- let closeButton = app.buttons["close-button"]
- let imageView = app.images["modal-image-view"]
- let actionButton = app.buttons["message-action-button"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Regular"].tap()
- waitForElementToAppear(closeButton)
- snapshot("in-app-regular-modal-view-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(actionButton))
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isElementExistentAndHavingSize(messageCardView))
- XCTAssert(isElementExistentAndHavingSize(closeButton))
- XCTAssert(isUIElementWithinUIWindow(messageCardView))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: actionButton))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(messageCardView)
- }
- }
- func testModalViewWithWideImage() {
- let app = XCUIApplication()
- app.tabBars.buttons["Modal Messages"].tap()
- let messageCardView = app.otherElements["message-card-view"]
- let closeButton = app.buttons["close-button"]
- let imageView = app.images["modal-image-view"]
- let actionButton = app.buttons["message-action-button"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Thin Image"].tap()
- waitForElementToAppear(closeButton)
- snapshot("in-app-regular-modal-view-with-wider-image-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(actionButton))
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isElementExistentAndHavingSize(messageCardView))
- XCTAssert(isElementExistentAndHavingSize(closeButton))
- XCTAssert(isUIElementWithinUIWindow(messageCardView))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: actionButton))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(messageCardView)
- }
- }
- func testModalViewWithNarrowImage() {
- let app = XCUIApplication()
- app.tabBars.buttons["Modal Messages"].tap()
- let messageCardView = app.otherElements["message-card-view"]
- let closeButton = app.buttons["close-button"]
- let imageView = app.images["modal-image-view"]
- let actionButton = app.buttons["message-action-button"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Wide Image"].tap()
- waitForElementToAppear(closeButton)
- snapshot("in-app-regular-modal-view-with-narrow-image-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(actionButton))
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isElementExistentAndHavingSize(messageCardView))
- XCTAssert(isElementExistentAndHavingSize(closeButton))
- XCTAssert(isUIElementWithinUIWindow(messageCardView))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: actionButton))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(messageCardView)
- }
- }
- func testNormalBannerView() {
- let app = XCUIApplication()
- app.tabBars.buttons["Banner Messages"].tap()
- let titleElement = app.staticTexts["banner-message-title-view"]
- let imageView = app.images["banner-image-view"]
- let bodyElement = app.staticTexts["banner-body-label"]
- let bannerUIView = app.otherElements["banner-mode-uiview"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Show Regular Banner View"].tap()
- waitForElementToAppear(bannerUIView)
- snapshot("in-app-regular-banner-view-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isElementExistentAndHavingSize(titleElement))
- XCTAssert(isElementExistentAndHavingSize(bodyElement))
- bannerUIView.swipeUp()
- waitForElementToDisappear(bannerUIView)
- }
- }
- func testBannerViewAutoDimiss() {
- let app = XCUIApplication()
- app.tabBars.buttons["Banner Messages"].tap()
- let titleElement = app.staticTexts["banner-message-title-view"]
- let imageView = app.images["banner-image-view"]
- let bodyElement = app.staticTexts["banner-body-label"]
- let bannerUIView = app.otherElements["banner-mode-uiview"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Banner View With Short Auto Dismiss"].tap()
- waitForElementToAppear(bannerUIView)
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isElementExistentAndHavingSize(titleElement))
- XCTAssert(isElementExistentAndHavingSize(bodyElement))
- // without user action, the banner is dismissed quickly in this test setup
- waitForElementToDisappear(bannerUIView, 15)
- }
- }
- func testBannerViewWithoutImage() {
- let app = XCUIApplication()
- app.tabBars.buttons["Banner Messages"].tap()
- let titleElement = app.staticTexts["banner-message-title-view"]
- let bodyElement = app.staticTexts["banner-body-label"]
- let bannerUIView = app.otherElements["banner-mode-uiview"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Without Image"].tap()
- waitForElementToAppear(bannerUIView)
- snapshot("in-app-banner-view-without-image-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(titleElement))
- XCTAssert(isElementExistentAndHavingSize(bodyElement))
- bannerUIView.swipeUp()
- waitForElementToDisappear(bannerUIView)
- }
- }
- func testBannerViewWithLongTitle() {
- let app = XCUIApplication()
- app.tabBars.buttons["Banner Messages"].tap()
- let titleElement = app.staticTexts["banner-message-title-view"]
- let imageView = app.images["banner-image-view"]
- let bodyElement = app.staticTexts["banner-body-label"]
- let bannerUIView = app.otherElements["banner-mode-uiview"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["With Long Title"].tap()
- waitForElementToAppear(bannerUIView)
- snapshot("in-app-banner-view-with-long-title-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isElementExistentAndHavingSize(titleElement))
- XCTAssert(isElementExistentAndHavingSize(bodyElement))
- bannerUIView.swipeUp()
- waitForElementToDisappear(bannerUIView)
- }
- }
- func testBannerViewWithWideImage() {
- let app = XCUIApplication()
- app.tabBars.buttons["Banner Messages"].tap()
- let titleElement = app.staticTexts["banner-message-title-view"]
- let imageView = app.images["banner-image-view"]
- let bodyElement = app.staticTexts["banner-body-label"]
- let bannerUIView = app.otherElements["banner-mode-uiview"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["With Wide Image"].tap()
- waitForElementToAppear(bannerUIView)
- snapshot("in-app-banner-view-with-wide-image-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isElementExistentAndHavingSize(titleElement))
- XCTAssert(isElementExistentAndHavingSize(bodyElement))
- bannerUIView.swipeUp()
- waitForElementToDisappear(bannerUIView)
- }
- }
- func testBannerViewWithThinImage() {
- let app = XCUIApplication()
- app.tabBars.buttons["Banner Messages"].tap()
- let titleElement = app.staticTexts["banner-message-title-view"]
- let imageView = app.images["banner-image-view"]
- let bodyElement = app.staticTexts["banner-body-label"]
- let bannerUIView = app.otherElements["banner-mode-uiview"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["With Thin Image"].tap()
- waitForElementToAppear(bannerUIView)
- snapshot("in-app-banner-view-with-thing-image-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isElementExistentAndHavingSize(titleElement))
- XCTAssert(isElementExistentAndHavingSize(bodyElement))
- bannerUIView.swipeUp()
- waitForElementToDisappear(bannerUIView)
- }
- }
- func testBannerViewWithLargeBody() {
- let app = XCUIApplication()
- app.tabBars.buttons["Banner Messages"].tap()
- let titleElement = app.staticTexts["banner-message-title-view"]
- let imageView = app.images["banner-image-view"]
- let bodyElement = app.staticTexts["banner-body-label"]
- let bannerUIView = app.otherElements["banner-mode-uiview"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["With Large Body Text"].tap()
- waitForElementToAppear(bannerUIView)
- snapshot("in-app-banner-view-with-long-body-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isElementExistentAndHavingSize(titleElement))
- XCTAssert(isElementExistentAndHavingSize(bodyElement))
- bannerUIView.swipeUp()
- waitForElementToDisappear(bannerUIView)
- }
- }
- func testImageOnlyView() {
- let app = XCUIApplication()
- app.tabBars.buttons["Image Only Messages"].tap()
- let imageView = app.images["image-view-in-image-only-view"]
- let closeButton = app.buttons["close-button"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Show Regular Image Only View"].tap()
- waitForElementToAppear(closeButton)
- snapshot("in-app-regular-image-only-view-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isUIElementWithinUIWindow(imageView))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(imageView)
- }
- }
- func testImageOnlyViewWithLargeImageDimension() {
- let app = XCUIApplication()
- app.tabBars.buttons["Image Only Messages"].tap()
- let imageView = app.images["image-view-in-image-only-view"]
- let closeButton = app.buttons["close-button"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["High Dimension Image"].tap()
- // wait time longer due to large image
- waitForElementToAppear(closeButton, 10)
- snapshot("in-app-large-image-only-view-high-dimension-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isUIElementWithinUIWindow(imageView))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(imageView)
- }
- }
- func testImageOnlyViewWithLowImageDimension() {
- let app = XCUIApplication()
- app.tabBars.buttons["Image Only Messages"].tap()
- let imageView = app.images["image-view-in-image-only-view"]
- let closeButton = app.buttons["close-button"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Low Dimension Image"].tap()
- // wait time longer due to large image
- waitForElementToAppear(closeButton, 10)
- snapshot("in-app-large-image-only-view-low-dimension-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isUIElementWithinUIWindow(imageView))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(imageView)
- }
- }
- func testModalViewWithoutImage() {
- let app = XCUIApplication()
- app.tabBars.buttons["Modal Messages"].tap()
- let messageCardView = app.otherElements["message-card-view"]
- let closeButton = app.buttons["close-button"]
- let actionButton = app.buttons["message-action-button"]
- let imageView = app.images["modal-image-view"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Without Image"].tap()
- waitForElementToAppear(closeButton)
- snapshot("in-app-no-image-modal-view-\(orientation.rawValue)")
- XCTAssert(isElementExistentAndHavingSize(actionButton))
- XCTAssert(isElementExistentAndHavingSize(closeButton))
- XCTAssertFalse(isElementExistentAndHavingSize(imageView))
- XCTAssert(isElementExistentAndHavingSize(messageCardView))
- XCTAssert(isUIElementWithinUIWindow(messageCardView))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: actionButton))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(messageCardView)
- }
- }
- func testModalViewWithoutImageOrActionButton() {
- let app = XCUIApplication()
- app.tabBars.buttons["Modal Messages"].tap()
- let messageCardView = app.otherElements["message-card-view"]
- let closeButton = app.buttons["close-button"]
- let actionButton = app.buttons["message-action-button"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Wthout Image or Action Button"].tap()
- waitForElementToAppear(closeButton)
- snapshot("in-app-no-image-no-button-modal-view-\(orientation.rawValue)")
- XCTAssertFalse(isElementExistentAndHavingSize(actionButton))
- XCTAssert(isElementExistentAndHavingSize(closeButton))
- XCTAssert(isElementExistentAndHavingSize(messageCardView))
- XCTAssert(isUIElementWithinUIWindow(messageCardView))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(messageCardView)
- XCUIDevice.shared.orientation = .portrait
- }
- }
- func testModalViewWithoutActionButton() {
- let app = XCUIApplication()
- app.tabBars.buttons["Modal Messages"].tap()
- let messageCardView = app.otherElements["message-card-view"]
- let closeButton = app.buttons["close-button"]
- let imageView = app.images["modal-image-view"]
- let actionButton = app.buttons["message-action-button"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Without Action Button"].tap()
- waitForElementToAppear(closeButton)
- snapshot("in-app-no-action-button-moal-view-\(orientation.rawValue)")
- XCTAssertFalse(isElementExistentAndHavingSize(actionButton))
- XCTAssert(isElementExistentAndHavingSize(closeButton))
- XCTAssert(isElementExistentAndHavingSize(messageCardView))
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isUIElementWithinUIWindow(messageCardView))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(messageCardView)
- }
- }
- func testModalViewWithLongMessageTitle() {
- let app = XCUIApplication()
- app.tabBars.buttons["Modal Messages"].tap()
- let messageCardView = app.otherElements["message-card-view"]
- let closeButton = app.buttons["close-button"]
- let imageView = app.images["modal-image-view"]
- let bodyTextview = app.textViews["message-body-textview"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Large Title Text"].tap()
- waitForElementToAppear(closeButton)
- snapshot("in-app-long-title-modal-view-\(orientation.rawValue)")
- let actionButton = app.buttons["message-action-button"]
- XCTAssert(isElementExistentAndHavingSize(actionButton))
- XCTAssert(isElementExistentAndHavingSize(closeButton))
- XCTAssert(isElementExistentAndHavingSize(bodyTextview))
- XCTAssert(isElementExistentAndHavingSize(messageCardView))
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isUIElementWithinUIWindow(messageCardView))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: actionButton))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: bodyTextview))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: imageView))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(messageCardView)
- }
- }
- func testModalViewWithLongMessageBody() {
- let app = XCUIApplication()
- app.tabBars.buttons["Modal Messages"].tap()
- let messageCardView = app.otherElements["message-card-view"]
- let closeButton = app.buttons["close-button"]
- let imageView = app.images["modal-image-view"]
- let bodyTextview = app.textViews["message-body-textview"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["Large Title Text"].tap()
- waitForElementToAppear(closeButton)
- snapshot("in-app-long-body-modal-view-\(orientation.rawValue)")
- let actionButton = app.buttons["message-action-button"]
- XCTAssert(isElementExistentAndHavingSize(actionButton))
- XCTAssert(isElementExistentAndHavingSize(closeButton))
- XCTAssert(isElementExistentAndHavingSize(bodyTextview))
- XCTAssert(isElementExistentAndHavingSize(messageCardView))
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isUIElementWithinUIWindow(messageCardView))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: actionButton))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: bodyTextview))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: imageView))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(messageCardView)
- }
- }
- func testModalViewWithLongMessageTitleAndMessageBody() {
- let app = XCUIApplication()
- app.tabBars.buttons["Modal Messages"].tap()
- let messageCardView = app.otherElements["message-card-view"]
- let closeButton = app.buttons["close-button"]
- let imageView = app.images["modal-image-view"]
- let bodyTextview = app.textViews["message-body-textview"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["With Large Title and Body"].tap()
- waitForElementToAppear(closeButton)
- snapshot("in-app-long-title-and-body-modal-view-\(orientation.rawValue)")
- let actionButton = app.buttons["message-action-button"]
- XCTAssert(isElementExistentAndHavingSize(actionButton))
- XCTAssert(isElementExistentAndHavingSize(closeButton))
- XCTAssert(isElementExistentAndHavingSize(bodyTextview))
- XCTAssert(isElementExistentAndHavingSize(messageCardView))
- XCTAssert(isElementExistentAndHavingSize(imageView))
- XCTAssert(isUIElementWithinUIWindow(messageCardView))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: actionButton))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: bodyTextview))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: imageView))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(messageCardView)
- }
- }
- func testModalViewWithLongMessageTitleAndMessageBodyWithoutImage() {
- let app = XCUIApplication()
- app.tabBars.buttons["Modal Messages"].tap()
- let messageCardView = app.otherElements["message-card-view"]
- let closeButton = app.buttons["close-button"]
- let imageView = app.images["modal-image-view"]
- let bodyTextview = app.textViews["message-body-textview"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["With Large Title and Body Without Image"].tap()
- waitForElementToAppear(closeButton)
- snapshot("in-app-long-title-and-body-no-image-modal-view-\(orientation.rawValue)")
- let actionButton = app.buttons["message-action-button"]
- XCTAssert(isElementExistentAndHavingSize(actionButton))
- XCTAssert(isElementExistentAndHavingSize(closeButton))
- XCTAssert(isElementExistentAndHavingSize(bodyTextview))
- XCTAssert(isElementExistentAndHavingSize(messageCardView))
- XCTAssert(!isElementExistentAndHavingSize(imageView))
- XCTAssert(isUIElementWithinUIWindow(messageCardView))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: actionButton))
- XCTAssert(childFrameWithinParentBound(parent: messageCardView, child: bodyTextview))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(messageCardView)
- }
- }
- func testModalViewWithLongMessageTitleWithoutBodyWithoutImageWithoutButton() {
- let app = XCUIApplication()
- app.tabBars.buttons["Modal Messages"].tap()
- let messageCardView = app.otherElements["message-card-view"]
- let closeButton = app.buttons["close-button"]
- let imageView = app.images["modal-image-view"]
- let bodyTextview = app.textViews["message-body-textview"]
- let orientantions = [UIDeviceOrientation.portrait, UIDeviceOrientation.landscapeLeft]
- for orientation in orientantions {
- XCUIDevice.shared.orientation = orientation
- app.buttons["With Large Title, No Image, No Body and No Button"].tap()
- waitForElementToAppear(closeButton)
- snapshot("in-app-long-title-no-image-body-button-modal-view-\(orientation.rawValue)")
- let actionButton = app.buttons["message-action-button"]
- XCTAssert(!isElementExistentAndHavingSize(actionButton))
- XCTAssert(isElementExistentAndHavingSize(closeButton))
- XCTAssert(!isElementExistentAndHavingSize(bodyTextview))
- XCTAssert(isElementExistentAndHavingSize(messageCardView))
- XCTAssert(!isElementExistentAndHavingSize(imageView))
- XCTAssert(isUIElementWithinUIWindow(messageCardView))
- app.buttons["close-button"].tap()
- waitForElementToDisappear(messageCardView)
- }
- }
- }
|