BaseUIXCTestCase.swift 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // BaseUIXCTestCase.swift
  3. // NextcloudUITests
  4. //
  5. // Created by Milen on 20.06.23.
  6. // Copyright © 2023 Marino Faggiana. All rights reserved.
  7. //
  8. // This program is free software: you can redistribute it and/or modify
  9. // it under the terms of the GNU General Public License as published by
  10. // the Free Software Foundation, either version 3 of the License, or
  11. // (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. //
  21. import XCTest
  22. class BaseUIXCTestCase: XCTestCase {
  23. let timeoutSeconds: Double = 100
  24. override final class var runsForEachTargetApplicationUIConfiguration: Bool {
  25. false
  26. }
  27. internal func waitForEnabled(object: Any?) {
  28. let predicate = NSPredicate(format: "enabled == true")
  29. expectation(for: predicate, evaluatedWith: object, handler: nil)
  30. waitForExpectations(timeout: timeoutSeconds, handler: nil)
  31. }
  32. internal func waitForHittable(object: Any?) {
  33. let predicate = NSPredicate(format: "hittable == true")
  34. expectation(for: predicate, evaluatedWith: object, handler: nil)
  35. waitForExpectations(timeout: timeoutSeconds, handler: nil)
  36. }
  37. internal func waitForEnabledAndHittable(object: Any?) {
  38. waitForEnabled(object: object)
  39. waitForHittable(object: object)
  40. }
  41. }