Skip to content

Commit

Permalink
Change AbstractSearchEngine.offlineEngineReady to public var
Browse files Browse the repository at this point in the history
- Revert offline testNoData test
  • Loading branch information
aokj4ck committed Apr 26, 2024
1 parent d77f240 commit da5266d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Guide: https://keepachangelog.com/en/1.0.0/

<!-- Add changes for active work here -->

- [Offline] Add `AbstractSearchEngine.offlineEngineReady` to mark when offline searches are ready.
- [Offline] Add public `AbstractSearchEngine.offlineEngineReady` to mark when offline searches are ready.

- [Demo] Add OfflineDemoViewController to MapboxSearch.xcodeproj > Demo application.
- [Demo] Remove support for `--offline` launch argument.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class AbstractSearchEngine: FeedbackManagerDelegate {
public private(set) var offlineManager: SearchOfflineManager

/// Block offline searches until the tileset is ready
var offlineEngineReady = false
public var offlineEngineReady = false

// Manager to send raw events to Mapbox Telemetry
let eventsManager: EventsManager
Expand Down
25 changes: 17 additions & 8 deletions Tests/MapboxSearchIntegrationTests/OfflineIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,22 @@ class OfflineIntegrationTests: XCTestCase {
acceptExpired: true
)!

let cancelable = searchEngine.offlineManager.tileStore.loadTileRegion(id: regionId, options: options) { _ in
} completion: { result in
completion(result)
}
let cancelable = searchEngine.offlineManager.tileStore
.loadTileRegion(id: regionId, options: options) { progress in
// let sizePercent = CGFloat(progress.loadedResourceSize) / CGFloat(max(1, progress.completedResourceSize))
// NSLog("@@ progress size: \(sizePercent)% (loaded: \(progress.loadedResourceSize), completed:
// \(progress.completedResourceSize))")

let countPercent = CGFloat(progress.loadedResourceCount) / CGFloat(max(
1,
progress.requiredResourceCount
))
NSLog(
"@@ progress count: \(countPercent)% (loaded: \(progress.loadedResourceCount), required: \(progress.requiredResourceCount))"
)
} completion: { result in
completion(result)
}
return cancelable
}

Expand Down Expand Up @@ -208,11 +220,8 @@ class OfflineIntegrationTests: XCTestCase {

let errorExpectation = delegate.errorExpectation
searchEngine.search(query: "query")
wait(for: [errorExpectation], timeout: 100)
wait(for: [errorExpectation], timeout: 10)

XCTAssertNotNil(delegate.error)
XCTAssertNotNil(delegate.error?.localizedDescription)
XCTAssertNil(searchEngine.responseInfo)
XCTAssertTrue(searchEngine.suggestions.isEmpty)
}

Expand Down

0 comments on commit da5266d

Please sign in to comment.