123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /*****************************************************************************
- * TestHelper.swift
- * VLC for iOSUITests
- *****************************************************************************
- * Copyright (c) 2018 VideoLAN. All rights reserved.
- * $Id$
- *
- * Authors: Mike JS. Choi <mkchoi212 # icloud.com>
- *
- * Refer to the COPYING file of the official project for license.
- *****************************************************************************/
- import Foundation
- import XCTest
- struct TestHelper {
- let localizationBundle: Bundle
- init(lang: String, target: AnyClass) {
- localizationBundle = TestHelper.loadLocalizables(lang: lang, target: target)
- }
- func localized(key: String) -> String {
- return NSLocalizedString(key, bundle: localizationBundle, comment: "")
- }
-
- func tap(tabDescription: String, app: XCUIApplication) {
- let target = app.tabBars.buttons.element(matching: .button, identifier: tabDescription)
-
- if target.exists {
- target.tap()
- } else if app.tabBars.buttons.count == 5 {
- // 5 tabBar buttons for iPhone
- let moreTab = app.tabBars.buttons.element(boundBy: 4)
- moreTab.tap()
- app.cells.staticTexts[tabDescription].tap()
- }
- }
- }
- extension TestHelper {
- static func loadLocalizables(lang: String, target: AnyClass) -> Bundle {
- let mainBundle = Bundle(for: target.self)
- guard let path = mainBundle.path(forResource: lang, ofType: ".lproj") else {
- XCTFail("Could not resolve localization file for \(lang)")
- return Bundle()
- }
- guard let bundle = Bundle(path: path) else {
- XCTFail("Could not load bundle at \(path)")
- return Bundle()
- }
- return bundle
- }
- }
|