@josuelmm/cordova-background-geolocation 4.2.3 → 4.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +11 -0
- package/CHANGELOG.md +261 -0
- package/README.md +306 -115
- package/android/CDVBackgroundGeolocation/src/main/java/com/marianhello/bgloc/cordova/ConfigMapper.java +34 -0
- package/android/CDVBackgroundGeolocation/src/main/java/com/tenforwardconsulting/bgloc/cordova/BackgroundGeolocationPlugin.java +61 -1
- package/android/common/src/main/AndroidManifest.xml +1 -1
- package/android/common/src/main/java/com/marianhello/bgloc/BootCompletedReceiver.java +20 -3
- package/android/common/src/main/java/com/marianhello/bgloc/Config.java +87 -1
- package/android/common/src/main/java/com/marianhello/bgloc/data/BackgroundLocation.java +94 -0
- package/android/common/src/main/java/com/marianhello/bgloc/data/ConfigJsonMapper.java +211 -0
- package/android/common/src/main/java/com/marianhello/bgloc/data/LocationTemplateFactory.java +6 -0
- package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationContract.java +5 -1
- package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationDAO.java +32 -1
- package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationContract.java +12 -2
- package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationDAO.java +33 -2
- package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteOpenHelper.java +15 -1
- package/android/common/src/main/java/com/marianhello/bgloc/provider/AbstractLocationProvider.java +48 -1
- package/android/common/src/main/java/com/marianhello/bgloc/provider/ActivityRecognitionLocationProvider.java +105 -6
- package/android/common/src/main/java/com/marianhello/bgloc/provider/DistanceFilterLocationProvider.java +336 -250
- package/android/common/src/main/java/com/marianhello/bgloc/provider/RawLocationProvider.java +69 -19
- package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceImpl.java +246 -21
- package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceProxy.java +5 -2
- package/android/common/src/main/java/com/marianhello/bgloc/sync/BatchManager.java +46 -13
- package/ios/CDVBackgroundGeolocation/CDVBackgroundGeolocation.m +23 -1
- package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.m +208 -70
- package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.m +132 -5
- package/ios/common/BackgroundGeolocation/MAURBackgroundSync.m +20 -0
- package/ios/common/BackgroundGeolocation/MAURConfig.h +7 -0
- package/ios/common/BackgroundGeolocation/MAURConfig.m +37 -2
- package/ios/common/BackgroundGeolocation/MAURConfigurationContract.h +3 -0
- package/ios/common/BackgroundGeolocation/MAURConfigurationContract.m +3 -1
- package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.m +10 -1
- package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.m +15 -1
- package/ios/common/BackgroundGeolocation/MAURLocation.h +12 -0
- package/ios/common/BackgroundGeolocation/MAURLocation.m +33 -4
- package/ios/common/BackgroundGeolocation/MAURLocationContract.h +4 -0
- package/ios/common/BackgroundGeolocation/MAURLocationContract.m +5 -1
- package/ios/common/BackgroundGeolocation/MAURLocationManager.m +19 -1
- package/ios/common/BackgroundGeolocation/MAURPostLocationTask.h +9 -0
- package/ios/common/BackgroundGeolocation/MAURPostLocationTask.m +59 -1
- package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.m +10 -1
- package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.m +54 -4
- package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.h +12 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.m +125 -5
- package/package.json +31 -1
- package/plugin.xml +3 -10
- package/www/BackgroundGeolocation.d.ts +143 -3
- package/www/BackgroundGeolocation.js +11 -4
- package/CLAUDE.md +0 -56
- package/HISTORY.md +0 -871
- package/android/CDVBackgroundGeolocation/src/test/java/com/marianhello/ConfigMapperTest.java +0 -220
- package/android/common/src/androidTest/java/com/marianhello/bgloc/BackgroundGeolocationFacadeTest.java +0 -45
- package/android/common/src/androidTest/java/com/marianhello/bgloc/BatchManagerTest.java +0 -570
- package/android/common/src/androidTest/java/com/marianhello/bgloc/ConfigTest.java +0 -76
- package/android/common/src/androidTest/java/com/marianhello/bgloc/ContentProviderLocationDAOTest.java +0 -437
- package/android/common/src/androidTest/java/com/marianhello/bgloc/DBLogReaderTest.java +0 -95
- package/android/common/src/androidTest/java/com/marianhello/bgloc/LocationContentProviderTest.java +0 -159
- package/android/common/src/androidTest/java/com/marianhello/bgloc/LocationServiceProxyTest.java +0 -161
- package/android/common/src/androidTest/java/com/marianhello/bgloc/LocationServiceTest.java +0 -247
- package/android/common/src/androidTest/java/com/marianhello/bgloc/SQLiteConfigurationDAOTest.java +0 -200
- package/android/common/src/androidTest/java/com/marianhello/bgloc/SQLiteLocationDAOTest.java +0 -457
- package/android/common/src/androidTest/java/com/marianhello/bgloc/SQLiteLocationDAOThreadTest.java +0 -96
- package/android/common/src/androidTest/java/com/marianhello/bgloc/SQLiteOpenHelperTest.java +0 -225
- package/android/common/src/androidTest/java/com/marianhello/bgloc/TestPluginDelegate.java +0 -46
- package/android/common/src/androidTest/java/com/marianhello/bgloc/TestResourceResolver.java +0 -14
- package/android/common/src/androidTest/java/com/marianhello/bgloc/provider/MockLocationProvider.java +0 -50
- package/android/common/src/androidTest/java/com/marianhello/bgloc/provider/TestLocationProviderFactory.java +0 -17
- package/android/common/src/androidTest/java/com/marianhello/bgloc/sqlite/SQLiteOpenHelper10.java +0 -92
- package/android/common/src/androidTest/java/com/marianhello/bgloc/test/LocationProviderTestCase.java +0 -107
- package/android/common/src/androidTest/java/com/marianhello/bgloc/test/TestConstants.java +0 -5
- package/android/common/src/test/java/com/marianhello/backgroundgeolocation/ArrayListLocationTemplateTest.java +0 -82
- package/android/common/src/test/java/com/marianhello/backgroundgeolocation/BackgroundLocationTest.java +0 -128
- package/android/common/src/test/java/com/marianhello/backgroundgeolocation/ConfigTest.java +0 -191
- package/android/common/src/test/java/com/marianhello/backgroundgeolocation/DBLogReaderTest.java +0 -37
- package/android/common/src/test/java/com/marianhello/backgroundgeolocation/HashMapLocationTemplateTest.java +0 -216
- package/android/common/src/test/java/com/marianhello/backgroundgeolocation/HttpPostServiceTest.java +0 -223
- package/android/common/src/test/java/com/marianhello/backgroundgeolocation/LocationTemplateFactoryTest.java +0 -50
- package/android/common/src/test/java/com/marianhello/backgroundgeolocation/PostLocationTaskTest.java +0 -180
- package/android/common/src/test/java/com/marianhello/backgroundgeolocation/TestHelper.java +0 -16
- package/ios/common/BackgroundGeolocation/SOMotionDetector/CHANGELOG.md +0 -2
- package/ios/common/BackgroundGeolocation/SOMotionDetector/LICENSE +0 -21
- package/ios/common/BackgroundGeolocation/SOMotionDetector/README.md +0 -135
- package/ios/common/BackgroundGeolocation/SOMotionDetector/SOLocationManager.h +0 -80
- package/ios/common/BackgroundGeolocation/SOMotionDetector/SOLocationManager.m +0 -147
- package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionActivity.h +0 -30
- package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionActivity.m +0 -42
- package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionDetector.h +0 -99
- package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionDetector.m +0 -327
- package/ios/common/BackgroundGeolocation/SOMotionDetector/SOStepDetector.h +0 -44
- package/ios/common/BackgroundGeolocation/SOMotionDetector/SOStepDetector.m +0 -94
- package/ios/common/BackgroundGeolocationTests/Info.plist +0 -24
- package/ios/common/BackgroundGeolocationTests/MAURBackgroundLocationTest.m +0 -185
- package/ios/common/BackgroundGeolocationTests/MAURConfigTest.m +0 -161
- package/ios/common/BackgroundGeolocationTests/MAURGeolocationOpenHelperTest.m +0 -102
- package/ios/common/BackgroundGeolocationTests/MAURLocationTest.m +0 -216
- package/ios/common/BackgroundGeolocationTests/MAURLocationUploaderTest.m +0 -55
- package/ios/common/BackgroundGeolocationTests/MAURLogReaderTest.m +0 -43
- package/ios/common/BackgroundGeolocationTests/MAURSQLiteConfigurationDAOTest.m +0 -102
- package/ios/common/BackgroundGeolocationTests/MAURSQLiteHelperTest.m +0 -41
- package/ios/common/BackgroundGeolocationTests/MAURSQLiteLocationDAOTests.m +0 -240
- package/ios/common/BackgroundGeolocationTests/MAURSQLiteLocationDAOThreadTest.m +0 -84
- package/ios/common/BackgroundGeolocationTests/MAURSQLiteOpenHelperTest.m +0 -144
- package/ios/common/scripts/xcode-refactor.js +0 -184
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// MAURConfigTest.m
|
|
3
|
-
// BackgroundGeolocationTests
|
|
4
|
-
//
|
|
5
|
-
// Created by Marian Hello on 02/12/2017.
|
|
6
|
-
// Copyright © 2017 mauron85. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <XCTest/XCTest.h>
|
|
10
|
-
#import "MAURConfig.h"
|
|
11
|
-
|
|
12
|
-
@interface MAURConfigTest : XCTestCase
|
|
13
|
-
|
|
14
|
-
@end
|
|
15
|
-
|
|
16
|
-
@implementation MAURConfigTest
|
|
17
|
-
|
|
18
|
-
- (void)setUp {
|
|
19
|
-
[super setUp];
|
|
20
|
-
// Put setup code here. This method is called before the invocation of each test method in the class.
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
- (void)tearDown {
|
|
24
|
-
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
25
|
-
[super tearDown];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
- (void)testInit {
|
|
29
|
-
MAURConfig *config = [[MAURConfig alloc] init];
|
|
30
|
-
|
|
31
|
-
XCTAssertFalse([config hasStationaryRadius]);
|
|
32
|
-
XCTAssertFalse([config hasDistanceFilter]);
|
|
33
|
-
XCTAssertFalse([config hasDesiredAccuracy]);
|
|
34
|
-
XCTAssertFalse([config hasDebug]);
|
|
35
|
-
XCTAssertFalse([config hasActivityType]);
|
|
36
|
-
XCTAssertFalse([config hasActivitiesInterval]);
|
|
37
|
-
XCTAssertFalse([config hasStopOnTerminate]);
|
|
38
|
-
XCTAssertFalse([config hasUrl]);
|
|
39
|
-
XCTAssertFalse([config hasSyncUrl]);
|
|
40
|
-
XCTAssertFalse([config hasSyncThreshold]);
|
|
41
|
-
XCTAssertFalse([config hasHttpHeaders]);
|
|
42
|
-
XCTAssertFalse([config hasSaveBatteryOnBackground]);
|
|
43
|
-
XCTAssertFalse([config hasMaxLocations]);
|
|
44
|
-
XCTAssertFalse([config hasPauseLocationUpdates]);
|
|
45
|
-
XCTAssertFalse([config hasLocationProvider]);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
- (void)testToDictionary {
|
|
49
|
-
MAURConfig *config = [[MAURConfig alloc] init];
|
|
50
|
-
NSDictionary *dict = [config toDictionary];
|
|
51
|
-
|
|
52
|
-
XCTAssertNil(dict[@"url"]);
|
|
53
|
-
XCTAssertNil(dict[@"syncUrl"]);
|
|
54
|
-
XCTAssertNil(dict[@"httpHeaders"]);
|
|
55
|
-
XCTAssertEqualObjects(dict[@"postTemplate"], [MAURConfig getDefaultTemplate]);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
- (void)testBooleans {
|
|
59
|
-
MAURConfig *config = [[MAURConfig alloc] init];
|
|
60
|
-
|
|
61
|
-
config._debug = @YES;
|
|
62
|
-
XCTAssertTrue([config isDebugging]);
|
|
63
|
-
|
|
64
|
-
config._debug = @NO;
|
|
65
|
-
XCTAssertFalse([config isDebugging]);
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
- (void)testNullToDictionary {
|
|
70
|
-
MAURConfig *config = [[MAURConfig alloc] init];
|
|
71
|
-
config.url = (id)[NSNull null];
|
|
72
|
-
config.syncUrl = (id)[NSNull null];
|
|
73
|
-
config.httpHeaders = (id)[NSNull null];
|
|
74
|
-
config._template = (id)[NSNull null];
|
|
75
|
-
|
|
76
|
-
NSDictionary *dict = [config toDictionary];
|
|
77
|
-
XCTAssertEqualObjects(dict[@"url"], @"");
|
|
78
|
-
XCTAssertEqualObjects(dict[@"syncUrl"], @"");
|
|
79
|
-
XCTAssertEqualObjects(dict[@"httpHeaders"], @{});
|
|
80
|
-
XCTAssertEqualObjects(dict[@"postTemplate"], [MAURConfig getDefaultTemplate]);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
- (void)testMerge {
|
|
84
|
-
MAURConfig *config1 = [[MAURConfig alloc] init];
|
|
85
|
-
config1.distanceFilter = [NSNumber numberWithInt:666];
|
|
86
|
-
MAURConfig *config2 = [[MAURConfig alloc] initWithDefaults];
|
|
87
|
-
config2.distanceFilter = [NSNumber numberWithInt:999];
|
|
88
|
-
|
|
89
|
-
MAURConfig *merger = [MAURConfig merge:config1 withConfig:config2];
|
|
90
|
-
|
|
91
|
-
XCTAssertEqual(merger.distanceFilter.intValue, 999);
|
|
92
|
-
XCTAssertEqualObjects(merger.activityType, @"OtherNavigation");
|
|
93
|
-
XCTAssertEqual(config1.distanceFilter.intValue, 666);
|
|
94
|
-
XCTAssertEqual(config2.distanceFilter.intValue, 999);
|
|
95
|
-
XCTAssertNotEqual(merger.distanceFilter, config1.distanceFilter);
|
|
96
|
-
XCTAssertEqual(merger.distanceFilter, config2.distanceFilter);
|
|
97
|
-
XCTAssertNotEqual(config1.distanceFilter, config2.distanceFilter);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
- (void)testArrayTemplateToString {
|
|
101
|
-
MAURConfig *config = [[MAURConfig alloc] init];
|
|
102
|
-
config._template = @[@"latitude", @"longitude", @"custom"];
|
|
103
|
-
|
|
104
|
-
XCTAssertEqualObjects([config getTemplateAsString:nil], @"[\"latitude\",\"longitude\",\"custom\"]");
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
- (void)testDictionaryTemplateToString {
|
|
108
|
-
MAURConfig *config = [[MAURConfig alloc] init];
|
|
109
|
-
config._template = @{
|
|
110
|
-
@"lat": @"latitude",
|
|
111
|
-
@"lon": @"longitude",
|
|
112
|
-
@"foo": @"bar"
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
XCTAssertEqualObjects([config getTemplateAsString:nil], @"{\"lat\":\"latitude\",\"lon\":\"longitude\",\"foo\":\"bar\"}");
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
- (void)testMergeEmpty {
|
|
119
|
-
MAURConfig *config1 = [[MAURConfig alloc] init];
|
|
120
|
-
MAURConfig *config2 = [[MAURConfig alloc] init];
|
|
121
|
-
|
|
122
|
-
config1.url = @"url";
|
|
123
|
-
config1.syncUrl = @"syncurl";
|
|
124
|
-
|
|
125
|
-
config2.url = @"";
|
|
126
|
-
config2.syncUrl = @"";
|
|
127
|
-
|
|
128
|
-
MAURConfig *merger = [MAURConfig merge:config1 withConfig:config2];
|
|
129
|
-
|
|
130
|
-
XCTAssertEqualObjects(merger.url, @"");
|
|
131
|
-
XCTAssertEqualObjects(merger.syncUrl, @"");
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
- (void)testMergeNullFromDictionary {
|
|
135
|
-
MAURConfig *config1 = [[MAURConfig alloc] init];
|
|
136
|
-
|
|
137
|
-
config1.url = @"url";
|
|
138
|
-
config1.syncUrl = @"syncurl";
|
|
139
|
-
config1.httpHeaders = @{@"foo": @"bar"};
|
|
140
|
-
config1._template = @{@"lat": @"@latitude"};
|
|
141
|
-
|
|
142
|
-
NSDictionary *configProps = @{
|
|
143
|
-
@"url": [NSNull null],
|
|
144
|
-
@"syncUrl": [NSNull null],
|
|
145
|
-
@"httpHeaders": [NSNull null],
|
|
146
|
-
@"postTemplate": [NSNull null]
|
|
147
|
-
};
|
|
148
|
-
MAURConfig *config2 = [MAURConfig fromDictionary:configProps];
|
|
149
|
-
|
|
150
|
-
XCTAssertFalse([config2 hasValidUrl]);
|
|
151
|
-
XCTAssertFalse([config2 hasValidSyncUrl]);
|
|
152
|
-
|
|
153
|
-
MAURConfig *merger = [MAURConfig merge:config1 withConfig:config2];
|
|
154
|
-
|
|
155
|
-
XCTAssertEqualObjects(merger.url, @"");
|
|
156
|
-
XCTAssertEqualObjects(merger.syncUrl, @"");
|
|
157
|
-
XCTAssertEqualObjects(merger.httpHeaders, @{});
|
|
158
|
-
XCTAssertEqualObjects(merger._template, [MAURConfig getDefaultTemplate]);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
@end
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// MAURGeolocationOpenHelperTest.m
|
|
3
|
-
// BackgroundGeolocationTests
|
|
4
|
-
//
|
|
5
|
-
// Created by Marian Hello on 01/07/16.
|
|
6
|
-
// Copyright © 2016 mauron85. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <XCTest/XCTest.h>
|
|
10
|
-
#import "MAURSQLiteOpenHelper.h"
|
|
11
|
-
#import "MAURLocationContract.h"
|
|
12
|
-
#import "MAURConfigurationContract.h"
|
|
13
|
-
#import "MAURGeolocationOpenHelper.h"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// Warning: This has to be last test in suite, because it unlinks db file
|
|
17
|
-
@interface xGeolocationOpenHelperTest : XCTestCase
|
|
18
|
-
|
|
19
|
-
@end
|
|
20
|
-
|
|
21
|
-
@implementation xGeolocationOpenHelperTest
|
|
22
|
-
|
|
23
|
-
- (void)setUp {
|
|
24
|
-
[super setUp];
|
|
25
|
-
MAURGeolocationOpenHelper *helper = [[MAURGeolocationOpenHelper alloc] init];
|
|
26
|
-
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
27
|
-
NSString *dbPath = [helper getDatabasePath];
|
|
28
|
-
[fileManager removeItemAtPath:dbPath error:nil];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
- (void)tearDown {
|
|
32
|
-
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
33
|
-
[super tearDown];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
- (void)testIfLocationTableIsCreated {
|
|
37
|
-
MAURGeolocationOpenHelper *helper = [[MAURGeolocationOpenHelper alloc] init];
|
|
38
|
-
FMDatabaseQueue *queue = [helper getWritableDatabase];
|
|
39
|
-
|
|
40
|
-
[queue inDatabase:^(FMDatabase *database) {
|
|
41
|
-
NSString *sql = [NSString stringWithFormat: @"SELECT count(name) FROM sqlite_master WHERE type='table' AND name='%@';", @LC_TABLE_NAME];
|
|
42
|
-
FMResultSet *rs = [database executeQuery:sql];
|
|
43
|
-
while([rs next]) {
|
|
44
|
-
XCTAssertEqual([rs intForColumnIndex:0], 1);
|
|
45
|
-
}
|
|
46
|
-
[rs close];
|
|
47
|
-
}];
|
|
48
|
-
|
|
49
|
-
[helper close];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
- (void)testIfConfigurationTableIsCreated {
|
|
53
|
-
MAURGeolocationOpenHelper *helper = [[MAURGeolocationOpenHelper alloc] init];
|
|
54
|
-
FMDatabaseQueue *queue = [helper getWritableDatabase];
|
|
55
|
-
|
|
56
|
-
[queue inDatabase:^(FMDatabase *database) {
|
|
57
|
-
NSString *sql = [NSString stringWithFormat: @"SELECT count(name) FROM sqlite_master WHERE type='table' AND name='%@';", @CC_TABLE_NAME];
|
|
58
|
-
FMResultSet *rs = [database executeQuery:sql];
|
|
59
|
-
while([rs next]) {
|
|
60
|
-
XCTAssertEqual([rs intForColumnIndex:0], 1);
|
|
61
|
-
}
|
|
62
|
-
[rs close];
|
|
63
|
-
}];
|
|
64
|
-
|
|
65
|
-
[helper close];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
- (void)testIfDbIsUpgradedFromVersion2ToVersion3 {
|
|
69
|
-
FMDatabaseQueue *queue;
|
|
70
|
-
|
|
71
|
-
MAURSQLiteOpenHelper *baseHelper = [[MAURSQLiteOpenHelper alloc] init:@"cordova_bg_geolocation.db" version:2];
|
|
72
|
-
[baseHelper getWritableDatabase];
|
|
73
|
-
|
|
74
|
-
queue = [baseHelper getWritableDatabase];
|
|
75
|
-
[queue inDatabase:^(FMDatabase *database) {
|
|
76
|
-
NSString *sql = [NSString stringWithFormat: @"SELECT count(name) FROM sqlite_master WHERE type='table' AND name='%@';", @CC_TABLE_NAME];
|
|
77
|
-
FMResultSet *rs = [database executeQuery:sql];
|
|
78
|
-
while([rs next]) {
|
|
79
|
-
XCTAssertEqual([rs intForColumnIndex:0], 0);
|
|
80
|
-
}
|
|
81
|
-
[rs close];
|
|
82
|
-
}];
|
|
83
|
-
|
|
84
|
-
MAURGeolocationOpenHelper *helper = [[MAURGeolocationOpenHelper alloc] init];
|
|
85
|
-
queue = [helper getWritableDatabase];
|
|
86
|
-
|
|
87
|
-
[queue inDatabase:^(FMDatabase *database) {
|
|
88
|
-
NSString *sql = [NSString stringWithFormat: @"SELECT count(name) FROM sqlite_master WHERE type='table' AND name='%@';", @CC_TABLE_NAME];
|
|
89
|
-
FMResultSet *rs = [database executeQuery:sql];
|
|
90
|
-
while([rs next]) {
|
|
91
|
-
XCTAssertEqual([rs intForColumnIndex:0], 1);
|
|
92
|
-
}
|
|
93
|
-
[rs close];
|
|
94
|
-
}];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
- (void)testLocationTableSQLStatement {
|
|
98
|
-
NSString *sql = [MAURLocationContract createTableSQL];
|
|
99
|
-
XCTAssertEqualObjects(sql, @"CREATE TABLE IF NOT EXISTS location ( id INTEGER PRIMARY KEY AUTOINCREMENT , time REAL , accuracy REAL , speed REAL , bearing REAL , altitude REAL , latitude REAL , longitude REAL , provider TEXT , service_provider TEXT , valid INTEGER , recorded_at INTEGER );");
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
@end
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// MAURLocationTest.m
|
|
3
|
-
// BackgroundGeolocationTests
|
|
4
|
-
//
|
|
5
|
-
// Created by Marian Hello on 06/12/2017.
|
|
6
|
-
// Copyright © 2017 mauron85. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <XCTest/XCTest.h>
|
|
10
|
-
#import "MAURLocation.h"
|
|
11
|
-
|
|
12
|
-
@interface MAURLocationTest : XCTestCase
|
|
13
|
-
|
|
14
|
-
@end
|
|
15
|
-
|
|
16
|
-
@implementation MAURLocationTest
|
|
17
|
-
|
|
18
|
-
- (void)testLocationToArray {
|
|
19
|
-
MAURLocation *location = [[MAURLocation alloc] init];
|
|
20
|
-
location.locationId = [NSNumber numberWithInt:1];
|
|
21
|
-
location.time = [NSDate dateWithTimeIntervalSince1970:1000];
|
|
22
|
-
location.accuracy = [NSNumber numberWithInt:40];
|
|
23
|
-
location.altitudeAccuracy = [NSNumber numberWithInt:50];
|
|
24
|
-
location.speed = [NSNumber numberWithInt:60];
|
|
25
|
-
location.heading = [NSNumber numberWithInt:1];
|
|
26
|
-
location.altitude = [NSNumber numberWithInt:100];
|
|
27
|
-
location.latitude = [NSNumber numberWithInt:49];
|
|
28
|
-
location.longitude = [NSNumber numberWithInt:20];
|
|
29
|
-
location.provider = @"TEST";
|
|
30
|
-
location.locationProvider = [NSNumber numberWithInt:-1];
|
|
31
|
-
location.radius = [NSNumber numberWithInt:111];
|
|
32
|
-
location.isValid = @YES;
|
|
33
|
-
location.recordedAt = [NSDate dateWithTimeIntervalSince1970:2000];
|
|
34
|
-
|
|
35
|
-
NSArray *template = @[@"@time", @"@altitude", @"@longitude", @"@recordedAt", @"@accuracy", @"", @"custom", @"@heading", @"@speed", @"@provider", @"@id", @"@radius"];
|
|
36
|
-
|
|
37
|
-
NSArray *actual = [location toResultFromTemplate:template];
|
|
38
|
-
NSArray *expected = @[
|
|
39
|
-
[NSNumber numberWithDouble:([location.time timeIntervalSince1970] * 1000)],
|
|
40
|
-
location.altitude,
|
|
41
|
-
location.longitude,
|
|
42
|
-
[NSNumber numberWithDouble:([location.recordedAt timeIntervalSince1970] * 1000)],
|
|
43
|
-
location.accuracy,
|
|
44
|
-
@"",
|
|
45
|
-
@"custom",
|
|
46
|
-
location.heading,
|
|
47
|
-
location.speed,
|
|
48
|
-
location.provider,
|
|
49
|
-
location.locationId,
|
|
50
|
-
location.radius
|
|
51
|
-
];
|
|
52
|
-
|
|
53
|
-
XCTAssertEqualObjects(actual, expected);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
- (void)testLocationToDictionary {
|
|
57
|
-
MAURLocation *location = [[MAURLocation alloc] init];
|
|
58
|
-
location.locationId = [NSNumber numberWithInt:1];
|
|
59
|
-
location.time = [NSDate dateWithTimeIntervalSince1970:1000];
|
|
60
|
-
location.accuracy = [NSNumber numberWithInt:40];
|
|
61
|
-
location.altitudeAccuracy = [NSNumber numberWithInt:50];
|
|
62
|
-
location.speed = [NSNumber numberWithInt:60];
|
|
63
|
-
location.heading = [NSNumber numberWithInt:1];
|
|
64
|
-
location.altitude = [NSNumber numberWithInt:100];
|
|
65
|
-
location.latitude = [NSNumber numberWithInt:49];
|
|
66
|
-
location.longitude = [NSNumber numberWithInt:20];
|
|
67
|
-
location.provider = @"TEST";
|
|
68
|
-
location.locationProvider = [NSNumber numberWithInt:-1];
|
|
69
|
-
location.radius = [NSNumber numberWithInt:111];
|
|
70
|
-
location.isValid = @YES;
|
|
71
|
-
location.recordedAt = [NSDate dateWithTimeIntervalSince1970:2000];
|
|
72
|
-
|
|
73
|
-
NSDictionary *template = @{
|
|
74
|
-
@"id": @"@id",
|
|
75
|
-
@"t": @"@time",
|
|
76
|
-
@"acu": @"@accuracy",
|
|
77
|
-
@"aacu": @"@altitudeAccuracy",
|
|
78
|
-
@"s": @"@speed",
|
|
79
|
-
@"h": @"@heading",
|
|
80
|
-
@"alt": @"@altitude",
|
|
81
|
-
@"lat": @"@latitude",
|
|
82
|
-
@"lon": @"@longitude",
|
|
83
|
-
@"p": @"@provider",
|
|
84
|
-
@"lp": @"@locationProvider",
|
|
85
|
-
@"r": @"@radius",
|
|
86
|
-
@"rt": @"@recordedAt",
|
|
87
|
-
@"foo": @"bar",
|
|
88
|
-
@"at": @"@",
|
|
89
|
-
@"number": @12
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
NSDictionary *actual = [location toResultFromTemplate:template];
|
|
93
|
-
NSDictionary *expected = @{
|
|
94
|
-
@"id": location.locationId,
|
|
95
|
-
@"t": [NSNumber numberWithDouble:([location.time timeIntervalSince1970] * 1000)],
|
|
96
|
-
@"acu": location.accuracy,
|
|
97
|
-
@"aacu": location.altitudeAccuracy,
|
|
98
|
-
@"s": location.speed,
|
|
99
|
-
@"h": location.heading,
|
|
100
|
-
@"alt": location.altitude,
|
|
101
|
-
@"lat": location.latitude,
|
|
102
|
-
@"lon": location.longitude,
|
|
103
|
-
@"p": location.provider,
|
|
104
|
-
@"lp": location.locationProvider,
|
|
105
|
-
@"r": location.radius,
|
|
106
|
-
@"rt": [NSNumber numberWithDouble:([location.recordedAt timeIntervalSince1970] * 1000)],
|
|
107
|
-
@"foo": @"bar",
|
|
108
|
-
@"at": @"@",
|
|
109
|
-
@"number": @12
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
XCTAssertEqualObjects(actual, expected);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
- (void)testNestedLocationTemplateToArray {
|
|
116
|
-
MAURLocation *location = [[MAURLocation alloc] init];
|
|
117
|
-
location.locationId = [NSNumber numberWithInt:1];
|
|
118
|
-
location.time = [NSDate dateWithTimeIntervalSince1970:1000];
|
|
119
|
-
location.accuracy = [NSNumber numberWithInt:40];
|
|
120
|
-
location.altitudeAccuracy = [NSNumber numberWithInt:50];
|
|
121
|
-
location.speed = [NSNumber numberWithInt:60];
|
|
122
|
-
location.heading = [NSNumber numberWithInt:1];
|
|
123
|
-
location.altitude = [NSNumber numberWithInt:100];
|
|
124
|
-
location.latitude = [NSNumber numberWithInt:49];
|
|
125
|
-
location.longitude = [NSNumber numberWithInt:20];
|
|
126
|
-
location.provider = @"TEST";
|
|
127
|
-
location.locationProvider = [NSNumber numberWithInt:-1];
|
|
128
|
-
location.radius = [NSNumber numberWithInt:111];
|
|
129
|
-
location.isValid = @YES;
|
|
130
|
-
location.recordedAt = [NSDate dateWithTimeIntervalSince1970:2000];
|
|
131
|
-
|
|
132
|
-
NSArray *template = @[@"@time", @{ @"lat": @"@latitude", @"lon": @"@longitude" }, @"@recordedAt", @"@accuracy", @"", @"custom", @"@heading", @"@speed", @"@provider", @"@id", @"@radius"];
|
|
133
|
-
|
|
134
|
-
NSArray *actual = [location toResultFromTemplate:template];
|
|
135
|
-
NSArray *expected = @[
|
|
136
|
-
[NSNumber numberWithDouble:([location.time timeIntervalSince1970] * 1000)],
|
|
137
|
-
@{
|
|
138
|
-
@"lat": location.latitude,
|
|
139
|
-
@"lon": location.longitude,
|
|
140
|
-
},
|
|
141
|
-
[NSNumber numberWithDouble:([location.recordedAt timeIntervalSince1970] * 1000)],
|
|
142
|
-
location.accuracy,
|
|
143
|
-
@"",
|
|
144
|
-
@"custom",
|
|
145
|
-
location.heading,
|
|
146
|
-
location.speed,
|
|
147
|
-
location.provider,
|
|
148
|
-
location.locationId,
|
|
149
|
-
location.radius
|
|
150
|
-
];
|
|
151
|
-
|
|
152
|
-
XCTAssertEqualObjects(actual, expected);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
- (void)testNestedLocationTemplateToDictionary {
|
|
156
|
-
MAURLocation *location = [[MAURLocation alloc] init];
|
|
157
|
-
location.locationId = [NSNumber numberWithInt:1];
|
|
158
|
-
location.time = [NSDate dateWithTimeIntervalSince1970:1000];
|
|
159
|
-
location.accuracy = [NSNumber numberWithInt:40];
|
|
160
|
-
location.altitudeAccuracy = [NSNumber numberWithInt:50];
|
|
161
|
-
location.speed = [NSNumber numberWithInt:60];
|
|
162
|
-
location.heading = [NSNumber numberWithInt:1];
|
|
163
|
-
location.altitude = [NSNumber numberWithInt:100];
|
|
164
|
-
location.latitude = [NSNumber numberWithInt:49];
|
|
165
|
-
location.longitude = [NSNumber numberWithInt:20];
|
|
166
|
-
location.provider = @"TEST";
|
|
167
|
-
location.locationProvider = [NSNumber numberWithInt:-1];
|
|
168
|
-
location.radius = [NSNumber numberWithInt:111];
|
|
169
|
-
location.isValid = @YES;
|
|
170
|
-
location.recordedAt = [NSDate dateWithTimeIntervalSince1970:2000];
|
|
171
|
-
|
|
172
|
-
NSDictionary *template = @{
|
|
173
|
-
@"data": @{
|
|
174
|
-
@"id": @"@id",
|
|
175
|
-
@"t": @"@time",
|
|
176
|
-
@"acu": @"@accuracy",
|
|
177
|
-
@"aacu": @"@altitudeAccuracy",
|
|
178
|
-
@"s": @"@speed",
|
|
179
|
-
@"h": @"@heading",
|
|
180
|
-
@"alt": @"@altitude",
|
|
181
|
-
@"lat": @"@latitude",
|
|
182
|
-
@"lon": @"@longitude",
|
|
183
|
-
@"p": @"@provider",
|
|
184
|
-
@"lp": @"@locationProvider",
|
|
185
|
-
@"r": @"@radius",
|
|
186
|
-
@"rt": @"@recordedAt",
|
|
187
|
-
@"foo": @"bar",
|
|
188
|
-
@"at": @"@",
|
|
189
|
-
@"number": @12
|
|
190
|
-
}};
|
|
191
|
-
|
|
192
|
-
NSDictionary *actual = [location toResultFromTemplate:template];
|
|
193
|
-
NSDictionary *expected = @{
|
|
194
|
-
@"data": @{
|
|
195
|
-
@"id": location.locationId,
|
|
196
|
-
@"t": [NSNumber numberWithDouble:([location.time timeIntervalSince1970] * 1000)],
|
|
197
|
-
@"acu": location.accuracy,
|
|
198
|
-
@"aacu": location.altitudeAccuracy,
|
|
199
|
-
@"s": location.speed,
|
|
200
|
-
@"h": location.heading,
|
|
201
|
-
@"alt": location.altitude,
|
|
202
|
-
@"lat": location.latitude,
|
|
203
|
-
@"lon": location.longitude,
|
|
204
|
-
@"p": location.provider,
|
|
205
|
-
@"lp": location.locationProvider,
|
|
206
|
-
@"r": location.radius,
|
|
207
|
-
@"rt": [NSNumber numberWithDouble:([location.recordedAt timeIntervalSince1970] * 1000)],
|
|
208
|
-
@"foo": @"bar",
|
|
209
|
-
@"at": @"@",
|
|
210
|
-
@"number": @12
|
|
211
|
-
}};
|
|
212
|
-
|
|
213
|
-
XCTAssertEqualObjects(actual, expected);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
@end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// MAURLocationUploaderTest.m
|
|
3
|
-
// BackgroundGeolocationTests
|
|
4
|
-
//
|
|
5
|
-
// Created by Marian Hello on 07/07/16.
|
|
6
|
-
// Copyright © 2016 mauron85. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <XCTest/XCTest.h>
|
|
10
|
-
#import "MAURBackgroundSync.h"
|
|
11
|
-
#import "MAURSQLiteLocationDAO.h"
|
|
12
|
-
|
|
13
|
-
@interface BackgroundSyncTest : XCTestCase
|
|
14
|
-
|
|
15
|
-
@end
|
|
16
|
-
|
|
17
|
-
@implementation BackgroundSyncTest
|
|
18
|
-
|
|
19
|
-
- (void)setUp {
|
|
20
|
-
[super setUp];
|
|
21
|
-
MAURSQLiteLocationDAO *locationDAO = [MAURSQLiteLocationDAO sharedInstance];
|
|
22
|
-
[locationDAO clearDatabase];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
- (void)tearDown {
|
|
26
|
-
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
27
|
-
[super tearDown];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
- (void)testSync {
|
|
31
|
-
MAURSQLiteLocationDAO *locationDAO = [MAURSQLiteLocationDAO sharedInstance];
|
|
32
|
-
MAURLocation *location;
|
|
33
|
-
|
|
34
|
-
for (int i = 0; i < 10; i++) {
|
|
35
|
-
location = [[MAURLocation alloc] init];
|
|
36
|
-
location.time = [NSDate dateWithTimeIntervalSince1970:1465511097774.577+i];
|
|
37
|
-
location.accuracy = [NSNumber numberWithDouble:5+i];
|
|
38
|
-
location.speed = [NSNumber numberWithDouble:31.67+i];
|
|
39
|
-
location.heading = [NSNumber numberWithDouble:298.83+i];
|
|
40
|
-
location.altitude = [NSNumber numberWithDouble:940+i];
|
|
41
|
-
location.latitude = [NSNumber numberWithDouble:37.35439853+i];
|
|
42
|
-
location.longitude = [NSNumber numberWithDouble:-122.1100721+i];
|
|
43
|
-
location.provider = @"TEST";
|
|
44
|
-
location.locationProvider = [NSNumber numberWithInt:-1];
|
|
45
|
-
|
|
46
|
-
[locationDAO persistLocation:location];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
MAURBackgroundSync *uploader = [[MAURBackgroundSync alloc] init];
|
|
50
|
-
[uploader sync:@"http://192.168.81.15:3000/testSync" withTemplate:nil withHttpHeaders:nil];
|
|
51
|
-
sleep(5);
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// MAURLogReaderTest.m
|
|
3
|
-
// BackgroundGeolocationTests
|
|
4
|
-
//
|
|
5
|
-
// Created by Marian Hello on 13/04/2018.
|
|
6
|
-
// Copyright © 2018 mauron85. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <Foundation/Foundation.h>
|
|
10
|
-
#import <XCTest/XCTest.h>
|
|
11
|
-
#import "MAURLogReader.h"
|
|
12
|
-
|
|
13
|
-
@interface MAURLogReaderTest : XCTestCase
|
|
14
|
-
|
|
15
|
-
@end
|
|
16
|
-
|
|
17
|
-
@implementation MAURLogReaderTest
|
|
18
|
-
|
|
19
|
-
- (void)testSqlStatementDescending {
|
|
20
|
-
MAURLogReader *lr = [[MAURLogReader alloc] init];
|
|
21
|
-
NSString *stmt = [lr prepareSQL:100 fromLogEntryId:0 minLogLevel:14];
|
|
22
|
-
XCTAssertEqualObjects(stmt, @"SELECT [rowid], [context], [level], [message], [timestamp] FROM [logs] WHERE [level] <= 14 ORDER BY [timestamp] DESC, [rowid] DESC LIMIT 100;");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
- (void)testSqlStatementAscending {
|
|
26
|
-
MAURLogReader *lr = [[MAURLogReader alloc] init];
|
|
27
|
-
NSString *stmt = [lr prepareSQL:-100 fromLogEntryId:0 minLogLevel:14];
|
|
28
|
-
XCTAssertEqualObjects(stmt, @"SELECT [rowid], [context], [level], [message], [timestamp] FROM [logs] WHERE [level] <= 14 ORDER BY [timestamp] ASC, [rowid] ASC LIMIT 100;");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
- (void)testSqlStatementFromOffsetDescending {
|
|
32
|
-
MAURLogReader *lr = [[MAURLogReader alloc] init];
|
|
33
|
-
NSString *stmt = [lr prepareSQL:100 fromLogEntryId:100 minLogLevel:14];
|
|
34
|
-
XCTAssertEqualObjects(stmt, @"SELECT [rowid], [context], [level], [message], [timestamp] FROM [logs] WHERE [level] <= 14 AND [rowid] < 100 ORDER BY [timestamp] DESC, [rowid] DESC LIMIT 100;");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
- (void)testSqlStatementFromOffsetAscending {
|
|
38
|
-
MAURLogReader *lr = [[MAURLogReader alloc] init];
|
|
39
|
-
NSString *stmt = [lr prepareSQL:-100 fromLogEntryId:100 minLogLevel:14];
|
|
40
|
-
XCTAssertEqualObjects(stmt, @"SELECT [rowid], [context], [level], [message], [timestamp] FROM [logs] WHERE [level] <= 14 AND [rowid] > 100 ORDER BY [timestamp] ASC, [rowid] ASC LIMIT 100;");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@end
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// MAURSQLiteConfigurationDAOTest.m
|
|
3
|
-
// BackgroundGeolocationTests
|
|
4
|
-
//
|
|
5
|
-
// Created by Marian Hello on 01/12/2017.
|
|
6
|
-
// Copyright © 2017 mauron85. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <XCTest/XCTest.h>
|
|
10
|
-
#import "MAURConfig.h"
|
|
11
|
-
#import "MAURSQLiteConfigurationDAO.h"
|
|
12
|
-
|
|
13
|
-
@interface MAURSQLiteConfigurationDAOTest : XCTestCase
|
|
14
|
-
|
|
15
|
-
@end
|
|
16
|
-
|
|
17
|
-
@implementation MAURSQLiteConfigurationDAOTest
|
|
18
|
-
|
|
19
|
-
- (void)setUp {
|
|
20
|
-
[super setUp];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
- (void)tearDown {
|
|
24
|
-
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
25
|
-
[super tearDown];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
- (void)testEmptyConfiguration {
|
|
29
|
-
MAURSQLiteConfigurationDAO *dao = [MAURSQLiteConfigurationDAO sharedInstance];
|
|
30
|
-
XCTAssertTrue([dao clearDatabase]);
|
|
31
|
-
MAURConfig *config = [dao retrieveConfiguration];
|
|
32
|
-
XCTAssertNil(config);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
- (void)testPersistConfiguration {
|
|
36
|
-
MAURSQLiteConfigurationDAO *dao = [MAURSQLiteConfigurationDAO sharedInstance];
|
|
37
|
-
MAURConfig *config = [[MAURConfig alloc] init];
|
|
38
|
-
|
|
39
|
-
BOOL success = [dao persistConfiguration:config];
|
|
40
|
-
config = [dao retrieveConfiguration];
|
|
41
|
-
|
|
42
|
-
XCTAssertTrue(success);
|
|
43
|
-
XCTAssertFalse([config hasStationaryRadius]);
|
|
44
|
-
XCTAssertFalse([config hasDistanceFilter]);
|
|
45
|
-
XCTAssertFalse([config hasDesiredAccuracy]);
|
|
46
|
-
XCTAssertFalse([config hasDebug]);
|
|
47
|
-
XCTAssertFalse([config hasActivityType]);
|
|
48
|
-
XCTAssertFalse([config hasActivitiesInterval]);
|
|
49
|
-
XCTAssertFalse([config hasStopOnTerminate]);
|
|
50
|
-
XCTAssertFalse([config hasUrl]);
|
|
51
|
-
XCTAssertFalse([config hasSyncUrl]);
|
|
52
|
-
XCTAssertFalse([config hasSyncThreshold]);
|
|
53
|
-
XCTAssertFalse([config hasHttpHeaders]);
|
|
54
|
-
XCTAssertFalse([config hasSaveBatteryOnBackground]);
|
|
55
|
-
XCTAssertFalse([config hasMaxLocations]);
|
|
56
|
-
XCTAssertFalse([config hasPauseLocationUpdates]);
|
|
57
|
-
XCTAssertFalse([config hasLocationProvider]);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
- (void)testRetrieveConfiguration {
|
|
62
|
-
MAURSQLiteConfigurationDAO *dao = [MAURSQLiteConfigurationDAO sharedInstance];
|
|
63
|
-
MAURConfig *config = [[MAURConfig alloc] init];
|
|
64
|
-
config.stationaryRadius = [NSNumber numberWithInt:99];
|
|
65
|
-
config.distanceFilter = [NSNumber numberWithInt:20];
|
|
66
|
-
config.desiredAccuracy = [NSNumber numberWithInt:30];
|
|
67
|
-
config._debug = [NSNumber numberWithBool:YES];
|
|
68
|
-
config.activityType = @"MyActivity";
|
|
69
|
-
config.activitiesInterval = [NSNumber numberWithInt:1234];
|
|
70
|
-
config._stopOnTerminate = [NSNumber numberWithBool:YES];
|
|
71
|
-
config.url = @"http://server:3000/locations";
|
|
72
|
-
config.syncUrl = @"http://server:3000/sync";
|
|
73
|
-
config.syncThreshold = [NSNumber numberWithInt:100];
|
|
74
|
-
config.httpHeaders = [[NSMutableDictionary alloc] init];
|
|
75
|
-
[config.httpHeaders setObject:@"bar" forKey:@"foo"];
|
|
76
|
-
config._saveBatteryOnBackground = [NSNumber numberWithBool:YES];
|
|
77
|
-
config.maxLocations = [NSNumber numberWithInt:10];
|
|
78
|
-
config._pauseLocationUpdates = [NSNumber numberWithBool:YES];
|
|
79
|
-
config.locationProvider = [NSNumber numberWithInt:2];
|
|
80
|
-
|
|
81
|
-
[dao persistConfiguration:config];
|
|
82
|
-
MAURConfig *stored = [dao retrieveConfiguration];
|
|
83
|
-
|
|
84
|
-
XCTAssertEqualObjects(config.stationaryRadius, stored.stationaryRadius);
|
|
85
|
-
XCTAssertEqualObjects(config.distanceFilter, stored.distanceFilter);
|
|
86
|
-
XCTAssertEqualObjects(config.desiredAccuracy, stored.desiredAccuracy);
|
|
87
|
-
XCTAssertEqual([config isDebugging], [stored isDebugging]);
|
|
88
|
-
XCTAssertEqualObjects(config.activityType, stored.activityType);
|
|
89
|
-
XCTAssertEqualObjects(config.activitiesInterval, stored.activitiesInterval);
|
|
90
|
-
XCTAssertEqual([config stopOnTerminate], [stored stopOnTerminate]);
|
|
91
|
-
XCTAssertEqualObjects(config.url, stored.url);
|
|
92
|
-
XCTAssertEqualObjects(config.syncUrl, stored.syncUrl);
|
|
93
|
-
XCTAssertEqualObjects(config.syncThreshold, stored.syncThreshold);
|
|
94
|
-
XCTAssertEqualObjects(config.httpHeaders, stored.httpHeaders);
|
|
95
|
-
XCTAssertEqual([config saveBatteryOnBackground], [stored saveBatteryOnBackground]);
|
|
96
|
-
XCTAssertEqualObjects(config.maxLocations, stored.maxLocations);
|
|
97
|
-
XCTAssertEqual([config pauseLocationUpdates], [stored pauseLocationUpdates]);
|
|
98
|
-
XCTAssertEqualObjects(config.locationProvider, stored.locationProvider);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
@end
|