-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from SDWebImage/feature_public_image_manager
Make the ImageManager public, which is useful for custom View who need to bind the data source
- Loading branch information
Showing
8 changed files
with
147 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import XCTest | ||
import SwiftUI | ||
import ViewInspector | ||
@testable import SDWebImageSwiftUI | ||
|
||
class ImageManagerTests: XCTestCase { | ||
|
||
override func setUp() { | ||
super.setUp() | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
override func tearDown() { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
super.tearDown() | ||
} | ||
|
||
func testImageManager() throws { | ||
let expectation = self.expectation(description: "ImageManager usage with Combine") | ||
let imageUrl = URL(string: "https://via.placeholder.com/500x500.jpg") | ||
let imageManager = ImageManager(url: imageUrl) | ||
imageManager.setOnSuccess { image, cacheType in | ||
XCTAssertNotNil(image) | ||
expectation.fulfill() | ||
} | ||
imageManager.setOnFailure { error in | ||
XCTFail() | ||
} | ||
imageManager.setOnProgress { receivedSize, expectedSize in | ||
|
||
} | ||
imageManager.load() | ||
XCTAssertNotNil(imageManager.currentOperation) | ||
let sub = imageManager.objectWillChange | ||
.subscribe(on: RunLoop.main) | ||
.receive(on: RunLoop.main) | ||
.sink { value in | ||
print(value) | ||
} | ||
sub.cancel() | ||
self.waitForExpectations(timeout: 5, handler: nil) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters