-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fead303
commit ec5ab77
Showing
3 changed files
with
93 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import XCTest | ||
|
||
final class PartsRepresentableTests: XCTestCase { | ||
let imageURL = Bundle.main.url(forResource: "logo", withExtension: "png")! | ||
|
||
func testModelContentFromCGImageIsNotEmpty() throws { | ||
guard let dataProvider = CGDataProvider(url: imageURL as CFURL) else { | ||
XCTFail("Could not find data for url: \(imageURL)") | ||
return | ||
} | ||
guard let image = CGImage(pngDataProviderSource: dataProvider, | ||
decode: nil, | ||
shouldInterpolate: false, | ||
intent: .defaultIntent) else { | ||
XCTFail("Could not construct CGImage from URL: \(imageURL)") | ||
return | ||
} | ||
let modelContent = image.partsValue | ||
XCTAssert(modelContent.count > 0, "Expected non-empty model content for CGImage: \(image)") | ||
} | ||
|
||
func testModelContentFromCIImageIsNotEmpty() throws { | ||
guard let image = CIImage(contentsOf: imageURL) else { | ||
XCTFail("Could not construct CIImage from URL: \(imageURL)") | ||
return | ||
} | ||
let modelContent = image.partsValue | ||
XCTAssert(modelContent.count > 0, "Expected non-empty model content for CGImage: \(image)") | ||
} | ||
|
||
func testModelContentFromUIImageIsNotEmpty() throws { | ||
guard let image = UIImage(named: "logo.png") else { | ||
XCTFail("Could not find image named logo.png.") | ||
return | ||
} | ||
let modelContent = image.partsValue | ||
XCTAssert(modelContent.count > 0, "Expected non-empty model content for UIImage: \(image)") | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.