925096b79073fc66019db0913a04bc7d9f1dd24d
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2018 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         Qunfang Lin <qunfang.lin@samsung.com>
19
20 -->
21
22 <html>
23 <head>
24 <title>FileHandle_readStringNonBlocking_InvalidValuesError</title>
25 <meta charset="utf-8"/>
26 <script src="support/unitcommon.js"></script>
27 </head>
28 <body>
29 <div id="log"></div>
30 <script>
31 //==== TEST: FileHandle_readStringNonBlocking_InvalidValuesError
32 //==== LABEL Check if FileHandle::readStringNonBlocking() method with invalid count throws InvalidValuesError
33 //==== SPEC Tizen Web API:IO:Filesystem:FileHandle:readStringNonBlocking M
34 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/filesystem.html
35 //==== PRIORITY P2
36 //==== ONLOAD_DELAY 90
37 //==== TEST_CRITERIA MC
38
39 var t = async_test(document.title), readStringNonBlockingSuccess, readStringNonBlockingError, fileHandle, arch;
40
41 t.step(function () {
42     arch = tizen.systeminfo.getCapability("http://tizen.org/feature/platform.core.cpu.arch");
43     if (arch !== "aarch64" && arch !== "armv8") {
44         add_result_callback(function () {
45             try {
46                 fileHandle.close();
47                 tizen.filesystem.deleteFile("documents/file");
48             } catch (err) {
49             }
50         });
51
52         readStringNonBlockingSuccess = t.step_func(function (output) {
53         });
54
55         readStringNonBlockingError = t.step_func(function (error) {
56             assert_unreached("readStringNonBlocking() error callback invoked: name:" + error.name + "msg:" + error.message);
57         });
58
59         fileHandle = tizen.filesystem.openFile("documents/file", "w");
60         fileHandle.close();
61         fileHandle = tizen.filesystem.openFile("documents/file", "r");
62         assert_throws(INVALID_VALUES_EXCEPTION, function () {
63             fileHandle.readStringNonBlocking(readStringNonBlockingSuccess, readStringNonBlockingError, 0x7fffffffffffffff);
64         }, "InvalidValuesError should be thrown - invalid count.");
65     }
66     t.done();
67 });
68
69 </script>
70 </body>
71 </html>