Skip to content

Commit 09f5e4c

Browse files
authored
Merge pull request #158 from fulldecent/copilot/fix-2e46fe3c-0df2-4a19-9b0f-2658b291e409
Set up GitHub Actions testing with iPhone platform targeting and add meaningful unit tests
2 parents 3eff468 + d23b9f6 commit 09f5e4c

File tree

6 files changed

+94
-11
lines changed

6 files changed

+94
-11
lines changed

.github/workflows/test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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-14
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Xcode version
18+
uses: maxim-lobanov/setup-xcode@v1
19+
with:
20+
xcode-version: '15.4'
21+
22+
- name: Build and Test for iOS
23+
run: |
24+
# Build for iPhone Simulator using xcodebuild with Swift package
25+
xcodebuild -scheme FDWaveformView \
26+
-destination "platform=iOS Simulator,name=iPhone 15,OS=17.5" \
27+
clean build
28+
29+
# Run tests on iPhone Simulator
30+
xcodebuild -scheme FDWaveformView \
31+
-destination "platform=iOS Simulator,name=iPhone 15,OS=17.5" \
32+
test

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

Example/Example.xcodeproj/project.pbxproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@
291291
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
292292
CODE_SIGN_STYLE = Automatic;
293293
CURRENT_PROJECT_VERSION = 1;
294-
DEVELOPMENT_ASSET_PATHS = "\"Sources/Preview Content\"";
295294
ENABLE_PREVIEWS = YES;
296295
GENERATE_INFOPLIST_FILE = YES;
297296
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
@@ -319,7 +318,7 @@
319318
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
320319
CODE_SIGN_STYLE = Automatic;
321320
CURRENT_PROJECT_VERSION = 1;
322-
DEVELOPMENT_ASSET_PATHS = "\"Sources/Preview Content\"";
321+
DEVELOPMENT_TEAM = 8Q693ZG5RN;
323322
ENABLE_PREVIEWS = YES;
324323
GENERATE_INFOPLIST_FILE = YES;
325324
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;

Package.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import PackageDescription
55

66
let package = Package(
77
name: "FDWaveformView",
8+
platforms: [
9+
.iOS(.v12),
10+
.macOS(.v10_14)
11+
],
812
products: [
913
// Products define the executables and libraries a package produces, making them visible to other packages.
1014
.library(

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ self.waveform.doesAllowScroll = true
5959
```swift
6060
UIView.animate(withDuration: 0.3) {
6161
let randomNumber = arc4random() % self.waveform.totalSamples
62-
self.waveform.highlightedSamples = 0..<randomNumber
62+
self.waveform.highlightedSamples = 0 ..< randomNumber
6363
}
6464
```
6565

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

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

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

7777
## Installation
7878

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)