MakeScreenshots.swift 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2019-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  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 Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. import XCTest
  21. class MakeScreenshots: XCTestCase {
  22. var language: String = ""
  23. var theme: String = "light"
  24. var version: String = "4.6.3"
  25. var orientation: String = ""
  26. var screenshotNameStart: String = ""
  27. var screenshotNameEnd: String = ""
  28. var app: XCUIApplication?
  29. var isWorkApp: Bool = false
  30. override func setUp() {
  31. // Put setup code here. This method is called before the invocation of each test method in the class.
  32. if UIDevice.current.userInterfaceIdiom == .pad {
  33. orientation = "landscape"
  34. XCUIDevice.shared.orientation = .landscapeLeft
  35. } else {
  36. orientation = "portrait"
  37. XCUIDevice.shared.orientation = .portrait
  38. }
  39. // In UI tests it is usually best to stop immediately when a failure occurs.
  40. continueAfterFailure = false
  41. // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
  42. app = XCUIApplication()
  43. Snapshot.setupSnapshot(app!, waitForAnimations: true)
  44. language = Snapshot.getLanguage()
  45. app!.launch()
  46. // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
  47. if let tmpTheme = argValueForKey(key: "-theme", app: app!) {
  48. theme = tmpTheme
  49. }
  50. if let tmpVersion = argValueForKey(key: "-version", app: app!) {
  51. version = tmpVersion
  52. }
  53. var ios: String = "ios-"
  54. ios.append(ProcessInfo().environment["SIMULATOR_DEVICE_NAME"]!)
  55. // add os, device, appversion, locale, theme
  56. var lang = language
  57. lang = lang.replacingOccurrences(of: "-", with: "_")
  58. screenshotNameStart = "\(ios)-\(version)-\(lang)"
  59. screenshotNameEnd = "\(theme)-\(orientation)"
  60. if #available(iOS 13.0, *) {
  61. }
  62. else {
  63. SDStatusBarManager.sharedInstance().carrierName = "3ma"
  64. SDStatusBarManager.sharedInstance().timeString = "08:15"
  65. SDStatusBarManager.sharedInstance().bluetoothState = .hidden
  66. SDStatusBarManager.sharedInstance().batteryDetailEnabled = true
  67. SDStatusBarManager.sharedInstance().enableOverrides()
  68. }
  69. addUIInterruptionMonitor(withDescription: "System Dialog") { (alert) -> Bool in
  70. let btnAllow: XCUIElement
  71. let btnAllowAlways: XCUIElement
  72. let btnAllowAll: XCUIElement
  73. let btnOK: XCUIElement
  74. let cancelButton: XCUIElement
  75. btnAllow = alert.buttons[self.allowButtonText()]
  76. btnAllowAlways = alert.buttons[self.alwaysAllowButtonText()]
  77. btnAllowAll = alert.buttons[self.allowAllButtonText()]
  78. btnOK = alert.buttons[self.okButtonText()]
  79. cancelButton = alert.buttons[self.cancelButtonText()]
  80. if cancelButton.exists {
  81. cancelButton.tap()
  82. return true
  83. }
  84. if btnAllow.exists {
  85. btnAllow.tap()
  86. return true
  87. }
  88. if btnAllowAlways.exists {
  89. btnAllowAlways.tap()
  90. return true
  91. }
  92. if btnAllowAll.exists {
  93. btnAllowAll.tap()
  94. return true
  95. }
  96. if btnOK.exists {
  97. btnOK.tap()
  98. return true
  99. }
  100. return true
  101. }
  102. }
  103. override func tearDown() {
  104. // Put teardown code here. This method is called after the invocation of each test method in the class.
  105. if #available(iOS 13.0, *) {
  106. }
  107. else {
  108. SDStatusBarManager.sharedInstance().disableOverrides()
  109. }
  110. }
  111. func testMakeScreenshots() {
  112. app = XCUIApplication()
  113. if Bundle.main.bundleIdentifier == "ch.threema.ScreenshotsWithDataWork.xctrunner" {
  114. isWorkApp = true
  115. // theme = "dark"
  116. // screenshotNameEnd = "\(theme)-\(orientation)"
  117. }
  118. // MARK: Enter license key
  119. if isWorkApp && app!.textFields.count > 0 {
  120. let login = workLogin()
  121. app!.textFields["licenseUsername"].typeText(login!["username"]!)
  122. if app!.keys.allElementsBoundByIndex[0].exists {
  123. app!.typeText("\n")
  124. }
  125. app!.secureTextFields["licensePassword"].typeText(login!["password"]!)
  126. app!.buttons["ConfirmButton"].tap()
  127. sleep(5)
  128. }
  129. let contactTabBarItem = app!.tabBars.buttons.element(boundBy: 0)
  130. let messagesTabBarItem = app!.tabBars.buttons.element(boundBy: 1)
  131. // switch tabs that fastlane will close all alerts before it will take the first screenshot
  132. contactTabBarItem.tap()
  133. messagesTabBarItem.tap()
  134. if UIDevice.current.userInterfaceIdiom == .pad {
  135. if isWorkApp == true {
  136. workScreenshotsForIpads()
  137. } else {
  138. screenshotsForIpads()
  139. }
  140. } else {
  141. if isWorkApp == true {
  142. workScreenshotsForIphones()
  143. } else {
  144. screenshotsForIphones()
  145. }
  146. }
  147. }
  148. private func workLogin() -> [String: String]? {
  149. // get screenshot project directory for work login
  150. guard let srcroot: String = ProcessInfo.processInfo.environment["SRCROOT"] else {
  151. assertionFailure("Can't find environment variable ro SRCROOT")
  152. return nil
  153. }
  154. let screenshotProject = "screenshot/dataWork"
  155. let screenshotPath = srcroot.replacingOccurrences(of: "ios-client", with: screenshotProject)
  156. let bundle = Bundle(path: screenshotPath)
  157. let loginJsonPath = bundle?.path(forResource: "login.json", ofType: nil)
  158. let fileManager = FileManager.default
  159. guard fileManager.fileExists(atPath: loginJsonPath!),
  160. let loginJsonData = fileManager.contents(atPath: loginJsonPath!) else {
  161. assertionFailure("Can't find login.json")
  162. return nil
  163. }
  164. do {
  165. return try JSONSerialization.jsonObject(with: loginJsonData, options: []) as? [String : String]
  166. } catch {
  167. assertionFailure("Can't create jsonObject from login.json")
  168. return nil
  169. }
  170. }
  171. private func screenshotsForIphones() {
  172. let contactTabBarItem = app!.tabBars.buttons.element(boundBy: 0)
  173. let messagesTabBarItem = app!.tabBars.buttons.element(boundBy: 1)
  174. let myIdTabBarItem = app!.tabBars.buttons.element(boundBy: 2)
  175. // switch tabs that fastlane will close all alerts before it will take the first screenshot
  176. contactTabBarItem.tap()
  177. messagesTabBarItem.tap()
  178. // MARK: Screenshot 1: conversations
  179. Snapshot.snapshot(screenshotName("01", "conversations"))
  180. // Switch to Contacts
  181. contactTabBarItem.tap()
  182. // MARK: Screenshot 2: contacts
  183. Snapshot.snapshot(screenshotName("02", "contacts"))
  184. // Switch to Chtas
  185. messagesTabBarItem.tap()
  186. // open chat of hanna schmidt
  187. app!.tables.cells.element(boundBy: 0).tap()
  188. // MARK: Screenshot 3: single_chat
  189. Snapshot.snapshot(screenshotName("03", "single_chat"))
  190. // tap plus icon
  191. app!.buttons["PlusButton"].tap()
  192. // MARK: Screenshot 4: single_chat_attachments
  193. Snapshot.snapshot(screenshotName("04", "single_chat_attachments"))
  194. // leave plus icon
  195. app!.cells["Cancel"].tap()
  196. // leave single chat --> chat overview
  197. app!.navigationBars.buttons.element(boundBy: 0).tap()
  198. // open chat of lisa goldman
  199. app!.tables.cells.element(boundBy: 4).tap()
  200. // swipe down to show the header
  201. app!.swipeDown()
  202. // open call view
  203. app!.buttons["CallButton"].tap()
  204. // MARK: Screenshot 5: threema_call
  205. Snapshot.snapshot(screenshotName("05", "threema_call_incoming"))
  206. // tap hide button to change ui to connected call
  207. app!.buttons["HideButton"].tap()
  208. // MARK: Screenshot 6: threema_call
  209. Snapshot.snapshot(screenshotName("06", "threema_call"))
  210. // close call view
  211. app!.buttons["EndButton"].tap()
  212. // leave single chat --> chat overview
  213. app!.navigationBars.buttons.element(boundBy: 0).tap()
  214. // open chat from roberto dias
  215. app!.tables.cells.element(boundBy: 3).tap()
  216. // swipe down to show the header
  217. app!.swipeDown()
  218. // open call view
  219. app!.buttons["CallButton"].tap()
  220. // tap hide button to change ui to connected call
  221. app!.buttons["HideButton"].tap()
  222. // tap camera button to change ui to video call
  223. app!.buttons["VideoButton"].tap()
  224. // MARK: Screenshot 7: threema_video_call
  225. Snapshot.snapshot(screenshotName("07", "threema_video_call"))
  226. // close call view
  227. app!.buttons["EndButton"].tap()
  228. // leave single chat --> chat overview
  229. app!.navigationBars.buttons.element(boundBy: 0).tap()
  230. // open group chat
  231. app!.tables.cells.element(boundBy: 1).tap()
  232. // MARK: Screenshot 8: group_chat
  233. Snapshot.snapshot(screenshotName("08", "group_chat"))
  234. // swipe down to show the header
  235. app!.swipeDown()
  236. // show group detail
  237. app!.scrollViews["GroupImageView"].tap()
  238. // MARK: Screenshot 9: group_detail
  239. Snapshot.snapshot(screenshotName("09", "group_detail"))
  240. // leave group detail --> group chat
  241. app!.navigationBars.buttons.element(boundBy: 0).tap()
  242. // swipe down to show the header
  243. app!.swipeDown()
  244. // open ballot view
  245. app!.buttons["BallotButton"].tap()
  246. // select closed ballot
  247. app!.cells.element(boundBy: 0).tap()
  248. // MARK: Screenshot 10: ballot_matrix
  249. Snapshot.snapshot(screenshotName("10", "ballot_matrix"))
  250. // leave ballot --> ballot overview
  251. app!.navigationBars.buttons.element(boundBy: 0).tap()
  252. // ballot overview --> group chat
  253. app!.navigationBars.buttons.element(boundBy: 0).tap()
  254. // group chat --> conversation overview
  255. app!.navigationBars.buttons.element(boundBy: 0).tap()
  256. contactTabBarItem.tap()
  257. // show detail of Schmidt Hanna
  258. app!.cells.element(boundBy: indexOfHannaSchmidt()).tap()
  259. // MARK: Screenshot 11: contact_detail
  260. Snapshot.snapshot(screenshotName("11", "contact_detail"))
  261. // contact detail --> contact overview
  262. app!.navigationBars.buttons.element(boundBy: 0).tap()
  263. // show my id tab
  264. myIdTabBarItem.tap()
  265. // MARK: Screenshot 12: my_id
  266. Snapshot.snapshot(screenshotName("12", "my_id"))
  267. //MARK: Show qr code
  268. app?.buttons["qrCodeButton"].tap()
  269. // MARK: Screenshot 13: qr_code
  270. Snapshot.snapshot(screenshotName("13", "qr_code"))
  271. // MARK: Dismiss qr code
  272. app?.otherElements["CoverView"].tap()
  273. // show threema safe
  274. app!.cells["SafeCell"].tap()
  275. // MARK: Screenshot 14: threema_safe
  276. Snapshot.snapshot(screenshotName("14", "threema_safe"))
  277. }
  278. private func screenshotsForIpads() {
  279. let contactTabBarItem = app!.tabBars.buttons.element(boundBy: 0)
  280. let messagesTabBarItem = app!.tabBars.buttons.element(boundBy: 1)
  281. let myIdTabBarItem = app!.tabBars.buttons.element(boundBy: 2)
  282. // switch tabs that fastlane will close all alerts before it will take the first screenshot
  283. contactTabBarItem.tap()
  284. messagesTabBarItem.tap()
  285. // MARK: Screenshot 1: conversations
  286. Snapshot.snapshot(screenshotName("01", "conversations"))
  287. // Switch to Contacts
  288. contactTabBarItem.tap()
  289. // MARK: Screenshot 2: contacts
  290. Snapshot.snapshot(screenshotName("02", "contacts"))
  291. // Switch to Chtas
  292. messagesTabBarItem.tap()
  293. // open chat of hanna schmidt
  294. app!.tables.cells.element(boundBy: 0).tap()
  295. // MARK: Screenshot 3: single_chat
  296. Snapshot.snapshot(screenshotName("03", "single_chat"))
  297. // tap plus icon
  298. app!.tap()
  299. // MARK: Screenshot 4: single_chat_attachments
  300. Snapshot.snapshot(screenshotName("04", "single_chat_attachments"))
  301. // leave plus icon
  302. app!.cells["Cancel"].tap()
  303. // open chat of lisa goldman
  304. app!.tables.cells.element(boundBy: 4).tap()
  305. // swipe down to show the header
  306. app!.swipeDown()
  307. // open call view
  308. app!.buttons["CallButton"].tap()
  309. // MARK: Screenshot 5: threema_call
  310. Snapshot.snapshot(screenshotName("05", "threema_call_incoming"))
  311. // tap hide button to change ui to connected call
  312. app!.buttons["HideButton"].tap()
  313. // MARK: Screenshot 6: threema_call
  314. Snapshot.snapshot(screenshotName("06", "threema_call"))
  315. // close call view
  316. app!.buttons["EndButton"].tap()
  317. // open chat from roberto dias
  318. app!.tables.cells.element(boundBy: 3).tap()
  319. // swipe down to show the header
  320. app!.swipeDown()
  321. // open call view
  322. app!.buttons["CallButton"].tap()
  323. // tap hide button to change ui to connected call
  324. app!.buttons["HideButton"].tap()
  325. // tap camera button to change ui to video call
  326. app!.buttons["VideoButton"].tap()
  327. // MARK: Screenshot 7: threema_video_call
  328. Snapshot.snapshot(screenshotName("07", "threema_video_call"))
  329. // close call view
  330. app!.buttons["EndButton"].tap()
  331. // open group chat
  332. app!.tables.cells.element(boundBy: 1).tap()
  333. // MARK: Screenshot 8: group_chat
  334. Snapshot.snapshot(screenshotName("08", "group_chat"))
  335. // swipe down to show the header
  336. app!.swipeDown()
  337. // show group detail
  338. app!.scrollViews["GroupImageView"].tap()
  339. // MARK: Screenshot 9: group_detail
  340. Snapshot.snapshot(screenshotName("09", "group_detail"))
  341. // leave group detail --> group chat
  342. app!.navigationBars.element(boundBy: 1).buttons.element(boundBy: 0).tap()
  343. // swipe down to show the header
  344. app!.swipeDown()
  345. // open ballot view
  346. app!.buttons["BallotButton"].tap()
  347. // select closed ballot
  348. app!.tables.element(boundBy: 1).cells.element(boundBy: 0).tap()
  349. // MARK: Screenshot 10: ballot_matrix
  350. Snapshot.snapshot(screenshotName("10", "ballot_matrix"))
  351. // leave ballot --> ballot overview
  352. app!.navigationBars.element(boundBy: 1).buttons.element(boundBy: 0).tap()
  353. // ballot overview --> group chat
  354. app!.navigationBars.element(boundBy: 1).buttons.element(boundBy: 0).tap()
  355. // show contact tab
  356. contactTabBarItem.tap()
  357. // show detail of Schmidt Hanna
  358. app!.tables.element(boundBy: 0).cells.element(boundBy: indexOfHannaSchmidt()).tap()
  359. // MARK: Screenshot 11: contact_detail
  360. Snapshot.snapshot(screenshotName("11", "contact_detail"))
  361. // show my id tab
  362. myIdTabBarItem.tap()
  363. // MARK: Screenshot 12: my_id
  364. Snapshot.snapshot(screenshotName("12", "my_id"))
  365. //MARK: Show qr code
  366. app?.buttons["qrCodeButton"].tap()
  367. // MARK: Screenshot 13: qr_code
  368. Snapshot.snapshot(screenshotName("13", "qr_code"))
  369. // MARK: Dismiss qr code
  370. app?.otherElements["CoverView"].tap()
  371. // show threema safe
  372. app!.cells["SafeCell"].tap()
  373. // MARK: Screenshot 14: threema_safe
  374. Snapshot.snapshot(screenshotName("14", "threema_safe"))
  375. }
  376. private func workScreenshotsForIphones() {
  377. let contactTabBarItem = app!.tabBars.buttons.element(boundBy: 0)
  378. let messagesTabBarItem = app!.tabBars.buttons.element(boundBy: 1)
  379. let myIdTabBarItem = app!.tabBars.buttons.element(boundBy: 2)
  380. // switch tabs that fastlane will close all alerts before it will take the first screenshot
  381. contactTabBarItem.tap()
  382. messagesTabBarItem.tap()
  383. // MARK: Screenshot 1: conversations
  384. Snapshot.snapshot(screenshotName("01", "conversations"))
  385. // Switch to Contacts
  386. contactTabBarItem.tap()
  387. // MARK: Screenshot 2: contacts
  388. Snapshot.snapshot(screenshotName("02", "contacts"))
  389. // Switch to Chtas
  390. messagesTabBarItem.tap()
  391. // open chat of peter schreiner
  392. app!.tables.cells.element(boundBy: 0).tap()
  393. // MARK: Screenshot 3: single_chat
  394. Snapshot.snapshot(screenshotName("03", "single_chat"))
  395. // tap plus icon
  396. app!/*@START_MENU_TOKEN@*/.buttons["PlusButton"]/*[[".images",".buttons[\"Send media or location\"]",".buttons[\"PlusButton\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/.tap()
  397. // MARK: Screenshot 4: single_chat_attachments
  398. Snapshot.snapshot(screenshotName("04", "single_chat_attachments"))
  399. // leave plus icon
  400. app!.cells["Cancel"].tap()
  401. // swipe down to show the header
  402. app!.swipeDown()
  403. // open call view
  404. app!.buttons["CallButton"].tap()
  405. // MARK: Screenshot 5: threema_call
  406. Snapshot.snapshot(screenshotName("05", "threema_call_incoming"))
  407. // tap hide button to change ui to connected call
  408. app!.buttons["HideButton"].tap()
  409. // MARK: Screenshot 6: threema_call
  410. Snapshot.snapshot(screenshotName("06", "threema_call"))
  411. // tap camera button to change ui to video call
  412. app!.buttons["VideoButton"].tap()
  413. // MARK: Screenshot 7: threema_video_call
  414. Snapshot.snapshot(screenshotName("07", "threema_video_call"))
  415. // close call view
  416. app!.buttons["EndButton"].tap()
  417. // leave single chat --> chat overview
  418. app!.navigationBars.buttons.element(boundBy: 0).tap()
  419. // open group chat
  420. app!.tables.cells.element(boundBy: 2).tap()
  421. // MARK: Screenshot 8: group_chat
  422. Snapshot.snapshot(screenshotName("08", "group_chat"))
  423. // swipe down to show the header
  424. app!.swipeDown()
  425. // show group detail
  426. app!.scrollViews["GroupImageView"].tap()
  427. // MARK: Screenshot 9: group_detail
  428. Snapshot.snapshot(screenshotName("09", "group_detail"))
  429. // leave group detail --> group chat
  430. app!.navigationBars.buttons.element(boundBy: 0).tap()
  431. // swipe down to show the header
  432. app!.swipeDown()
  433. // open ballot view
  434. app!.buttons["BallotButton"].tap()
  435. // select closed ballot
  436. app!.cells.element(boundBy: 0).tap()
  437. // MARK: Screenshot 10: ballot_matrix
  438. Snapshot.snapshot(screenshotName("10", "ballot_matrix"))
  439. // leave ballot --> ballot overview
  440. app!.navigationBars.buttons.element(boundBy: 0).tap()
  441. // ballot overview --> group chat
  442. app!.navigationBars.buttons.element(boundBy: 0).tap()
  443. // group chat --> conversation overview
  444. app!.navigationBars.buttons.element(boundBy: 0).tap()
  445. contactTabBarItem.tap()
  446. // tap contacts on segment control
  447. if app!.navigationBars.element(boundBy: 0).buttons["Work"].exists {
  448. app!.navigationBars.element(boundBy: 0).buttons["Work"].tap()
  449. } else {
  450. if app!.navigationBars.element(boundBy: 0).buttons["Case"].exists {
  451. app!.navigationBars.element(boundBy: 0).buttons["Case"].tap()
  452. }
  453. }
  454. // show detail of peter schreiner
  455. app!.cells.element(boundBy: indexOfPeterSchreiner()).tap()
  456. // MARK: Screenshot 11: contact_detail
  457. Snapshot.snapshot(screenshotName("11", "contact_detail"))
  458. // contact detail --> contact overview
  459. app!.navigationBars.buttons.element(boundBy: 0).tap()
  460. // show my id tab
  461. myIdTabBarItem.tap()
  462. // MARK: Screenshot 12: my_id
  463. Snapshot.snapshot(screenshotName("12", "my_id"))
  464. //MARK: Show qr code
  465. app?.buttons["qrCodeButton"].tap()
  466. // MARK: Screenshot 13: qr_code
  467. Snapshot.snapshot(screenshotName("13", "qr_code"))
  468. // MARK: Dismiss qr code
  469. app?.otherElements["CoverView"].tap()
  470. // show threema safe
  471. app!.cells["SafeCell"].tap()
  472. // MARK: Screenshot 14: threema_safe
  473. Snapshot.snapshot(screenshotName("14", "threema_safe"))
  474. }
  475. private func workScreenshotsForIpads() {
  476. let contactTabBarItem = app!.tabBars.buttons.element(boundBy: 0)
  477. let messagesTabBarItem = app!.tabBars.buttons.element(boundBy: 1)
  478. let myIdTabBarItem = app!.tabBars.buttons.element(boundBy: 2)
  479. // switch tabs that fastlane will close all alerts before it will take the first screenshot
  480. contactTabBarItem.tap()
  481. messagesTabBarItem.tap()
  482. // MARK: Screenshot 1: conversations
  483. Snapshot.snapshot(screenshotName("01", "conversations"))
  484. // Switch to Contacts
  485. contactTabBarItem.tap()
  486. // MARK: Screenshot 2: contacts
  487. Snapshot.snapshot(screenshotName("02", "contacts"))
  488. // Switch to Chtas
  489. messagesTabBarItem.tap()
  490. // open chat of peter schreiner
  491. app!.tables.cells.element(boundBy: 0).tap()
  492. // MARK: Screenshot 3: single_chat
  493. Snapshot.snapshot(screenshotName("03", "single_chat"))
  494. // tap plus icon
  495. app!/*@START_MENU_TOKEN@*/.buttons["PlusButton"]/*[[".images",".buttons[\"Send media or location\"]",".buttons[\"PlusButton\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/.tap()
  496. // MARK: Screenshot 4: single_chat_attachments
  497. Snapshot.snapshot(screenshotName("04", "single_chat_attachments"))
  498. // leave plus icon
  499. app!.cells["Cancel"].tap()
  500. // swipe down to show the header
  501. app!.swipeDown()
  502. // open call view
  503. app!.buttons["CallButton"].tap()
  504. // MARK: Screenshot 5: threema_call_incoming
  505. Snapshot.snapshot(screenshotName("05", "threema_call_incoming"))
  506. // tap hide button to change ui to connected call
  507. app!.buttons["HideButton"].tap()
  508. // MARK: Screenshot 6: threema_call
  509. Snapshot.snapshot(screenshotName("06", "threema_call"))
  510. // tap camera button to change ui to video call
  511. app!.buttons["VideoButton"].tap()
  512. // MARK: Screenshot 7: threema_video_call
  513. Snapshot.snapshot(screenshotName("07", "threema_video_call"))
  514. // close call view
  515. app!.buttons["EndButton"].tap()
  516. // open group chat
  517. app!.tables.cells.element(boundBy: 2).tap()
  518. // MARK: Screenshot 8: group_chat
  519. Snapshot.snapshot(screenshotName("08", "group_chat"))
  520. // swipe down to show the header
  521. app!.swipeDown()
  522. // show group detail
  523. app!.scrollViews["GroupImageView"].tap()
  524. // MARK: Screenshot 9: group_detail
  525. Snapshot.snapshot(screenshotName("09", "group_detail"))
  526. // leave group detail --> group chat
  527. app!.navigationBars.element(boundBy: 1).buttons.element(boundBy: 0).tap()
  528. // swipe down to show the header
  529. app!.swipeDown()
  530. // open ballot view
  531. app!.buttons["BallotButton"].tap()
  532. // select closed ballot
  533. app!.tables.element(boundBy: 1).cells.element(boundBy: 0).tap()
  534. // MARK: Screenshot 10: ballot_matrix
  535. Snapshot.snapshot(screenshotName("10", "ballot_matrix"))
  536. // leave ballot --> ballot overview
  537. app!.navigationBars.element(boundBy: 1).buttons.element(boundBy: 0).tap()
  538. // ballot overview --> group chat
  539. app!.navigationBars.element(boundBy: 1).buttons.element(boundBy: 0).tap()
  540. contactTabBarItem.tap()
  541. // tap contacts on segment control
  542. if app!.navigationBars.element(boundBy: 0).buttons["Work"].exists {
  543. app!.navigationBars.element(boundBy: 0).buttons["Work"].tap()
  544. } else {
  545. if app!.navigationBars.element(boundBy: 0).buttons["Case"].exists {
  546. app!.navigationBars.element(boundBy: 0).buttons["Case"].tap()
  547. }
  548. }
  549. // show detail of peter schreiner
  550. app!.cells.element(boundBy: indexOfPeterSchreiner()).tap()
  551. // MARK: Screenshot 11: contact_detail
  552. Snapshot.snapshot(screenshotName("11", "contact_detail"))
  553. // show my id tab
  554. myIdTabBarItem.tap()
  555. // MARK: Screenshot 12: my_id
  556. Snapshot.snapshot(screenshotName("12", "my_id"))
  557. //MARK: Show qr code
  558. app?.buttons["qrCodeButton"].tap()
  559. // MARK: Screenshot 13: qr_code
  560. Snapshot.snapshot(screenshotName("13", "qr_code"))
  561. // MARK: Dismiss qr code
  562. app?.otherElements["CoverView"].tap()
  563. // show threema safe
  564. app!.cells["SafeCell"].tap()
  565. // MARK: Screenshot 14: threema_safe
  566. Snapshot.snapshot(screenshotName("14", "threema_safe"))
  567. }
  568. private func argValueForKey(key: String, app: XCUIApplication) -> String? {
  569. if let index = app.launchArguments.firstIndex(of: key) {
  570. return app.launchArguments[index+1]
  571. }
  572. return nil
  573. }
  574. private func screenshotName(_ count: String, _ key: String) -> String {
  575. return "\(screenshotNameStart)-\(count)-\(key)-\(screenshotNameEnd)"
  576. }
  577. private func indexOfHannaSchmidt() -> Int {
  578. if language == "ru-RU" || language == "nl-NL" {
  579. return 4
  580. }
  581. else if language == "it-IT" || language == "pt_BR" {
  582. return 0
  583. }
  584. else if language == "fr-FR" {
  585. return 1
  586. }
  587. return 3
  588. }
  589. private func indexOfPeterSchreiner() -> Int {
  590. return 2
  591. }
  592. private func allowButtonText() -> String {
  593. return "Allow"
  594. }
  595. private func alwaysAllowButtonText() -> String {
  596. return "Always Allow"
  597. }
  598. private func allowAllButtonText() -> String {
  599. return "Allow Access to All Photos"
  600. }
  601. private func okButtonText() -> String {
  602. return "OK"
  603. }
  604. private func cancelButtonText() -> String {
  605. return "Cancel"
  606. }
  607. }