Skip to content

Commit b71f1dc

Browse files
Copilotfulldecent
andcommitted
Set up GitHub Actions testing and improve tests
Co-authored-by: fulldecent <[email protected]>
1 parent 605051e commit b71f1dc

File tree

4 files changed

+94
-12
lines changed

4 files changed

+94
-12
lines changed

.github/workflows/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Test
3+
4+
"on":
5+
push:
6+
branches: [main, master]
7+
pull_request:
8+
branches: [main, master]
9+
10+
jobs:
11+
test:
12+
runs-on: macos-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Select Xcode version
18+
run: >
19+
sudo xcode-select -s
20+
/Applications/Xcode_15.4.app/Contents/Developer
21+
22+
- name: Build
23+
run: swift build
24+
25+
- name: Run tests
26+
run: swift test
27+
28+
- name: Build for iOS Simulator
29+
run: |
30+
xcodebuild -scheme FDWaveformView \
31+
-destination 'platform=iOS Simulator,name=iPhone 15,OS=latest' \
32+
build \
33+
CODE_SIGNING_REQUIRED=NO \
34+
CODE_SIGNING_ALLOWED=NO

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All contributors are welcome. Please use issues and pull requests to contribute
44

55
# Release Process
66

7-
1. Confirm the build vorks (todo: set up GitHub Actions testing)
7+
1. Confirm the build works (GitHub Actions testing is now set up and will validate builds)
88
2. Create a release commit, see [prior releases](https://github.com/fulldecent/FDWaveformView/releases) for an example
99
1. Update the change log to label the latest improvements under the new version name
1010
2. Update the podspec version number

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Features
2525
**Set play progress** to highlight part of the waveform:
2626

2727
```swift
28-
self.waveform.progressSamples = self.waveform.totalSamples / 2
28+
let samplesToHighlight = self.waveform.totalSamples / 2
29+
self.waveform.highlightedSamples = 0 ..< samplesToHighlight
2930
```
3031

3132
<p align="center">
@@ -35,8 +36,7 @@ self.waveform.progressSamples = self.waveform.totalSamples / 2
3536
**Zoom in** to show only part of the waveform, of course, zooming in will smoothly re-render to show progressively more detail:
3637

3738
```swift
38-
self.waveform.zoomStartSamples = 0
39-
self.waveform.zoomEndSamples = self.waveform.totalSamples / 4
39+
self.waveform.zoomSamples = 0 ..< (self.waveform.totalSamples / 4)
4040
```
4141

4242
<p align="center">
@@ -60,7 +60,7 @@ self.waveform.doesAllowScroll = true
6060
```swift
6161
UIView.animate(withDuration: 0.3) {
6262
let randomNumber = arc4random() % self.waveform.totalSamples
63-
self.waveform.progressSamples = randomNumber
63+
self.waveform.highlightedSamples = 0 ..< randomNumber
6464
}
6565
```
6666

@@ -73,7 +73,7 @@ Creates **antialiased waveforms** by drawing more pixels than are seen on screen
7373

7474
Supports **iOS12+** and Swift 5.
7575

76-
**Includes unit tests**, todo: run these on GitHub Actions
76+
**Includes unit tests**, now running on GitHub Actions
7777

7878
## Installation
7979

Tests/FDWaveformViewTests/FDWaveformViewTests.swift

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,59 @@ import XCTest
22
@testable import FDWaveformView
33

44
final class FDWaveformViewTests: XCTestCase {
5-
func testExample() throws {
6-
// XCTest Documentation
7-
// https://developer.apple.com/documentation/xctest
8-
9-
// Defining Test Cases and Test Methods
10-
// https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods
5+
6+
func testFDWaveformViewInitialization() throws {
7+
// Test that FDWaveformView can be initialized
8+
let waveformView = FDWaveformView()
9+
XCTAssertNotNil(waveformView)
10+
XCTAssertEqual(waveformView.totalSamples, 0)
11+
XCTAssertNil(waveformView.audioURL)
12+
XCTAssertNil(waveformView.highlightedSamples)
13+
XCTAssertEqual(waveformView.zoomSamples, 0..<0)
14+
}
15+
16+
func testFDWaveformViewProperties() throws {
17+
// Test that properties can be set and retrieved
18+
let waveformView = FDWaveformView()
19+
20+
// Test boolean properties
21+
waveformView.doesAllowScrubbing = false
22+
XCTAssertFalse(waveformView.doesAllowScrubbing)
23+
24+
waveformView.doesAllowStretch = false
25+
XCTAssertFalse(waveformView.doesAllowStretch)
26+
27+
waveformView.doesAllowScroll = false
28+
XCTAssertFalse(waveformView.doesAllowScroll)
29+
30+
// Test color properties
31+
waveformView.wavesColor = .red
32+
XCTAssertEqual(waveformView.wavesColor, .red)
33+
34+
waveformView.progressColor = .green
35+
XCTAssertEqual(waveformView.progressColor, .green)
36+
}
37+
38+
func testFDWaveformTypeEquality() throws {
39+
// Test FDWaveformType enum equality
40+
let linear1 = FDWaveformType.linear
41+
let linear2 = FDWaveformType.linear
42+
let logarithmic1 = FDWaveformType.logarithmic(noiseFloor: -50.0)
43+
let logarithmic2 = FDWaveformType.logarithmic(noiseFloor: -50.0)
44+
let logarithmic3 = FDWaveformType.logarithmic(noiseFloor: -60.0)
45+
46+
XCTAssertEqual(linear1, linear2)
47+
XCTAssertEqual(logarithmic1, logarithmic2)
48+
XCTAssertNotEqual(linear1, logarithmic1)
49+
XCTAssertNotEqual(logarithmic1, logarithmic3)
50+
}
51+
52+
func testFDWaveformTypeFloorValue() throws {
53+
// Test floor value property
54+
let linear = FDWaveformType.linear
55+
let logarithmic = FDWaveformType.logarithmic(noiseFloor: -45.0)
56+
57+
XCTAssertEqual(linear.floorValue, 0)
58+
XCTAssertEqual(logarithmic.floorValue, -45.0)
1159
}
1260
}

0 commit comments

Comments
 (0)