Skip to content

Commit 9ba83ab

Browse files
committed
+ Checked unit testing is working
+ Allowed to use breakpoints in the Pod project + Added some source code. -- Messy commit :-$
1 parent c9c5af8 commit 9ba83ab

9 files changed

Lines changed: 124 additions & 17 deletions

File tree

Example/MapCache.xcodeproj/project.pbxproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
1515
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
1616
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
17+
897DE7EE22976D7E0054A9A1 /* MapCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 897DE7ED22976D7E0054A9A1 /* MapCacheTests.swift */; };
1718
C96E40763BA125EDD01D8619 /* Pods_MapCache_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E93B0D3BBC838295972E4B6C /* Pods_MapCache_Tests.framework */; };
1819
/* End PBXBuildFile section */
1920

@@ -43,10 +44,11 @@
4344
607FACE51AFB9204008FA782 /* MapCache_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MapCache_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4445
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4546
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
46-
86806D7962E8E2CA29F7E1EF /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; name = README.md; path = ../README.md; sourceTree = "<group>"; };
47-
98B68CF07B3AC619DB7870E1 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
47+
86806D7962E8E2CA29F7E1EF /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
48+
897DE7ED22976D7E0054A9A1 /* MapCacheTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapCacheTests.swift; sourceTree = "<group>"; };
49+
98B68CF07B3AC619DB7870E1 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
4850
E93B0D3BBC838295972E4B6C /* Pods_MapCache_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MapCache_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
49-
EEF136F62BE41AE85E8E4DEA /* MapCache.podspec */ = {isa = PBXFileReference; includeInIndex = 1; name = MapCache.podspec; path = ../MapCache.podspec; sourceTree = "<group>"; };
51+
EEF136F62BE41AE85E8E4DEA /* MapCache.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = MapCache.podspec; path = ../MapCache.podspec; sourceTree = "<group>"; };
5052
/* End PBXFileReference section */
5153

5254
/* Begin PBXFrameworksBuildPhase section */
@@ -125,6 +127,7 @@
125127
isa = PBXGroup;
126128
children = (
127129
607FACEB1AFB9204008FA782 /* Tests.swift */,
130+
897DE7ED22976D7E0054A9A1 /* MapCacheTests.swift */,
128131
607FACE91AFB9204008FA782 /* Supporting Files */,
129132
);
130133
path = Tests;
@@ -227,6 +230,7 @@
227230
developmentRegion = English;
228231
hasScannedForEncodings = 0;
229232
knownRegions = (
233+
English,
230234
en,
231235
Base,
232236
);
@@ -353,6 +357,7 @@
353357
buildActionMask = 2147483647;
354358
files = (
355359
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */,
360+
897DE7EE22976D7E0054A9A1 /* MapCacheTests.swift in Sources */,
356361
);
357362
runOnlyForDeploymentPostprocessing = 0;
358363
};

