This repository was archived by the owner on Jan 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.cy
More file actions
58 lines (45 loc) · 3.34 KB
/
test.cy
File metadata and controls
58 lines (45 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@import org.cycript.NSLog;
function assert_equal(a, b) {
if (![a isEqual:b]) {
NSLog("FAIL: " + a + " !== " + b);
}
}
function assert_not_equal(a, b) {
if ([a isEqual:b]) {
NSLog("FAIL: " + a + " === " + b);
}
}
function assert_null(a) {
if (typeof a !== "undefined" && a !== null) {
NSLog("FAIL: " + a + " !== nil");
}
}
function assert_not_null(a) {
if (typeof a === "undefined" || a === null) {
NSLog("FAIL: " + a + " === nil");
}
}
assert_equal([[NSBundle bundleWithPath:"/System/Library/Frameworks/UIKit.framework"] load], true);
assert_equal([[NSBundle bundleWithPath:"/Library/Frameworks/Opener.framework"] load], true);
assert_equal([[NSBundle bundleWithPath:"/Library/Opener/MapsOpener.bundle"] load], true);
assert_not_equal(dlopen("/Library/MobileSubstrate/DynamicLibraries/MapsOpenerHooks.dylib", RTLD_LAZY), null);
var handler = [[HBLOMapsOpenerHandler alloc] init];
// handler class should exist and be able to instantiate
assert_not_null(handler);
// test that the NSURL+UIKitAdditions are translated
assert_equal([NSURL mapsURLWithQuery:"1 Infinite Loop, Cupertino CA 95014"].absoluteString, "comgooglemaps://?q=1%20Infinite%20Loop%2C%20Cupertino%20CA%2095014");
assert_equal([NSURL mapsURLWithSourceAddress:"1 Infinite Loop, Cupertino CA 95014" destinationAddress:"742 Evergreen Terrace, Springfield"].absoluteString, "comgooglemaps://?saddr=1%20Infinite%20Loop%2C%20Cupertino%20CA%2095014&daddr=742%20Evergreen%20Terrace%2C%20Springfield");
// this is a random unrelated maps url that should be ignored
assert_null([handler openURL:[NSURL URLWithString:"https://www.google.com.au/maps?source=tldsi&hl=en"] sender:nil]);
// maps: urls – these should become comgooglemaps://
assert_equal([handler openURL:[NSURL URLWithString:"maps:address=123%20Fake%20Street%2C%20Faketown%20SA%205108"] sender:nil].absoluteString, "comgooglemaps://?q=123%20Fake%20Street%2C%20Faketown%20SA%205108");
assert_equal([handler openURL:[NSURL URLWithString:"maps:?address=123%20Fake%20Street%2C%20Faketown%20SA%205108"] sender:nil].absoluteString, "comgooglemaps://?q=123%20Fake%20Street%2C%20Faketown%20SA%205108");
assert_equal([handler openURL:[NSURL URLWithString:"maps:saddr=123%20Fake%20Street%2C%20Faketown%20SA%205108&daddr=742%20Evergreen%20Terrace%2C%20Springfield"] sender:nil].absoluteString, "comgooglemaps://?saddr=123%20Fake%20Street%2C%20Faketown%20SA%205108&daddr=742%20Evergreen%20Terrace%2C%20Springfield");
// google maps urls – these should become comgooglemapsurl://
assert_equal([handler openURL:[NSURL URLWithString:"https://www.google.com.au/maps/@5.0990064,-162.1046249,3z?hl=en"] sender:nil].absoluteString, "comgooglemapsurl://www.google.com.au/maps/@5.0990064,-162.1046249,3z?hl=en");
assert_equal([handler openURL:[NSURL URLWithString:"https://google.com/maps/place/sdfsdf,+Woodstock,+CT+06281,+USA/@41.9459219,-71.9406471,17z/data=!3m1!4b1!4m2!3m1!1s0x89e42742eb2a583f:0xeee932d65eb62d50?hl=en"] sender:nil].absoluteString, "comgooglemapsurl://google.com/maps/place/sdfsdf,+Woodstock,+CT+06281,+USA/@41.9459219,-71.9406471,17z/data=!3m1!4b1!4m2!3m1!1s0x89e42742eb2a583f:0xeee932d65eb62d50?hl=en");
assert_equal([handler openURL:[NSURL URLWithString:"https://goo.gl/maps/PU7sBfeFHkC2"] sender:nil].absoluteString, "comgooglemapsurl://goo.gl/maps/PU7sBfeFHkC2");
// mapitem: urls
// too lazy, maybe i’ll do it some other time
// hooray (hopefully)
NSLog("END");