d740dea827a5dc5840b8df0995e25b7eff672b65
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2014 Samsung Electronics Co., Ltd.
4
5 Licensed under the Apache License, Version 2.0 (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
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17 Authors:
18         Hyukin Kwon <hyukin.kwon@samsung.com>
19
20 -->
21 <html>
22 <head>
23 <title>HumanActivityMonitorOption_callbackInterval_type_GPS_default</title>
24 <meta charset="utf-8"/>
25 <script src="support/unitcommon.js"></script>
26 <script src="support/humanactivitymonitor_common.js"></script>
27 </head>
28 <body>
29 <div id="log"></div>
30 <script>
31 //==== TEST: HumanActivityMonitorOption_callbackInterval_type_GPS_default
32 //==== LABEL Check if method HumanActivityMonitorOption::callbackInterval works properly when set to null
33 //==== PRIORITY P1
34 //==== EXECUTION_TYPE manual
35 //==== SPEC Tizen Web API:System:HumanActivityMonitor:HumanActivityMonitorOption:callbackInterval A
36 //==== SPEC_URL TBD
37 //==== STEP Turn off the screen, then wait 150 seconds for the callback
38 //==== EXPECT Pass should be shown in the page after turn off the screen 150 seconds
39 //==== TEST_CRITERIA
40 //==== ONLOAD_DELAY 300
41
42 setup({"timeout": 400000});
43
44 var t = async_test(document.title, {"timeout": 400000}), onScreenStateChanged, changedCallback, startMeasure, endMeasure, humanActivityType = "GPS", cbFlag = 0;
45
46 t.step(function () {
47     add_result_callback(function () {
48         tizen.humanactivitymonitor.stop(humanActivityType);
49     });
50
51     changedCallback = t.step_func(function (gpsInfo) {
52         if (cbFlag == 1) {
53             endMeasure = new Date().getTime();
54             assert_approx_equals(endMeasure - startMeasure, 150000, 1000, "Callback should be invoked in given interval time.");
55             t.done();
56         }
57         if (cbFlag == 0) {
58             startMeasure = new Date().getTime();
59             cbFlag = 1;
60         }
61     });
62
63     onScreenStateChanged = t.step_func(function (previousState, changedState) {
64         if (changedState === "SCREEN_OFF") {
65             tizen.humanactivitymonitor.start(humanActivityType, changedCallback, null, {callbackInterval:null});
66             startMeasure = new Date().getTime();
67             tizen.power.unsetScreenStateChangeListener();
68         }
69     }); 
70
71     alert('Please turn off the screen');
72     tizen.power.setScreenStateChangeListener(onScreenStateChanged);
73 });
74
75 </script>
76 </body>
77 </html>