@@ -51,59 +51,75 @@ class GNSSTestCase extends ImpTestCase {
51
51
52
52
function testGetValidTime () {
53
53
54
- // Valid results should come in at less than 10080 minutes
54
+ // Valid results should come in at less than "validDuration" minutes
55
55
56
56
// Set 'now' for consistent testing: 23/02/2021,15:57:00
57
57
local nowTime = {" year" : 2021 , " month" : 1 , " day" : 23 , " hour" : 15 , " min" : 57 };
58
58
59
- // Ten days ago -- data invalid
59
+ // Ten days ago and 7 day validity -- data invalid
60
60
local testDate = " 2021/02/13,15:00:00"
61
- local result = BG96_GPS. _getValidTime (testDate, nowTime);
61
+ local validDuration = 10080 // 7*24*60 minutes
62
+ local result = BG96_GPS. _getValidTime (testDate,validDuration,nowTime);
62
63
// this.info(result);
63
64
this . assertEqual (result, - 1 );
64
65
65
- // 4 hrs, 45 mins ago -- data valid
66
+ // Ten days ago and 11 day validity-- data valid
67
+ local testDate = " 2021/02/13,15:00:00"
68
+ local validDuration = 15840
69
+ local result = BG96_GPS. _getValidTime (testDate,validDuration,nowTime);
70
+ // this.info(result);
71
+ this . assert (result < validDuration && result != - 1 );
72
+
73
+ // 4 hrs, 45 mins ago and 7 day vailidy-- data valid
66
74
local testDate = " 2021/02/23,11:12:00"
67
- local result = BG96_GPS. _getValidTime (testDate, nowTime);
75
+ local validDuration = 10080
76
+ local result = BG96_GPS. _getValidTime (testDate,validDuration,nowTime);
68
77
// this.info(result);
69
- this . assert (result < 10080 && result != - 1 );
78
+ this . assert (result < validDuration && result != - 1 );
70
79
71
80
// Ancient time
72
81
testDate = " 1980/01/01,00:00:00"
73
- result = BG96_GPS. _getValidTime (testDate, nowTime);
82
+ local validDuration = 10080
83
+ local result = BG96_GPS. _getValidTime (testDate,validDuration,nowTime);
74
84
// this.info(result);
75
85
this . assertEqual (result, - 1 );
76
86
77
87
// Future time
78
88
testDate = " 2021/05/15,13:00:00"
79
- result = BG96_GPS. _getValidTime (testDate, nowTime);
89
+ local validDuration = 10080
90
+ local result = BG96_GPS. _getValidTime (testDate,validDuration,nowTime);
80
91
// this.info(result);
81
92
this . assertEqual (result, - 1 );
82
93
83
94
// Just in the zone
84
95
testDate = " 2021/02/16,16:01:00"
85
- result = BG96_GPS. _getValidTime (testDate, nowTime);
96
+ local validDuration = 10080
97
+ local result = BG96_GPS. _getValidTime (testDate,validDuration,nowTime);
98
+
86
99
// this.info(result);
87
- this . assert (result < 10080 && result != - 1 );
100
+ this . assert (result < validDuration && result != - 1 );
88
101
89
102
// Cross-month valid
90
103
nowTime = {" year" : 2021 , " month" : 4 , " day" : 4 , " hour" : 11 , " min" : 57 };
91
104
testDate = " 2021/04/30,12:12:00"
92
- result = BG96_GPS. _getValidTime (testDate, nowTime);
105
+ local validDuration = 10080
106
+ local result = BG96_GPS. _getValidTime (testDate,validDuration,nowTime);
93
107
// this.info(result);
94
- this . assert (result < 10080 && result != - 1 );
108
+ this . assert (result < validDuration && result != - 1 );
95
109
96
110
// Cross-month valid -- just
97
111
nowTime = {" year" : 2021 , " month" : 4 , " day" : 4 , " hour" : 11 , " min" : 57 };
98
112
testDate = " 2021/04/27,12:12:00"
99
- result = BG96_GPS. _getValidTime (testDate, nowTime);
113
+ local validDuration = 10080
114
+ local result = BG96_GPS. _getValidTime (testDate,validDuration,nowTime);
100
115
// this.info(result);
101
- this . assert (result < 10080 && result != - 1 );
116
+ this . assert (result < validDuration && result != - 1 );
102
117
103
118
// Cross-month invalid
104
119
nowTime = {" year" : 2021 , " month" : 4 , " day" : 4 , " hour" : 11 , " min" : 57 };
105
120
testDate = " 2021/04/27,09:22:00"
106
- result = BG96_GPS. _getValidTime (testDate, nowTime);
121
+ local validDuration = 10080
122
+ local result = BG96_GPS. _getValidTime (testDate,validDuration,nowTime);
107
123
// this.info(result);
108
124
this . assertEqual (result, - 1 );
109
125
}
@@ -112,6 +128,7 @@ class GNSSTestCase extends ImpTestCase {
112
128
function tearDown () {
113
129
114
130
// TEST WE CAN DISABLE GNSS
131
+ imp. sleep (4 ); // A small delay is introduced here to ensure there is enough time to update the assist data in the modem; otherwise, test3 will fail.
115
132
local result = BG96_GPS. disableGNSS ();
116
133
this . assert (result);
117
134
}
0 commit comments