Commit 773b500c authored by Mike JS. Choi's avatar Mike JS. Choi

[fastlane] Seperate screenshot code from testing code

Fixed bugs regarding change of localization during screenshoting
parent 7e6593d8
/*****************************************************************************
* Screenshot.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
class Screenshot: XCTestCase {
let app = XCUIApplication()
var helper: TestHelper!
override func setUp() {
super.setUp()
XCUIDevice.shared.orientation = .portrait
SDStatusBarManager.sharedInstance().enableOverrides()
setupSnapshot(app)
helper = TestHelper(lang: deviceLanguage, target: VLCiOSTestMenu.self)
app.launch()
}
override func tearDown() {
SDStatusBarManager.sharedInstance().disableOverrides()
}
func testCaptureVideoPlayback() {
download(name: "http://jell.yfish.us/media/jellyfish-10-mbps-hd-h264.mkv")
helper.tap(tabDescription: "Video", app: app)
app.collectionViews.cells.element(boundBy: 0).tap()
app.navigationBars["VLCMovieView"].buttons[helper.localized(key: "VIDEO_ASPECT_RATIO_BUTTON")].tap()
snapshot("playback")
}
func testCaptureAudioTab() {
let audio = helper.localized(key: "AUDIO")
helper.tap(tabDescription: audio, app: app)
snapshot("audio_tab")
}
func testCaptureNetworkTab() {
let localNetwork = helper.localized(key: "LOCAL_NETWORK")
helper.tap(tabDescription: localNetwork, app: app)
snapshot("network_tab")
}
func testCaptureVideoTab() {
helper.tap(tabDescription: "Video", app: app)
snapshot("video_tab")
}
func download(name fileName: String) {
let download = helper.localized(key: "DOWNLOAD_FROM_HTTP")
helper.tap(tabDescription: download, app: app)
let downloadTextfield = app.textFields["http://myserver.com/file.mkv"]
downloadTextfield.clearAndEnter(text: fileName)
app.buttons[helper.localized(key: "BUTTON_DOWNLOAD")].tap()
let cancelDownloadButton = app.buttons["flatDeleteButton"]
let predicate = NSPredicate(format: "exists == 0")
expectation(for: predicate, evaluatedWith: cancelDownloadButton, handler: nil)
waitForExpectations(timeout: 20.0) { err in
XCTAssertNil(err)
downloadTextfield.typeText("\n")
}
}
}
......@@ -15,15 +15,13 @@ import XCTest
struct TestHelper {
let localizationBundle: Bundle
let inherantBundle = Bundle(for: UIApplication.self)
init(lang: String, target: AnyClass) {
localizationBundle = TestHelper.loadLocalizables(lang: lang, target: target)
}
func localized(key: String) -> String {
let res = NSLocalizedString(key, bundle: localizationBundle, comment: "")
return res
return NSLocalizedString(key, bundle: localizationBundle, comment: "")
}
func tap(tabDescription: String, app: XCUIApplication) {
......@@ -41,12 +39,6 @@ struct TestHelper {
}
extension TestHelper {
static func prepare(_ app: XCUIApplication) {
XCUIDevice.shared.orientation = .portrait
SDStatusBarManager.sharedInstance().enableOverrides()
setupSnapshot(app)
}
static func loadLocalizables(lang: String, target: AnyClass) -> Bundle {
let mainBundle = Bundle(for: target.self)
guard let path = mainBundle.path(forResource: lang, ofType: ".lproj") else {
......
......@@ -20,36 +20,27 @@ class VLCiOSTestMenu: XCTestCase {
override func setUp() {
super.setUp()
TestHelper.prepare(app)
XCUIDevice.shared.orientation = .portrait
setupSnapshot(app)
helper = TestHelper(lang: deviceLanguage, target: VLCiOSTestMenu.self)
app.launch()
}
override func tearDown() {
SDStatusBarManager.sharedInstance().disableOverrides()
}
func testNavigationToAudioTab() {
let audio = helper.localized(key: "AUDIO")
helper.tap(tabDescription: audio, app: app)
XCTAssertNotNil(app.navigationBars[audio])
snapshot("audio_tab")
}
func testNavigationToNetworkTab() {
let localNetwork = helper.localized(key: "LOCAL_NETWORK")
helper.tap(tabDescription: localNetwork, app: app)
XCTAssertNotNil(app.navigationBars[localNetwork])
snapshot("network_tab")
}
func testNavigationToVideoTab() {
helper.tap(tabDescription: "Video", app: app)
XCTAssertNotNil(app.navigationBars["Video"])
snapshot("video_tab")
}
func testNavigationToSettingsTab() {
......
......@@ -20,23 +20,12 @@ class VLCiOSTestVideoCodecs: XCTestCase {
override func setUp() {
super.setUp()
TestHelper.prepare(app)
XCUIDevice.shared.orientation = .portrait
setupSnapshot(app)
helper = TestHelper(lang: deviceLanguage, target: VLCiOSTestVideoCodecs.self)
setupSnapshot(app)
app.launch()
}
override func tearDown() {
SDStatusBarManager.sharedInstance().disableOverrides()
}
func testDownload() {
download(name: "http://jell.yfish.us/media/jellyfish-10-mbps-hd-h264.mkv")
helper.tap(tabDescription: "Video", app: app)
app.collectionViews.cells.element(boundBy: 0).tap()
app.navigationBars["VLCMovieView"].buttons[helper.localized(key: "VIDEO_ASPECT_RATIO_BUTTON")].tap()
snapshot("playback")
}
func testMovCodec() {
stream(named: "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov")
......@@ -54,24 +43,6 @@ class VLCiOSTestVideoCodecs: XCTestCase {
stream(named: "http://jell.yfish.us/media/jellyfish-25-mbps-hd-h264.mkv")
}
func download(name fileName: String) {
let download = helper.localized(key: "DOWNLOAD_FROM_HTTP")
helper.tap(tabDescription: download, app: app)
let downloadTextfield = app.textFields["http://myserver.com/file.mkv"]
downloadTextfield.clearAndEnter(text: fileName)
app.buttons[helper.localized(key: "BUTTON_DOWNLOAD")].tap()
let cancelDownloadButton = app.buttons["flatDeleteButton"]
let predicate = NSPredicate(format: "exists == 0")
expectation(for: predicate, evaluatedWith: cancelDownloadButton, handler: nil)
waitForExpectations(timeout: 20.0) { err in
XCTAssertNil(err)
downloadTextfield.typeText("\n")
}
}
func stream(named fileName: String) {
let stream = helper.localized(key: "OPEN_NETWORK")
helper.tap(tabDescription: stream, app: app)
......
......@@ -246,11 +246,12 @@
A79246C8170F11DF0036AAF2 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A79246C6170F11DF0036AAF2 /* Localizable.strings */; };
C91ABE4F469FB899168F35C0 /* libPods-VLC for iOSUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 260624EB5BF9F1FBE58BF816 /* libPods-VLC for iOSUITests.a */; };
CAA0B0ED2072651000B9274E /* VLCiOSTestMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF76D8F20709C4100E2AD7B /* VLCiOSTestMenu.swift */; };
CAA0B0EE2072651500B9274E /* SnapshotHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF76D8D20709BE400E2AD7B /* SnapshotHelper.swift */; };
CAA0B0EF2072651800B9274E /* VLCiOSTestVideoCodecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF76D9120709C7000E2AD7B /* VLCiOSTestVideoCodecs.swift */; };
CAA0B0F02072651A00B9274E /* XCUIElement+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF76D9320709C9500E2AD7B /* XCUIElement+Helpers.swift */; };
CAA0B0F52072686E00B9274E /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A79246C6170F11DF0036AAF2 /* Localizable.strings */; };
CAA0B0F720726A0E00B9274E /* TestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAA0B0F620726A0E00B9274E /* TestHelper.swift */; };
CAD925792075536300F88496 /* Screenshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAD925782075536300F88496 /* Screenshot.swift */; };
CAD925812075613200F88496 /* SnapshotHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAD925802075613100F88496 /* SnapshotHelper.swift */; };
CAF76D9520709CDE00E2AD7B /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A79246C6170F11DF0036AAF2 /* Localizable.strings */; };
CC1BBC461704938300A20CBF /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CC1BBC451704938300A20CBF /* libiconv.dylib */; };
CC1BBC4C1704939B00A20CBF /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CC1BBC4B1704939B00A20CBF /* libsqlite3.dylib */; };
......@@ -955,7 +956,8 @@
C6872E7B396534F3DAF4E48F /* Pods-VLC-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-VLC-iOS/Pods-VLC-iOS.release.xcconfig"; sourceTree = "<group>"; };
CA6FB8222074601900FC9BF2 /* VLC-iOSUITest-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "VLC-iOSUITest-Bridging-Header.h"; sourceTree = "<group>"; };
CAA0B0F620726A0E00B9274E /* TestHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestHelper.swift; sourceTree = "<group>"; };
CAF76D8D20709BE400E2AD7B /* SnapshotHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SnapshotHelper.swift; path = fastlane/SnapshotHelper.swift; sourceTree = SOURCE_ROOT; };
CAD925782075536300F88496 /* Screenshot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Screenshot.swift; sourceTree = "<group>"; };
CAD925802075613100F88496 /* SnapshotHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SnapshotHelper.swift; path = fastlane/SnapshotHelper.swift; sourceTree = SOURCE_ROOT; };
CAF76D8F20709C4100E2AD7B /* VLCiOSTestMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLCiOSTestMenu.swift; sourceTree = "<group>"; };
CAF76D9120709C7000E2AD7B /* VLCiOSTestVideoCodecs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLCiOSTestVideoCodecs.swift; sourceTree = "<group>"; };
CAF76D9320709C9500E2AD7B /* XCUIElement+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCUIElement+Helpers.swift"; sourceTree = "<group>"; };
......@@ -1248,8 +1250,9 @@
41B0BC871F73ED7D0063BA26 /* VLC for iOSUITests */ = {
isa = PBXGroup;
children = (
CAD925782075536300F88496 /* Screenshot.swift */,
CAD925802075613100F88496 /* SnapshotHelper.swift */,
41B0BC8A1F73ED7D0063BA26 /* Info.plist */,
CAF76D8D20709BE400E2AD7B /* SnapshotHelper.swift */,
CAF76D8F20709C4100E2AD7B /* VLCiOSTestMenu.swift */,
CAF76D9120709C7000E2AD7B /* VLCiOSTestVideoCodecs.swift */,
CAA0B0F620726A0E00B9274E /* TestHelper.swift */,
......@@ -3027,33 +3030,6 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-VLC-iOS-VLC for iOSUITests/Pods-VLC-iOS-VLC for iOSUITests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
E83630DE168FA377CB2B8C84 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
4187112B1F78F87200317B1A /* VLC_for_iOSTestVideoCodecs.m in Sources */,
41B0BC931F73EF1B0063BA26 /* VLC_for_IOSTestMenu.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
F7403765A53B71CD3E9EF429 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-VLC-watchOS-Extension-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
......@@ -3062,10 +3038,11 @@
buildActionMask = 2147483647;
files = (
CAA0B0F720726A0E00B9274E /* TestHelper.swift in Sources */,
CAD925792075536300F88496 /* Screenshot.swift in Sources */,
CAA0B0EF2072651800B9274E /* VLCiOSTestVideoCodecs.swift in Sources */,
CAA0B0F02072651A00B9274E /* XCUIElement+Helpers.swift in Sources */,
CAA0B0ED2072651000B9274E /* VLCiOSTestMenu.swift in Sources */,
CAA0B0EE2072651500B9274E /* SnapshotHelper.swift in Sources */,
CAD925812075613200F88496 /* SnapshotHelper.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -3431,7 +3408,6 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
......@@ -3481,7 +3457,6 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
......@@ -3532,7 +3507,6 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
......
scheme("VLC for iOSUITests")
devices([
"iPhone 5s",
"iPhone 6",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment