Files
rive-ios/Tests/RiveModelTests.swift
dskuza e77bda6ffa Add ability to set iOS artboard volume through RiveModel
Updates the `RiveModel` API with the ability to set and get the volume for the currently set artboard. Any new artboards will default to use the last-set volume of the model. A volume default of 1.0 is set to match rive-cpp's default. `RiveArtboard` is also updated to forward volume calls to the artboard instance, exposing a new `volume` property.

There's an open question whether this belongs in `RiveViewModel`, or `RiveModel`, but I went for `RiveModel` since there's a direct reference to the artboard within the model itself, and an indirect reference through the view model (model?.artboard)

Diffs=
a31cd9761 Add ability to set iOS artboard volume through RiveModel (#7658)

Co-authored-by: David Skuza <david@rive.app>
2024-07-23 18:17:06 +00:00

39 lines
919 B
Swift

//
// RiveModelTests.swift
// RiveRuntimeTests
//
// Created by David Skuza on 7/23/24.
// Copyright © 2024 Rive. All rights reserved.
//
import XCTest
@testable import RiveRuntime
class RiveModelTests: XCTestCase {
func test_volume() throws {
let file = try RiveFile(testfileName: "multipleartboards")
let model = RiveModel(riveFile: file)
XCTAssertEqual(model.volume, 1)
do {
try model.setArtboard()
model.volume = 0.5
XCTAssertEqual(model.volume, 0.5)
XCTAssertEqual(model.artboard?.__volume, 0.5)
}
do {
try model.setArtboard("artboard2")
XCTAssertEqual(model.volume, 0.5)
XCTAssertEqual(model.artboard?.__volume, 0.5)
model.volume = 0
XCTAssertEqual(model.volume, 0)
XCTAssertEqual(model.artboard?.__volume, 0)
}
}
}