Commit 59a4fea2 authored by Soomin Lee's avatar Soomin Lee

VLCiOSTestMenu: Fix tests

VLCAccessibilityIdentifier: Globalize accessibility identifiers
parent 7f5dd63c
......@@ -53,6 +53,7 @@ public class RemoteNetworkDataSource: NSObject, UITableViewDataSource, UITableVi
networkCell.textLabel?.text = cloudVC.title
networkCell.detailTextLabel?.text = cloudVC.detailText
networkCell.imageView?.image = cloudVC.cellImage
networkCell.accessibilityIdentifier = VLCAccessibilityIdentifier.cloud
return networkCell
}
case .streaming:
......@@ -60,7 +61,7 @@ public class RemoteNetworkDataSource: NSObject, UITableViewDataSource, UITableVi
networkCell.textLabel?.text = streamingVC.title
networkCell.detailTextLabel?.text = streamingVC.detailText
networkCell.imageView?.image = streamingVC.cellImage
networkCell.accessibilityIdentifier = "Stream"
networkCell.accessibilityIdentifier = VLCAccessibilityIdentifier.stream
return networkCell
}
case .download:
......@@ -68,7 +69,7 @@ public class RemoteNetworkDataSource: NSObject, UITableViewDataSource, UITableVi
networkCell.textLabel?.text = downloadVC.title
networkCell.detailTextLabel?.text = downloadVC.detailText
networkCell.imageView?.image = downloadVC.cellImage
networkCell.accessibilityIdentifier = "Downloads"
networkCell.accessibilityIdentifier = VLCAccessibilityIdentifier.downloads
return networkCell
}
case .wifi:
......
......@@ -14,6 +14,7 @@
#import "VLCMovieViewControlPanelView.h"
#import "VLCPlaybackController.h"
#import "VLCMetadata.h"
#import "VLC_iOS-Swift.h"
@interface VLCMovieViewControlPanelView ()
......@@ -100,7 +101,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.accessibilityIdentifier = VLCAccessibilityIdentifier.playPause;
_playPauseButton.accessibilityHint = NSLocalizedString(@"LONGPRESS_TO_STOP", nil);
_fwdButton.accessibilityLabel = NSLocalizedString(@"FWD_BUTTON", nil);
_videoFilterButton.accessibilityLabel = NSLocalizedString(@"VIDEO_FILTER", nil);
......
......@@ -145,7 +145,7 @@
cell.textLabel.textColor = PresentationTheme.current.colors.cellTextColor;
cell.detailTextLabel.textColor = PresentationTheme.current.colors.cellDetailTextColor;
if ([specifier.key isEqualToString:@"about"]) {
cell.accessibilityIdentifier = @"About";
cell.accessibilityIdentifier = VLCAccessibilityIdentifier.about;
}
return cell;
}
......
......@@ -50,7 +50,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate {
title: NSLocalizedString("VIDEO", comment: ""),
image: UIImage(named: "TVShowsIcon"),
selectedImage: UIImage(named: "TVShowsIcon"))
videoVC.tabBarItem.accessibilityIdentifier = "Video"
videoVC.tabBarItem.accessibilityIdentifier = VLCAccessibilityIdentifier.video
// Audio
let audioVC = VLCMediaViewController(services: services)
......@@ -61,7 +61,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate {
title: NSLocalizedString("AUDIO", comment: ""),
image: UIImage(named: "MusicAlbums"),
selectedImage:UIImage(named: "MusicAlbums"))
audioVC.tabBarItem.accessibilityIdentifier = "Audio"
audioVC.tabBarItem.accessibilityIdentifier = VLCAccessibilityIdentifier.audio
//Serverlist
let serverVC = VLCServerListViewController(nibName: nil, bundle: nil)
......@@ -70,7 +70,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate {
title: NSLocalizedString("LOCAL_NETWORK", comment: ""),
image: UIImage(named: "Local"),
selectedImage: UIImage(named: "Local"))
serverVC.tabBarItem.accessibilityIdentifier = "LocalNetwork"
serverVC.tabBarItem.accessibilityIdentifier = VLCAccessibilityIdentifier.localNetwork
//Settings
let settingsVC = VLCSettingsController()
......@@ -79,7 +79,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate {
title: NSLocalizedString("Settings", comment: ""),
image: UIImage(named: "Settings"),
selectedImage: UIImage(named: "Settings"))
settingsVC.tabBarItem.accessibilityIdentifier = "Settings"
settingsVC.tabBarItem.accessibilityIdentifier = VLCAccessibilityIdentifier.settings
let controllers = [audioVC, serverVC, videoVC, settingsVC]
tabBarController.viewControllers = controllers.map { UINavigationController(rootViewController: $0)}
......
......@@ -16,7 +16,7 @@ import XCTest
class Screenshot: XCTestCase {
let app = XCUIApplication()
var helper: TestHelper!
override func setUp() {
super.setUp()
......@@ -24,50 +24,50 @@ class Screenshot: XCTestCase {
SDStatusBarManager.sharedInstance().enableOverrides()
setupSnapshot(app)
helper = TestHelper(app)
app.launch()
}
override func tearDown() {
SDStatusBarManager.sharedInstance().disableOverrides()
}
func testCaptureVideoPlayback() {
download(name: "http://jell.yfish.us/media/jellyfish-10-mbps-hd-h264.mkv")
helper.tapTabBarItem(.Video)
helper.tapTabBarItem(VLCAccessibilityIdentifier.video)
app.collectionViews.cells.element(boundBy: 0).tap()
XCUIDevice.shared.orientation = .landscapeLeft
snapshot("playback")
}
func testCaptureAudioTab() {
helper.tapTabBarItem(.Audio)
helper.tapTabBarItem(VLCAccessibilityIdentifier.audio)
snapshot("audio_tab")
}
func testCaptureNetworkTab() {
helper.tapTabBarItem(.LocalNetwork)
helper.tapTabBarItem(VLCAccessibilityIdentifier.localNetwork)
snapshot("network_tab")
}
func testCaptureVideoTab() {
helper.tapTabBarItem(.Video)
helper.tapTabBarItem(VLCAccessibilityIdentifier.video)
snapshot("video_tab")
}
func download(name fileName: String) {
helper.tapTabBarItem(.LocalNetwork)
app.cells["Downloads"].tap()
helper.tapTabBarItem(VLCAccessibilityIdentifier.localNetwork)
app.cells[VLCAccessibilityIdentifier.downloads].tap()
let downloadTextfield = app.textFields["http://myserver.com/file.mkv"]
downloadTextfield.clearAndEnter(text: fileName)
app.buttons["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")
......
......@@ -13,11 +13,6 @@
import Foundation
import XCTest
enum Tab: String {
case Video, Audio, LocalNetwork, Cloud
case Settings, Downloads, Stream, About
}
struct TestHelper {
let app: XCUIApplication
......@@ -25,7 +20,7 @@ struct TestHelper {
self.app = app
}
func tapTabBarItem(_ type: Tab) {
app.tabBars.buttons[type.rawValue].tap()
func tapTabBarItem(_ identifier: String) {
app.tabBars.buttons[identifier].tap()
}
}
/*****************************************************************************
* VLCAccessibilityIdentifier.swift
*
* Copyright © 2018 VLC authors and VideoLAN
* Copyright © 2018 Videolabs
*
* Authors: Soomin Lee <bubu@mikan.io>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
import Foundation
@objc class VLCAccessibilityIdentifier: NSObject {
static let video = "video"
static let audio = "audio"
static let localNetwork = "localNetwork"
static let settings = "settings"
static let cloud = "cloud"
static let stream = "stream"
static let downloads = "downloads"
@objc static let about = "about"
@objc static let playPause = "playPause"
}
......@@ -27,45 +27,46 @@ class VLCiOSTestMenu: XCTestCase {
}
func testNavigationToAudioTab() {
helper.tapTabBarItem(.Audio)
XCTAssertNotNil(app.navigationBars[Tab.Audio.rawValue])
helper.tapTabBarItem(VLCAccessibilityIdentifier.audio)
XCTAssertNotNil(app.navigationBars[VLCAccessibilityIdentifier.audio])
}
func testNavigationToNetworkTab() {
helper.tapTabBarItem(.LocalNetwork)
XCTAssertNotNil(app.navigationBars[Tab.LocalNetwork.rawValue])
helper.tapTabBarItem(VLCAccessibilityIdentifier.localNetwork)
XCTAssertNotNil(app.navigationBars[VLCAccessibilityIdentifier.localNetwork])
}
func testNavigationToVideoTab() {
helper.tapTabBarItem(.Video)
XCTAssertNotNil(app.navigationBars[Tab.Video.rawValue])
helper.tapTabBarItem(VLCAccessibilityIdentifier.video)
XCTAssertNotNil(app.navigationBars[VLCAccessibilityIdentifier.video])
}
func testNavigationToSettingsTab() {
helper.tapTabBarItem(.Settings)
XCTAssertNotNil(app.navigationBars[Tab.Settings.rawValue])
helper.tapTabBarItem(VLCAccessibilityIdentifier.settings)
XCTAssertNotNil(app.navigationBars[VLCAccessibilityIdentifier.settings])
}
func testNavigationToCloudServices() {
helper.tapTabBarItem(.Cloud)
XCTAssertNotNil(app.navigationBars[Tab.Cloud.rawValue])
helper.tapTabBarItem(VLCAccessibilityIdentifier.localNetwork)
app.cells[VLCAccessibilityIdentifier.cloud].tap()
XCTAssertNotNil(app.navigationBars[VLCAccessibilityIdentifier.cloud])
}
func testNavigationToDownloads() {
helper.tapTabBarItem(.LocalNetwork)
app.cells["Downloads"].tap()
XCTAssertNotNil(app.navigationBars[Tab.Downloads.rawValue])
helper.tapTabBarItem(VLCAccessibilityIdentifier.localNetwork)
app.cells[VLCAccessibilityIdentifier.downloads].tap()
XCTAssertNotNil(app.navigationBars[VLCAccessibilityIdentifier.downloads])
}
func testNavigationToNetworkStream() {
helper.tapTabBarItem(.LocalNetwork)
app.cells["Stream"].tap()
XCTAssertNotNil(app.navigationBars[Tab.Stream.rawValue])
helper.tapTabBarItem(VLCAccessibilityIdentifier.localNetwork)
app.cells[VLCAccessibilityIdentifier.stream].tap()
XCTAssertNotNil(app.navigationBars[VLCAccessibilityIdentifier.stream])
}
func testNavigationToAbout() {
helper.tapTabBarItem(.Settings)
app.cells["About"].tap()
XCTAssertNotNil(app.navigationBars[Tab.About.rawValue])
helper.tapTabBarItem(VLCAccessibilityIdentifier.settings)
app.cells[VLCAccessibilityIdentifier.about].tap()
XCTAssertNotNil(app.navigationBars[VLCAccessibilityIdentifier.about])
}
}
......@@ -44,7 +44,8 @@ class VLCiOSTestVideoCodecs: XCTestCase {
}
func stream(named fileName: String) {
helper.tapTabBarItem(.Stream)
helper.tapTabBarItem(VLCAccessibilityIdentifier.localNetwork)
app.cells[VLCAccessibilityIdentifier.stream].tap()
let addressTextField = app.textFields["http://myserver.com/file.mkv"]
addressTextField.clearAndEnter(text: fileName)
......@@ -59,7 +60,7 @@ class VLCiOSTestVideoCodecs: XCTestCase {
if !(self.app.buttons["Done"].exists) {
self.app.otherElements["Video Player Title"].tap()
}
let playPause = self.app.buttons["Play Pause"]
let playPause = self.app.buttons[VLCAccessibilityIdentifier.playPause]
let onePredicate = NSPredicate(format: "exists == 1")
self.expectation(for: onePredicate, evaluatedWith: playPause, handler: nil)
self.waitForExpectations(timeout: 20.0, handler: nil)
......
......@@ -238,6 +238,8 @@
7DF90B4A1BE7A8110059C0E3 /* IASKSettingsReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DF90B471BE7A8110059C0E3 /* IASKSettingsReader.m */; };
7DF90B4B1BE7A8110059C0E3 /* IASKSpecifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DF90B491BE7A8110059C0E3 /* IASKSpecifier.m */; };
7DF9352F1958AB0600E60FD4 /* UIColor+Presets.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DF9352E1958AB0600E60FD4 /* UIColor+Presets.m */; };
8DD6516F208C89BC0052EE68 /* VLCAccessibilityIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD6516E208C89BC0052EE68 /* VLCAccessibilityIdentifier.swift */; };
8DD65170208C89C00052EE68 /* VLCAccessibilityIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD6516E208C89BC0052EE68 /* VLCAccessibilityIdentifier.swift */; };
8F91EC79195CEC7900F5BCBA /* VLCOpenInActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F91EC78195CEC7900F5BCBA /* VLCOpenInActivity.m */; };
8F91EC7F195E1DAB00F5BCBA /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F91EC7E195E1DAB00F5BCBA /* AssetsLibrary.framework */; };
9B088308183D7BEC004B5C2A /* VLCCloudStorageTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B088307183D7BEC004B5C2A /* VLCCloudStorageTableViewController.m */; };
......@@ -937,6 +939,7 @@
8939257D0D04F9AFF766DEA5 /* libPods-VLC-TV.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-VLC-TV.a"; sourceTree = BUILT_PRODUCTS_DIR; };
8B9DD09C453D2346D109D586 /* Pods-VLC-TV.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-TV.debug.xcconfig"; path = "Pods/Target Support Files/Pods-VLC-TV/Pods-VLC-TV.debug.xcconfig"; sourceTree = "<group>"; };
8C707B9BB2C5681D50CC9B99 /* Pods-VLC-tvOS-Debug.distribution.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-tvOS-Debug.distribution.xcconfig"; path = "Pods/Target Support Files/Pods-VLC-tvOS-Debug/Pods-VLC-tvOS-Debug.distribution.xcconfig"; sourceTree = "<group>"; };
8DD6516E208C89BC0052EE68 /* VLCAccessibilityIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLCAccessibilityIdentifier.swift; sourceTree = "<group>"; };
8DEAD87A672248D0A6790405 /* libPods-vlc-ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-vlc-ios.a"; sourceTree = BUILT_PRODUCTS_DIR; };
8F91EC77195CEC7900F5BCBA /* VLCOpenInActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCOpenInActivity.h; path = Sources/VLCOpenInActivity.h; sourceTree = SOURCE_ROOT; };
8F91EC78195CEC7900F5BCBA /* VLCOpenInActivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCOpenInActivity.m; path = Sources/VLCOpenInActivity.m; sourceTree = SOURCE_ROOT; };
......@@ -1261,6 +1264,7 @@
CAA0B0F620726A0E00B9274E /* TestHelper.swift */,
CAF76D9320709C9500E2AD7B /* XCUIElement+Helpers.swift */,
CA6FB8222074601900FC9BF2 /* VLC-iOSUITest-Bridging-Header.h */,
8DD6516E208C89BC0052EE68 /* VLCAccessibilityIdentifier.swift */,
);
path = "VLC for iOSUITests";
sourceTree = "<group>";
......@@ -3045,6 +3049,7 @@
files = (
CAA0B0F720726A0E00B9274E /* TestHelper.swift in Sources */,
CAD925792075536300F88496 /* Screenshot.swift in Sources */,
8DD6516F208C89BC0052EE68 /* VLCAccessibilityIdentifier.swift in Sources */,
CAA0B0EF2072651800B9274E /* VLCiOSTestVideoCodecs.swift in Sources */,
CAA0B0F02072651A00B9274E /* XCUIElement+Helpers.swift in Sources */,
CAA0B0ED2072651000B9274E /* VLCiOSTestMenu.swift in Sources */,
......@@ -3211,6 +3216,7 @@
DD8F84311B00EB3B0009138A /* VLCPlaybackController+MediaLibrary.m in Sources */,
418B144720179C00000447AA /* MediaViewController.swift in Sources */,
41EB91DD1F7BFF8500821AA5 /* VLCMetadata.m in Sources */,
8DD65170208C89C00052EE68 /* VLCAccessibilityIdentifier.swift in Sources */,
DD3EFF551BDEBCE500B68579 /* VLCLocalNetworkServiceBrowserDSM.m in Sources */,
7D37849A183A98D1009EE944 /* VLCPlaylistTableViewCell.m in Sources */,
7D37849B183A98D1009EE944 /* VLCLibraryViewController.m in Sources */,
......
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