some fixes
This commit is contained in:
1 parent
cf2bda9c54
commit
e28a4043ee
13 files changed
+793
-119
No files matched your search
@@ -2,9 +2,8 @@ import XCTest
|
||||
@testable import Luma
|
||||
|
||||
final class ArchiveMessageBatchPolicyTests: XCTestCase {
|
||||
func testMamPagesStaySmallEnoughForInteractiveUI() {
|
||||
XCTAssertLessThanOrEqual(ArchiveMessageBatchPolicy.pageSize, 32)
|
||||
XCTAssertGreaterThan(ArchiveMessageBatchPolicy.pageSize, 0)
|
||||
func testInteractivePageSize() {
|
||||
XCTAssertEqual(ArchiveMessageBatchPolicy.pageSize, 40)
|
||||
}
|
||||
|
||||
func testStanzasAreDecodedInSmallBatchesPerMainActorSlice() {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import XCTest
|
||||
@testable import Luma
|
||||
|
||||
final class OlderHistoryScrollPolicyTests: XCTestCase {
|
||||
func testIncompletePageWithFirstCursorContinues() {
|
||||
let page = OlderHistoryScrollPolicy.page(
|
||||
complete: false,
|
||||
pageFirstID: " mam-17 "
|
||||
)
|
||||
|
||||
XCTAssertTrue(page.hasMore)
|
||||
XCTAssertEqual(page.nextBefore, "mam-17")
|
||||
}
|
||||
|
||||
func testCompletePageStopsEvenWithCursor() {
|
||||
let page = OlderHistoryScrollPolicy.page(
|
||||
complete: true,
|
||||
pageFirstID: "mam-17"
|
||||
)
|
||||
|
||||
XCTAssertFalse(page.hasMore)
|
||||
XCTAssertEqual(page.nextBefore, "mam-17")
|
||||
}
|
||||
|
||||
func testEmptyPageNeverReportsMore() {
|
||||
// A server that keeps answering without RSM <first> must not leave
|
||||
// the UI re-requesting the same page in a spinner loop.
|
||||
let page = OlderHistoryScrollPolicy.page(complete: false, pageFirstID: nil)
|
||||
|
||||
XCTAssertFalse(page.hasMore)
|
||||
XCTAssertNil(page.nextBefore)
|
||||
}
|
||||
|
||||
func testWhitespaceOnlyCursorIsDiscarded() {
|
||||
let page = OlderHistoryScrollPolicy.page(complete: false, pageFirstID: " ")
|
||||
|
||||
XCTAssertFalse(page.hasMore)
|
||||
XCTAssertNil(page.nextBefore)
|
||||
}
|
||||
|
||||
func testPageFirstIDMustNotBecomeAnEmptyCursor() {
|
||||
let page = OlderHistoryScrollPolicy.page(complete: false, pageFirstID: "")
|
||||
|
||||
XCTAssertFalse(page.hasMore)
|
||||
XCTAssertNil(page.nextBefore)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import XCTest
|
||||
@testable import Luma
|
||||
|
||||
final class VideoNoteRotationPolicyTests: XCTestCase {
|
||||
func testPortraitNeedsClockwiseQuarterTurn() {
|
||||
// The sensor is landscape-native; an upright portrait circle must be
|
||||
// rotated 90 degrees clockwise in the QuickTime track matrix.
|
||||
XCTAssertEqual(
|
||||
VideoNoteRotationPolicy.angle(for: .portrait),
|
||||
90
|
||||
)
|
||||
}
|
||||
|
||||
func testPortraitUpsideDownNeedsThreeQuarterTurn() {
|
||||
XCTAssertEqual(
|
||||
VideoNoteRotationPolicy.angle(for: .portraitUpsideDown),
|
||||
270
|
||||
)
|
||||
}
|
||||
|
||||
func testLandscapeOrientationsMapToNativeAngles() {
|
||||
XCTAssertEqual(
|
||||
VideoNoteRotationPolicy.angle(for: .landscapeLeft),
|
||||
180
|
||||
)
|
||||
XCTAssertEqual(
|
||||
VideoNoteRotationPolicy.angle(for: .landscapeRight),
|
||||
0
|
||||
)
|
||||
}
|
||||
|
||||
func testAllAnglesAreSupportedCaptureAngles() {
|
||||
let orientations: [VideoNoteRotationPolicy.InterfaceOrientation] = [
|
||||
.portrait, .portraitUpsideDown, .landscapeLeft, .landscapeRight,
|
||||
]
|
||||
for orientation in orientations {
|
||||
let angle = VideoNoteRotationPolicy.angle(for: orientation)
|
||||
XCTAssertTrue(
|
||||
[CGFloat(0), 90, 180, 270].contains(angle),
|
||||
"unexpected angle \(angle) for \(orientation)"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user