tizen 2.3 release
[framework/web/wearable/wrt-security.git] / tests / geolocation_security / geolocationSecurityTest / js / WAC2.0 / TestGeolocation.js
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16
17 function presenceTest()
18 {
19     TestEngine.test("Checking checking", true);
20     TestEngine.test("Checking Geolocation object", navigator.geolocation);
21
22     TestEngine.test("Checking function getCurrentPosition",
23         isFunction(navigator.geolocation.getCurrentPosition));
24 }
25
26 function accessTest()
27 {
28     try {
29         jsPrint("DEBUG POINT 0");
30         var callbackObject = TestEngine.registerCallback("getCurrentPositionCallback",
31                                                          localSuccessCallback,
32                                                          localErrorCallback);
33         jsPrint("DEBUG POINT 1");
34         navigator.geolocation.getCurrentPosition(
35             callbackObject.successCallback,
36             callbackObject.errorCallback);
37         jsPrint("DEBUG POINT 2");
38     } catch (error) {
39         jsPrint("DEBUG POINT 3");
40         TestEngine.logErr("Error in: navigator.geolocation.getCurrentPosition");
41     }
42     jsPrint("DEBUG POINT 4");
43 }
44
45 TestEngine.setTestSuiteName("[WAC2.0][Geolocation]", 30*1000); // 30 seconds
46 TestEngine.addTest(true, presenceTest, "[WAC2.0][Geolocation] Geolocation prenence test");
47 TestEngine.addTest(true, accessTest, "[WAC2.0][Geolocation] Access test");
48 TestEngine.setFinalCallback(function(){ jsPrint("closing window"); window.close(); });