Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Test

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
test:
runs-on: macos-14

steps:
- uses: actions/checkout@v4

- name: Setup Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'

- name: Build and Test for iOS
run: |
# Build for iPhone Simulator using xcodebuild with Swift package
xcodebuild -scheme FDWaveformView \
-destination "platform=iOS Simulator,name=iPhone 15,OS=17.5" \
clean build

# Run tests on iPhone Simulator
xcodebuild -scheme FDWaveformView \
-destination "platform=iOS Simulator,name=iPhone 15,OS=17.5" \
test
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All contributors are welcome. Please use issues and pull requests to contribute

# Release Process

1. Confirm the build vorks (todo: set up GitHub Actions testing)
1. Confirm the build works (GitHub Actions testing is now set up and will validate builds)
2. Create a release commit, see [prior releases](https://github.com/fulldecent/FDWaveformView/releases) for an example
1. Update the change log to label the latest improvements under the new version name
2. Update the podspec version number
Expand Down
3 changes: 1 addition & 2 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Sources/Preview Content\"";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
Expand Down Expand Up @@ -319,7 +318,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Sources/Preview Content\"";
DEVELOPMENT_TEAM = 8Q693ZG5RN;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
Expand Down
4 changes: 4 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import PackageDescription

let package = Package(
name: "FDWaveformView",
platforms: [
.iOS(.v12),
.macOS(.v10_14)
],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ self.waveform.doesAllowScroll = true
```swift
UIView.animate(withDuration: 0.3) {
let randomNumber = arc4random() % self.waveform.totalSamples
self.waveform.highlightedSamples = 0..<randomNumber
self.waveform.highlightedSamples = 0 ..< randomNumber
}
```

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

Supports **iOS12+** and Swift 5.

**Includes unit tests**, todo: run these on GitHub Actions
**Includes unit tests**, now running on GitHub Actions

## Installation

Expand Down
60 changes: 54 additions & 6 deletions Tests/FDWaveformViewTests/FDWaveformViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,59 @@ import XCTest
@testable import FDWaveformView

final class FDWaveformViewTests: XCTestCase {
func testExample() throws {
// XCTest Documentation
// https://developer.apple.com/documentation/xctest

// Defining Test Cases and Test Methods
// https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods

func testFDWaveformViewInitialization() throws {
// Test that FDWaveformView can be initialized
let waveformView = FDWaveformView()
XCTAssertNotNil(waveformView)
XCTAssertEqual(waveformView.totalSamples, 0)
XCTAssertNil(waveformView.audioURL)
XCTAssertNil(waveformView.highlightedSamples)
XCTAssertEqual(waveformView.zoomSamples, 0..<0)
}

func testFDWaveformViewProperties() throws {
// Test that properties can be set and retrieved
let waveformView = FDWaveformView()

// Test boolean properties
waveformView.doesAllowScrubbing = false
XCTAssertFalse(waveformView.doesAllowScrubbing)

waveformView.doesAllowStretch = false
XCTAssertFalse(waveformView.doesAllowStretch)

waveformView.doesAllowScroll = false
XCTAssertFalse(waveformView.doesAllowScroll)

// Test color properties
waveformView.wavesColor = .red
XCTAssertEqual(waveformView.wavesColor, .red)

waveformView.progressColor = .green
XCTAssertEqual(waveformView.progressColor, .green)
}

func testFDWaveformTypeEquality() throws {
// Test FDWaveformType enum equality
let linear1 = FDWaveformType.linear
let linear2 = FDWaveformType.linear
let logarithmic1 = FDWaveformType.logarithmic(noiseFloor: -50.0)
let logarithmic2 = FDWaveformType.logarithmic(noiseFloor: -50.0)
let logarithmic3 = FDWaveformType.logarithmic(noiseFloor: -60.0)

XCTAssertEqual(linear1, linear2)
XCTAssertEqual(logarithmic1, logarithmic2)
XCTAssertNotEqual(linear1, logarithmic1)
XCTAssertNotEqual(logarithmic1, logarithmic3)
}

func testFDWaveformTypeFloorValue() throws {
// Test floor value property
let linear = FDWaveformType.linear
let logarithmic = FDWaveformType.logarithmic(noiseFloor: -45.0)

XCTAssertEqual(linear.floorValue, 0)
XCTAssertEqual(logarithmic.floorValue, -45.0)
}
}