Example/MapCache.xcodeproj/xcshareddata/xcschemes/MapCache-Example.xcscheme

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
buildConfiguration = "Debug"
4141
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4242
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43-
language = ""
4443
shouldUseLaunchSchemeArgsEnv = "YES">
4544
<Testables>
4645
<TestableReference
@@ -52,6 +51,11 @@
5251
BlueprintName = "MapCache_Tests"
5352
ReferencedContainer = "container:MapCache.xcodeproj">
5453
</BuildableReference>
54+
<SkippedTests>
55+
<Test
56+
Identifier = "MapCacheTests2">
57+
</Test>
58+
</SkippedTests>
5559
</TestableReference>
5660
</Testables>
5761
<MacroExpansion>
@@ -70,7 +74,6 @@
7074
buildConfiguration = "Debug"
7175
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
7276
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
73-
language = ""
7477
launchStyle = "0"
7578
useCustomWorkingDirectory = "NO"
7679
ignoresPersistentStateOnLaunch = "NO"

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Tests/MapCacheTests.swift

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// MapCacheTests.swift
3+
// MapCache_Tests
4+
//
5+
// Created by merlos on 23/05/2019.
6+
// Copyright © 2019 CocoaPods. All rights reserved.
7+
//
8+
// https://github.com/Quick/Quick
9+
10+
import Quick
11+
import Nimble
12+
import MapCache
13+
14+
class MapCacheTests: QuickSpec {
15+
override func spec() {
16+
describe("MapCache") {
17+
18+
it("can do maths") {
19+
expect(2) == 2
20+
}
21+
22+
it("can read") {
23+
expect("number") == "string"
24+
}
25+
26+
it("will eventually fail") {
27+
expect("time").toEventually( equal("time") )
28+
}
29+
30+
context("these will pass") {
31+
32+
it("can do maths") {
33+
expect(23) == 23
34+
}
35+
36+
it("can read") {
37+
expect("🐮") == "🐮"
38+
}
39+
40+
it("will eventually pass") {
41+
var time = "passing"
42+
43+
DispatchQueue.main.async {
44+
time = "done"
45+
}
46+
47+
waitUntil { done in
48+
Thread.sleep(forTimeInterval: 0.5)
49+
expect(time) == "done"
50+
51+
done()
52+
}
53+
}
54+
}
55+
}
56+
}
57+
}

Example/Tests/Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TableOfContentsSpec: QuickSpec {
99
describe("these will fail") {
1010

1111
it("can do maths") {
12-
expect(1) == 2
12+
expect(2) == 2
1313
}
1414

1515
it("can read") {

MapCache/Classes/CachedTileOverlay.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ import MapKit
1414
///
1515
public class CachedTileOverlay : MKTileOverlay {
1616

17-
/// Tells loadTile method if the tile shall be loaded rom the app cache.
18-
public var useCache: Bool = true
19-
20-
2117
public var config: MapCacheConfig?
2218

2319
public init(mapCacheConfig: MapCacheConfig) {
@@ -55,10 +51,10 @@ public class CachedTileOverlay : MKTileOverlay {
5551
override public func loadTile(at path: MKTileOverlayPath,
5652
result: @escaping (Data?, Error?) -> Void) {
5753
let url = self.url(forTilePath: path)
58-
print ("CachedTileOverlay::loadTile() url=\(url) useCache: \(useCache)")
54+
print ("CachedTileOverlay::loadTile() url=\(url) useCache: \(config?.useCache ?? true)")
5955

60-
if !self.useCache {
61-
print("lay:: not using cache")
56+
if !(config?.useCache ?? true) { // Use cache by use cache is not set.
57+
print("loadTile:: not using cache")
6258
return super.loadTile(at: path, result: result)
6359
}
6460
// Use cache

MapCache/Classes/DiskCache.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// DiskCache.swift
3+
// MapCache
4+
//
5+
// Created by merlos on 21/05/2019.
6+
//
7+
8+
import Foundation
9+
10+
11+
class DiskCache:NSObject {
12+
13+
}

MapCache/Classes/MapCache.swift

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,36 @@
66
//
77

88
import Foundation
9+
import MapKit
910

1011
/// The real brain
1112
public class MapCache : NSObject {
1213

13-
override init() {
14-
super.init()
14+
public var config : MapCacheConfig
15+
16+
init(config: MapCacheConfig ) {
17+
self.config = config
18+
}
19+
20+
func getTile(_ tilePath: MKTileOverlayPath) {
21+
22+
1523
}
1624

17-
func getTile(_ tileUrl: String) {
25+
func setTile(_ data: Data, forPath: MKTileOverlayPath) {
26+
1827
}
1928

2029
func removeTile(_ tileUrl: String) {
2130

2231
}
32+
33+
func cacheSize() {
34+
35+
}
36+
37+
func clear() {
38+
39+
}
40+
2341
}

MapCache/Classes/MapCacheConfig.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import Foundation
99

1010
public class MapCacheConfig : NSObject {
1111

12-
var tileUrlTemplate: String?
12+
public var tileUrlTemplate: String?
13+
14+
public var useCache: Bool = true
1315

1416
override public init() {
1517
super.init()

0 commit comments

Comments
 (0)