Commit 227814f5 authored by Mike JS. Choi's avatar Mike JS. Choi

[UI] Use accessibilityIdentifier to interact

Note that string literals are being used all over the project to create
identifiers. A new file containing all identifier literals should be
created in the future.
parent 773b500c
# Xcode
*.mode*
*.pbxuser
xcuserdata
*.xccheckout
*.pbxuser
*.mode*
# macOS
.DS_Store
# Fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/test_output
fastlane/report.xml
fastlane/screenshots/*/*.png
fastlane/screenshots/screenshots.html
fastlane/test_output
# CocoaPods
Pods
......@@ -22,9 +21,9 @@ Pods
0001-privateConstants.patch
# Others
!Makefile
build
DerivedData
External
ImportedSources
DerivedData
!Makefile
......@@ -74,6 +74,7 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) {
[super viewDidLoad];
[self.downloadButton setTitle:NSLocalizedString(@"BUTTON_DOWNLOAD", nil) forState:UIControlStateNormal];
[self.downloadButton setAccessibilityIdentifier:@"Download"];
self.whatToDownloadHelpLabel.text = [NSString stringWithFormat:NSLocalizedString(@"DOWNLOAD_FROM_HTTP_HELP", nil), [[UIDevice currentDevice] model]];
self.urlField.delegate = self;
self.urlField.keyboardType = UIKeyboardTypeURL;
......
......@@ -100,6 +100,7 @@ static const CGFloat maxControlsWidth = 474.0;
_trackSwitcherButton.accessibilityLabel = NSLocalizedString(@"OPEN_TRACK_PANEL", nil);
_bwdButton.accessibilityLabel = NSLocalizedString(@"BWD_BUTTON", nil);
_playPauseButton.accessibilityLabel = NSLocalizedString(@"PLAY_PAUSE_BUTTON", nil);
_playPauseButton.accessibilityIdentifier = @"Play Pause";
_playPauseButton.accessibilityHint = NSLocalizedString(@"LONGPRESS_TO_STOP", nil);
_fwdButton.accessibilityLabel = NSLocalizedString(@"FWD_BUTTON", nil);
_videoFilterButton.accessibilityLabel = NSLocalizedString(@"VIDEO_FILTER", nil);
......
......@@ -204,6 +204,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
rect.origin.y = rect.origin.y + 5.;
self.resetVideoFilterButton.frame = rect;
[self.movieView setAccessibilityIdentifier:@"Video Player Title"];
[self.movieView setAccessibilityLabel:NSLocalizedString(@"VO_VIDEOPLAYER_TITLE", nil)];
[self.movieView setAccessibilityHint:NSLocalizedString(@"VO_VIDEOPLAYER_DOUBLETAP", nil)];
......@@ -356,6 +357,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
{
//Needs to be a UIButton since we need it to work with constraints
_doneButton = [[UIButton alloc] initWithFrame:CGRectZero];
[_doneButton setAccessibilityIdentifier:@"Done"];
[_doneButton addTarget:self action:@selector(closePlayback:) forControlEvents:UIControlEventTouchUpInside];
[_doneButton setTitle:NSLocalizedString(@"BUTTON_DONE", nil) forState:UIControlStateNormal];
[_doneButton setTitleColor:[UIColor grayColor] forState:UIControlStateDisabled];
......
......@@ -96,6 +96,7 @@
object:[UIApplication sharedApplication]];
[self.openButton setTitle:NSLocalizedString(@"OPEN_NETWORK", nil) forState:UIControlStateNormal];
[self.openButton setAccessibilityIdentifier:@"Open Network Stream"];
[self.privateModeLabel setText:NSLocalizedString(@"PRIVATE_PLAYBACK_TOGGLE", nil)];
UILabel *scanSubModelabel = self.ScanSubModeLabel;
[scanSubModelabel setText:NSLocalizedString(@"SCAN_SUBTITLE_TOGGLE", nil)];
......
......@@ -65,6 +65,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC
title: NSLocalizedString("Video", comment: ""),
image: UIImage(named: "TVShowsIcon"),
selectedImage: UIImage(named: "TVShowsIcon"))
videoVC.tabBarItem.accessibilityIdentifier = "Video"
// Audio
let audioVC = VLCMediaViewController(services: services)
......@@ -75,6 +76,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC
title: NSLocalizedString("Audio", comment: ""),
image: UIImage(named: "MusicAlbums"),
selectedImage:UIImage(named: "MusicAlbums"))
audioVC.tabBarItem.accessibilityIdentifier = "Audio"
//Serverlist
let serverVC = VLCServerListViewController(nibName: nil, bundle: nil)
......@@ -83,6 +85,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC
title: NSLocalizedString("LOCAL_NETWORK", comment: ""),
image: UIImage(named: "Local"),
selectedImage: UIImage(named: "Local"))
serverVC.tabBarItem.accessibilityIdentifier = "Server"
//CloudServices
let cloudVC = VLCCloudServicesTableViewController(nibName: "VLCCloudServicesTableViewController", bundle: Bundle.main)
......@@ -91,6 +94,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC
title: NSLocalizedString("CLOUD_SERVICES", comment: ""),
image: UIImage(named: "iCloudIcon"),
selectedImage: UIImage(named: "iCloudIcon"))
cloudVC.tabBarItem.accessibilityIdentifier = "Cloud"
//Settings
let settingsVC = VLCSettingsController()
......@@ -99,6 +103,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC
title: NSLocalizedString("Settings", comment: ""),
image: UIImage(named: "Settings"),
selectedImage: UIImage(named: "Settings"))
settingsVC.tabBarItem.accessibilityIdentifier = "Settings"
//Download
let downloadVC = VLCDownloadViewController()
......@@ -107,6 +112,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC
title: NSLocalizedString("DOWNLOAD_FROM_HTTP", comment: ""),
image: UIImage(named: "Downloads"),
selectedImage: UIImage(named: "Downloads"))
downloadVC.tabBarItem.accessibilityIdentifier = "Downloads"
//Streaming
let streamVC = VLCOpenNetworkStreamViewController(nibName: "VLCOpenNetworkStreamViewController", bundle: Bundle.main)
......@@ -115,6 +121,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC
title: NSLocalizedString("OPEN_NETWORK", comment: ""),
image: UIImage(named: "OpenNetStream"),
selectedImage: UIImage(named: "OpenNetStream"))
streamVC.tabBarItem.accessibilityIdentifier = "Stream"
//About
let aboutVC = VLCAboutViewController()
......@@ -124,6 +131,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC
title: NSLocalizedString("ABOUT_APP", comment: ""),
image: coneIcon(),
selectedImage: coneIcon())
aboutVC.tabBarItem.accessibilityIdentifier = "About"
let controllers = [audioVC, serverVC, videoVC, settingsVC, cloudVC, downloadVC, streamVC, aboutVC]
tabBarController.viewControllers = controllers.map { UINavigationController(rootViewController: $0)}
......
......@@ -23,7 +23,7 @@ class Screenshot: XCTestCase {
XCUIDevice.shared.orientation = .portrait
SDStatusBarManager.sharedInstance().enableOverrides()
setupSnapshot(app)
helper = TestHelper(lang: deviceLanguage, target: VLCiOSTestMenu.self)
helper = TestHelper(app)
app.launch()
}
......@@ -34,37 +34,34 @@ class Screenshot: XCTestCase {
func testCaptureVideoPlayback() {
download(name: "http://jell.yfish.us/media/jellyfish-10-mbps-hd-h264.mkv")
helper.tap(tabDescription: "Video", app: app)
helper.tap(.Video)
app.collectionViews.cells.element(boundBy: 0).tap()
app.navigationBars["VLCMovieView"].buttons[helper.localized(key: "VIDEO_ASPECT_RATIO_BUTTON")].tap()
XCUIDevice.shared.orientation = .landscapeLeft
snapshot("playback")
}
func testCaptureAudioTab() {
let audio = helper.localized(key: "AUDIO")
helper.tap(tabDescription: audio, app: app)
helper.tap(.Audio)
snapshot("audio_tab")
}
func testCaptureNetworkTab() {
let localNetwork = helper.localized(key: "LOCAL_NETWORK")
helper.tap(tabDescription: localNetwork, app: app)
helper.tap(.Server)
snapshot("network_tab")
}
func testCaptureVideoTab() {
helper.tap(tabDescription: "Video", app: app)
helper.tap(.Video)
snapshot("video_tab")
}
func download(name fileName: String) {
let download = helper.localized(key: "DOWNLOAD_FROM_HTTP")
helper.tap(tabDescription: download, app: app)
helper.tap(.Downloads)
let downloadTextfield = app.textFields["http://myserver.com/file.mkv"]
downloadTextfield.clearAndEnter(text: fileName)
app.buttons[helper.localized(key: "BUTTON_DOWNLOAD")].tap()
app.buttons["Download"].tap()
let cancelDownloadButton = app.buttons["flatDeleteButton"]
let predicate = NSPredicate(format: "exists == 0")
......
......@@ -13,44 +13,19 @@
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()
}
}
enum Tab: String {
case Video, Audio, Server, Cloud
case Settings, Downloads, Stream, About
}
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()
}
struct TestHelper {
let app: XCUIApplication
guard let bundle = Bundle(path: path) else {
XCTFail("Could not load bundle at \(path)")
return Bundle()
}
init(_ app: XCUIApplication) {
self.app = app
}
return bundle
func tap(_ type: Tab) {
app.tabBars.buttons[type.rawValue].tap()
}
}
......@@ -22,54 +22,47 @@ class VLCiOSTestMenu: XCTestCase {
XCUIDevice.shared.orientation = .portrait
setupSnapshot(app)
helper = TestHelper(lang: deviceLanguage, target: VLCiOSTestMenu.self)
helper = TestHelper(app)
app.launch()
}
func testNavigationToAudioTab() {
let audio = helper.localized(key: "AUDIO")
helper.tap(tabDescription: audio, app: app)
XCTAssertNotNil(app.navigationBars[audio])
helper.tap(.Audio)
XCTAssertNotNil(app.navigationBars[Tab.Audio.rawValue])
}
func testNavigationToNetworkTab() {
let localNetwork = helper.localized(key: "LOCAL_NETWORK")
helper.tap(tabDescription: localNetwork, app: app)
XCTAssertNotNil(app.navigationBars[localNetwork])
helper.tap(.Server)
XCTAssertNotNil(app.navigationBars[Tab.Server.rawValue])
}
func testNavigationToVideoTab() {
helper.tap(tabDescription: "Video", app: app)
XCTAssertNotNil(app.navigationBars["Video"])
helper.tap(.Video)
XCTAssertNotNil(app.navigationBars[Tab.Video.rawValue])
}
func testNavigationToSettingsTab() {
let settings = helper.localized(key: "Settings")
helper.tap(tabDescription: settings, app: app)
XCTAssertNotNil(app.navigationBars[settings])
helper.tap(.Settings)
XCTAssertNotNil(app.navigationBars[Tab.Settings.rawValue])
}
func testNavigationToCloudServices() {
let cloudServices = helper.localized(key: "CLOUD_SERVICES")
helper.tap(tabDescription: cloudServices, app: app)
XCTAssertNotNil(app.navigationBars[cloudServices])
helper.tap(.Cloud)
XCTAssertNotNil(app.navigationBars[Tab.Cloud.rawValue])
}
func testNavigationToDownloads() {
let downloads = helper.localized(key: "DOWNLOAD_FROM_HTTP")
helper.tap(tabDescription: downloads, app: app)
XCTAssertNotNil(app.navigationBars[downloads])
helper.tap(.Downloads)
XCTAssertNotNil(app.navigationBars[Tab.Downloads.rawValue])
}
func testNavigationToNetworkStream() {
let network = helper.localized(key: "OPEN_NETWORK")
helper.tap(tabDescription: network, app: app)
XCTAssertNotNil(app.navigationBars[network])
helper.tap(.Stream)
XCTAssertNotNil(app.navigationBars[Tab.Stream.rawValue])
}
func testNavigationToAbout() {
let about = helper.localized(key: "ABOUT_APP")
helper.tap(tabDescription: about, app: app)
XCTAssertNotNil(app.navigationBars[about])
helper.tap(.About)
XCTAssertNotNil(app.navigationBars[Tab.About.rawValue])
}
}
......@@ -22,7 +22,7 @@ class VLCiOSTestVideoCodecs: XCTestCase {
XCUIDevice.shared.orientation = .portrait
setupSnapshot(app)
helper = TestHelper(lang: deviceLanguage, target: VLCiOSTestVideoCodecs.self)
helper = TestHelper(app)
setupSnapshot(app)
app.launch()
}
......@@ -44,12 +44,11 @@ class VLCiOSTestVideoCodecs: XCTestCase {
}
func stream(named fileName: String) {
let stream = helper.localized(key: "OPEN_NETWORK")
helper.tap(tabDescription: stream, app: app)
helper.tap(.Stream)
let addressTextField = app.textFields["http://myserver.com/file.mkv"]
addressTextField.clearAndEnter(text: fileName)
app.otherElements.children(matching: .button)[helper.localized(key: "OPEN_NETWORK")].tap()
app.buttons["Open Network Stream"].tap()
let displayTime = app.navigationBars["VLCMovieView"].buttons["--:--"]
let zeroPredicate = NSPredicate(format: "exists == 0")
......@@ -57,10 +56,10 @@ class VLCiOSTestVideoCodecs: XCTestCase {
waitForExpectations(timeout: 20.0) { err in
XCTAssertNil(err)
if !(self.app.buttons[self.helper.localized(key: "BUTTON_DONE")].exists) {
self.app.otherElements[self.helper.localized(key: "VO_VIDEOPLAYER_TITLE")].tap()
if !(self.app.buttons["Done"].exists) {
self.app.otherElements["Video Player Title"].tap()
}
let playPause = self.app.buttons[self.helper.localized(key: "PLAY_PAUSE_BUTTON")]
let playPause = self.app.buttons["Play Pause"]
let onePredicate = NSPredicate(format: "exists == 1")
self.expectation(for: onePredicate, evaluatedWith: playPause, handler: nil)
self.waitForExpectations(timeout: 20.0, handler: nil)
......
......@@ -244,7 +244,6 @@
9BADAF45185FBD9D00108BD8 /* VLCFrostedGlasView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BADAF44185FBD9D00108BD8 /* VLCFrostedGlasView.m */; };
9BE4D1CE183D76950006346C /* VLCCloudStorageTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784B0183A990F009EE944 /* VLCCloudStorageTableViewCell.m */; };
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 */; };
CAA0B0EF2072651800B9274E /* VLCiOSTestVideoCodecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF76D9120709C7000E2AD7B /* VLCiOSTestVideoCodecs.swift */; };
CAA0B0F02072651A00B9274E /* XCUIElement+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF76D9320709C9500E2AD7B /* XCUIElement+Helpers.swift */; };
......@@ -1146,7 +1145,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C91ABE4F469FB899168F35C0 /* libPods-VLC for iOSUITests.a in Frameworks */,
FBFA7376B199F363082AFE4A /* libPods-VLC-iOS-VLC for iOSUITests.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
......
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