2016-12-01 18:28:57 +00:00
/* *
Copyright ( c ) 2016 - present , Facebook , Inc . All rights reserved .
The examples provided by Facebook are for non - commercial testing and evaluation
purposes only . Facebook reserves all rights not expressly granted .
THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR
IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY ,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL
FACEBOOK BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE .
*/
import XCTest
final class MixedDataViewControllerUITests : UITestCase {
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
override func setUp ( ) {
super . setUp ( )
enterMixedDataDetailScreen ( )
}
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
func test_whenSelectingAll_thatAllSectionTypesArePresent ( ) {
mixedDataNavigationBarElement ( ) . buttons [ " All " ] . tap ( )
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
XCTAssertTrue ( expandableSectionElement ( ) . exists )
XCTAssertTrue ( userSectionElement ( ) . exists )
XCTAssertTrue ( gridSectionElement ( ) . exists )
}
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
func test_whenSelectingColors_thatOnlyGridSectionsArePresent ( ) {
mixedDataNavigationBarElement ( ) . buttons [ " Colors " ] . tap ( )
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
XCTAssertFalse ( expandableSectionElement ( ) . exists )
XCTAssertFalse ( userSectionElement ( ) . exists )
XCTAssertTrue ( gridSectionElement ( ) . exists )
}
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
func test_whenSelectingText_thatOnlyExpandableSectionsArePresent ( ) {
mixedDataNavigationBarElement ( ) . buttons [ " Text " ] . tap ( )
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
XCTAssertTrue ( expandableSectionElement ( ) . exists )
XCTAssertFalse ( userSectionElement ( ) . exists )
XCTAssertFalse ( gridSectionElement ( ) . exists )
}
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
func test_whenSelectingUsers_thatOnlyUserSectionsArePresent ( ) {
mixedDataNavigationBarElement ( ) . buttons [ " Users " ] . tap ( )
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
XCTAssertFalse ( expandableSectionElement ( ) . exists )
XCTAssertTrue ( userSectionElement ( ) . exists )
XCTAssertFalse ( gridSectionElement ( ) . exists )
}
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
func test_whenExpandingExpandableSection_thatHeightIsIncreased ( ) {
mixedDataNavigationBarElement ( ) . buttons [ " Text " ] . tap ( )
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
let expandableSection = expandableSectionElement ( )
let collapsedFrame = expandableSection . frame
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
// E x p a n d
expandableSection . tap ( )
let expandedFrame = expandableSection . frame
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
XCTAssertTrue ( expandedFrame . size . height > collapsedFrame . size . height )
}
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
func test_whenCollapsingExpandableSection_thatHeightIsDecreased ( ) {
mixedDataNavigationBarElement ( ) . buttons [ " Text " ] . tap ( )
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
let expandableSection = expandableSectionElement ( )
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
// E x p a n d
expandableSection . tap ( )
let expandedFrame = expandableSection . frame
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
// C o l l a p s e
expandableSection . tap ( )
let collapsedFrame = expandableSection . frame
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
XCTAssertTrue ( collapsedFrame . size . height < expandedFrame . size . height )
}
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
private func expandableSectionElement ( ) -> XCUIElement {
2016-12-07 14:28:29 +00:00
return XCUIApplication ( ) . collectionViews . cells . staticTexts [ " Maecenas faucibus mollis interdum. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. " ]
2016-12-01 18:28:57 +00:00
}
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
private func userSectionElement ( ) -> XCUIElement {
2016-12-07 14:28:29 +00:00
return XCUIApplication ( ) . collectionViews . cells . staticTexts [ " @ryanolsonk " ]
2016-12-01 18:28:57 +00:00
}
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
private func gridSectionElement ( ) -> XCUIElement {
2016-12-07 14:28:29 +00:00
return XCUIApplication ( ) . collectionViews . cells . staticTexts [ " 1 " ]
2016-12-01 18:28:57 +00:00
}
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
private func mixedDataNavigationBarElement ( ) -> XCUIElement {
2016-12-07 14:28:29 +00:00
return XCUIApplication ( ) . navigationBars [ " Mixed Data " ]
2016-12-01 18:28:57 +00:00
}
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
private func enterMixedDataDetailScreen ( ) {
2016-12-07 14:28:29 +00:00
XCUIApplication ( ) . collectionViews . cells . staticTexts [ " Mixed Data " ] . tap ( )
2016-12-01 18:28:57 +00:00
}
2017-05-16 14:30:08 +00:00
2016-12-01 18:28:57 +00:00
}