Skip to content

Commit

Permalink
Fix UI tests (#126)
Browse files Browse the repository at this point in the history
* Fix UI tests

* Update PreviewRecoreonServices.swift

* Update .swiftlint.yml

* Fix
  • Loading branch information
umireon authored Jul 23, 2024
1 parent 25cb0d5 commit 97d4ccb
Show file tree
Hide file tree
Showing 38 changed files with 239 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ disabled_rules:
- trailing_comma
- inclusive_language
- identifier_name
- function_body_length
- function_parameter_count
4 changes: 2 additions & 2 deletions FragmentedRecordWriterTests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
{
"target" : {
"containerPath" : "container:Recoreon.xcodeproj",
"identifier" : "9C846C6885638E59E1D9DD35",
"name" : "RealtimeMediaWriterTests"
"identifier" : "1BF2A5E882081DBA0A3D4441",
"name" : "FragmentedRecordWriterTests"
}
}
],
Expand Down
111 changes: 96 additions & 15 deletions Recoreon/Preview Content/PreviewRecoreonServices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct PreviewRecoreonServices: RecoreonServices {

init() {
let fileManager = FileManager.default
let recoreonPathService = RecoreonPathService(fileManager: fileManager)
let recoreonPathService = RecoreonPathService(fileManager: fileManager, isUITest: true)

appGroupsPreferenceService = AppGroupsPreferenceService()
encodeService = PreviewEncodeService(
Expand All @@ -22,29 +22,110 @@ struct PreviewRecoreonServices: RecoreonServices {
}

func deployAllAssets() {
copyIfNotExists(
at: Bundle.main.url(forResource: "Record01", withExtension: "mkv")!,
to: recoreonPathService.generateAppGroupsScreenRecordURL(recordID: "Record01", ext: "mkv")
)
let recoreon20240724T063654URL = recoreonPathService.generateAppGroupsFragmentedRecordURL(
recordID: "Recoreon20240724T063654")

copyIfNotExists(
at: Bundle.main.url(forResource: "Record02", withExtension: "mkv")!,
to: recoreonPathService.generateAppGroupsScreenRecordURL(recordID: "Record02", ext: "mkv")
)
let recoreon20240724T063654StreamFiles = [
"Recoreon20240724T063654-app-000000",
"Recoreon20240724T063654-app-000001",
"Recoreon20240724T063654-app-000002",
"Recoreon20240724T063654-app-init",
"Recoreon20240724T063654-mic-000000",
"Recoreon20240724T063654-mic-000001",
"Recoreon20240724T063654-mic-000002",
"Recoreon20240724T063654-mic-init",
"Recoreon20240724T063654-video-000000",
"Recoreon20240724T063654-video-000001",
"Recoreon20240724T063654-video-000002",
"Recoreon20240724T063654-video-init",
]
for streamFile in recoreon20240724T063654StreamFiles {
copyIfNotExists(
at: Bundle.main.url(
forResource: streamFile,
withExtension: "m4s"
)!,
to: recoreon20240724T063654URL.appending(
path: "\(streamFile).m4s", directoryHint: .notDirectory)
)
}

let recoreon20240724T063654IndexFiles = [
"Recoreon20240724T063654-app",
"Recoreon20240724T063654-mic",
"Recoreon20240724T063654-video",
"Recoreon20240724T063654",
]

for indexFile in recoreon20240724T063654IndexFiles {
copyIfNotExists(
at: Bundle.main.url(
forResource: indexFile,
withExtension: "m3u8"
)!,
to: recoreon20240724T063654URL.appending(
path: "\(indexFile).m3u8", directoryHint: .notDirectory)
)
}

let recoreon20240724T063710URL = recoreonPathService.generateAppGroupsFragmentedRecordURL(
recordID: "Recoreon20240724T063710")

let recoreon20240724T063710StreamFiles = [
"Recoreon20240724T063710-app-000000",
"Recoreon20240724T063710-app-000001",
"Recoreon20240724T063710-app-init",
"Recoreon20240724T063710-mic-000000",
"Recoreon20240724T063710-mic-000001",
"Recoreon20240724T063710-mic-init",
"Recoreon20240724T063710-video-000000",
"Recoreon20240724T063710-video-000001",
"Recoreon20240724T063710-video-init",
]
for streamFile in recoreon20240724T063710StreamFiles {
copyIfNotExists(
at: Bundle.main.url(
forResource: streamFile,
withExtension: "m4s"
)!,
to: recoreon20240724T063710URL.appending(
path: "\(streamFile).m4s", directoryHint: .notDirectory)
)
}

let recoreon20240724T063710IndexFiles = [
"Recoreon20240724T063710-app",
"Recoreon20240724T063710-mic",
"Recoreon20240724T063710-video",
"Recoreon20240724T063710",
]

for indexFile in recoreon20240724T063710IndexFiles {
copyIfNotExists(
at: Bundle.main.url(
forResource: indexFile,
withExtension: "m3u8"
)!,
to: recoreon20240724T063710URL.appending(
path: "\(indexFile).m3u8", directoryHint: .notDirectory)
)
}

copyIfNotExists(
at: Bundle.main.url(forResource: "Record01-1", withExtension: "txt")!,
to: recoreonPathService.generateRecordNoteURL(recordID: "Record01", shortName: "1")
at: Bundle.main.url(forResource: "Recoreon20240724T063654-1", withExtension: "txt")!,
to: recoreonPathService.generateRecordNoteURL(
recordID: "Recoreon20240724T063654", shortName: "1")
)

copyIfNotExists(
at: Bundle.main.url(forResource: "Record01-2", withExtension: "txt")!,
to: recoreonPathService.generateRecordNoteURL(recordID: "Record01", shortName: "2")
at: Bundle.main.url(forResource: "Recoreon20240724T063654-2", withExtension: "txt")!,
to: recoreonPathService.generateRecordNoteURL(
recordID: "Recoreon20240724T063654", shortName: "2")
)

copyIfNotExists(
at: Bundle.main.url(forResource: "Record01-summary", withExtension: "txt")!,
to: recoreonPathService.generateRecordSummaryURL(recordID: "Record01")
at: Bundle.main.url(forResource: "Recoreon20240724T063654-summary", withExtension: "txt")!,
to: recoreonPathService.generateRecordSummaryURL(recordID: "Recoreon20240724T063654")
)

copyIfNotExists(
Expand Down
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:7
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="Record01-app-init.m4s"
#EXTINF:3.48299,
Record01-app-000000.m4s
#EXTINF:5.96753,
Recoreon20240724T063654-app-000001.m4s
#EXTINF:0.60372,
Recoreon20240724T063654-app-000002.m4s
#EXT-X-ENDLIST
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:7
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="Recoreon20240724T063654-mic-init.m4s"
#EXTINF:3.49867,
Recoreon20240724T063654-mic-000000.m4s
#EXTINF:6.01600,
Recoreon20240724T063654-mic-000001.m4s
#EXTINF:0.55467,
Recoreon20240724T063654-mic-000002.m4s
#EXT-X-ENDLIST
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:7
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="Recoreon20240724T063654-video-init.m4s"
#EXTINF:5.33333,
Recoreon20240724T063654-video-000000.m4s
#EXTINF:4.38333,
Recoreon20240724T063654-video-000001.m4s
#EXTINF:0.35000,
Recoreon20240724T063654-video-000002.m4s
#EXT-X-ENDLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=150000,CODECS="avc1.42e00a,mp4a.40.2",AUDIO="audio"
Recoreon20240724T063654-video.m3u8

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="App",DEFAULT=YES,URI="Recoreon20240724T063654-app.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Mic",DEFAULT=NO,URI="Recoreon20240724T063654-mic.m3u8"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:7
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="Recoreon20240724T063710-app-init.m4s"
#EXTINF:5.47991,
Recoreon20240724T063710-app-000000.m4s
#EXTINF:2.99537,
Recoreon20240724T063710-app-000001.m4s
#EXT-X-ENDLIST
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:7
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="Recoreon20240724T063710-mic-init.m4s"
#EXTINF:5.52533,
Recoreon20240724T063710-mic-000000.m4s
#EXTINF:2.96533,
Recoreon20240724T063710-mic-000001.m4s
#EXT-X-ENDLIST
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:7
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="Recoreon20240724T063710-video-init.m4s"
#EXTINF:5.68333,
Recoreon20240724T063710-video-000000.m4s
#EXTINF:2.88333,
Recoreon20240724T063710-video-000001.m4s
#EXT-X-ENDLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=150000,CODECS="avc1.42e00a,mp4a.40.2",AUDIO="audio"
Recoreon20240724T063710-video.m3u8

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="App",DEFAULT=YES,URI="Recoreon20240724T063710-app.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Mic",DEFAULT=NO,URI="Recoreon20240724T063710-mic.m3u8"
50 changes: 44 additions & 6 deletions RecoreonCommon/RecoreonPathService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,60 @@ public struct RecoreonPathService {
private let recordsDir: URL
private let recordNotesDir: URL

public init(fileManager: FileManager) {
public init(fileManager: FileManager, isUITest: Bool = false) {
self.fileManager = fileManager

#if DEBUG
let isPreview = ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
#else
let isPreview = false
#endif

appGroupsDir = fileManager.containerURL(
forSecurityApplicationGroupIdentifier: appGroupsIdentifier)!
appGroupsDocumentsDir = appGroupsDir.appending(
component: "Documents", directoryHint: .isDirectory)
forSecurityApplicationGroupIdentifier: appGroupsIdentifier
)!

if isPreview || isUITest {
appGroupsDocumentsDir = appGroupsDir.appending(
path: "Library/Caches/PreviewDocuments",
directoryHint: .isDirectory
)

libraryDir = fileManager.urls(
for: .libraryDirectory,
in: .userDomainMask
)[0].appending(
path: "Caches/PreviewLibrary",
directoryHint: .isDirectory
)

documentsDir = fileManager.urls(
for: .libraryDirectory,
in: .userDomainMask
)[0].appending(
path: "Caches/PreviewDocuments",
directoryHint: .isDirectory
)
} else {
appGroupsDocumentsDir = appGroupsDir.appending(
path: "Documents",
directoryHint: .isDirectory
)

libraryDir = fileManager.urls(for: .libraryDirectory, in: .userDomainMask)[0]

documentsDir = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0]
}

appGroupsFragmentedRecordsDir = appGroupsDocumentsDir.appending(
path: "FragmentedRecords",
directoryHint: .isDirectory
)
appGroupsRecordsDir = appGroupsDocumentsDir.appending(
path: "Records", directoryHint: .isDirectory)
libraryDir = fileManager.urls(for: .libraryDirectory, in: .userDomainMask).first!

previewVideosDir = libraryDir.appending(path: "PreviewVideos", directoryHint: .isDirectory)
encodedVideosDir = libraryDir.appending(path: "EncodedVideos", directoryHint: .isDirectory)
documentsDir = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first!
recordsDir = documentsDir.appending(path: "Records", directoryHint: .isDirectory)
recordNotesDir = documentsDir.appending(path: "RecordNotes", directoryHint: .isDirectory)
}
Expand Down
2 changes: 1 addition & 1 deletion RecoreonUITests/RecoreonUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ final class RecoreonUITests: XCTestCase {

app.buttons.matching(identifier: "ScreenRecordEntry").element(boundBy: 1).tap()
app.buttons.matching(identifier: "RecordNoteEntryButton").element(boundBy: 0).tap()
XCTAssert(app.staticTexts["Record01-1.txt"].waitForExistence(timeout: 10))
XCTAssert(app.staticTexts["Recoreon20240724T063654-1.txt"].waitForExistence(timeout: 10))
}

// func testLaunchPerformance() throws {
Expand Down
9 changes: 4 additions & 5 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,15 @@ targets:
platform: "iOS"
sources:
- "Recoreon"
settings:
DEVELOPMENT_ASSET_PATHS: '"Recoreon/Preview Content"'
ENABLE_PREVIEWS: true
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME: "AccentColor"
SWIFT_OBJC_BRIDGING_HEADER: "Recoreon/Recoreon-Bridging-Header.h"
dependencies:
- target: "RecoreonCommon"
- target: "RecoreonBroadcastUploadExtension"
- package: "FFmpegKit"
settings:
DEVELOPMENT_ASSET_PATHS: '"Recoreon/Preview Content"'
ENABLE_PREVIEWS: true
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME: "AccentColor"
SWIFT_OBJC_BRIDGING_HEADER: "Recoreon/Recoreon-Bridging-Header.h"
GCC_GENERATE_TEST_COVERAGE_FILES: true
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS: true
SWIFT_EMIT_LOC_STRINGS: true
Expand Down

0 comments on commit 97d4ccb

Please sign in to comment.