Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: FavIconTests/FavIconsTests.swift

Issue 29664569: Favicon: Issue 6245 - SwiftLinted project files (Closed)
Patch Set: Created Jan. 12, 2018, 11:04 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « FavIcon/Utils.swift ('k') | FavIconTests/HTMLDocumentTests.swift » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // 1 //
2 // FavIcon 2 // FavIcon
3 // Copyright © 2016 Leon Breedt 3 // Copyright © 2016 Leon Breedt
4 // 4 //
5 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License. 6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at 7 // You may obtain a copy of the License at
8 // 8 //
9 // http://www.apache.org/licenses/LICENSE-2.0 9 // http://www.apache.org/licenses/LICENSE-2.0
10 // 10 //
11 // Unless required by applicable law or agreed to in writing, software 11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS, 12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and 14 // See the License for the specific language governing permissions and
15 // limitations under the License. 15 // limitations under the License.
16 // 16 //
17 17
18 // swiftlint:disable sorted_imports
19
18 import XCTest 20 import XCTest
19 @testable import FavIcon 21 @testable import FavIcon
20 22
21 #if os(iOS) 23 #if os(iOS)
22 import UIKit 24 import UIKit
23 #elseif os(OSX) 25 #elseif os(OSX)
24 import Cocoa 26 import Cocoa
25 #endif 27 #endif
26 28
27 // swiftlint:disable function_body_length 29 // swiftlint:disable function_body_length
28 // swiftlint:disable line_length
29 30
30 class FavIconTests: XCTestCase { 31 class FavIconTests: XCTestCase {
31 func testScan() { 32 func testScan() {
32 var actualIcons: [DetectedIcon] = [] 33 var actualIcons: [DetectedIcon] = []
33 34
34 performWebRequest(name: "scan") { requestCompleted in 35 performWebRequest(name: "scan") { requestCompleted in
35 do { 36 do {
36 try FavIcon.scan("https://apple.com") { icons, meta in 37 try FavIcon.scan("https://apple.com") { icons, _ in
37 actualIcons = icons 38 actualIcons = icons
38 requestCompleted() 39 requestCompleted()
39 } 40 }
40 } catch let error { 41 } catch let error {
41 XCTFail("failed to detect icons: \(error)") 42 XCTFail("failed to detect icons: \(error)")
42 } 43 }
43 } 44 }
44 45
45 XCTAssertEqual(1, actualIcons.count) 46 XCTAssertEqual(1, actualIcons.count)
46 XCTAssertEqual(URL(string: "https://www.apple.com/favicon.ico")!, actual Icons[0].url) 47 XCTAssertEqual(URL(string: "https://www.apple.com/favicon.ico")!, actual Icons[0].url)
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 private extension XCTestCase { 308 private extension XCTestCase {
308 func performWebRequest(name: String, timeout: TimeInterval = 50000.0, callba ck: (@escaping () -> Void) -> Void) { 309 func performWebRequest(name: String, timeout: TimeInterval = 50000.0, callba ck: (@escaping () -> Void) -> Void) {
309 FavIcon.urlSessionProvider = { URLSession.shared } 310 FavIcon.urlSessionProvider = { URLSession.shared }
310 let expectation = self.expectation(description: "web request - \(name)") 311 let expectation = self.expectation(description: "web request - \(name)")
311 callback(expectation.fulfill) 312 callback(expectation.fulfill)
312 waitForExpectations(timeout: timeout, handler: nil) 313 waitForExpectations(timeout: timeout, handler: nil)
313 } 314 }
314 } 315 }
315 316
316 // swiftlint:enable function_body_length 317 // swiftlint:enable function_body_length
317 // swiftlint:enable line_length
OLDNEW
« no previous file with comments | « FavIcon/Utils.swift ('k') | FavIconTests/HTMLDocumentTests.swift » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld