[iot][deprecatedapi][fix getEmailService is not defined issue] 30/302230/2
authorchen <chen89.chen@samsung.com>
Mon, 4 Dec 2023 09:09:38 +0000 (17:09 +0800)
committerchen chen <chen89.chen@samsung.com>
Mon, 4 Dec 2023 09:06:16 +0000 (09:06 +0000)
Change-Id: Iba6620daccab6489c3de8e7e43b9019fe3427046
Signed-off-by: chen <chen89.chen@samsung.com>
13 files changed:
iot/tct-deprecatedapi-tizen-tests/NOTICE
iot/tct-deprecatedapi-tizen-tests/config.xml
iot/tct-deprecatedapi-tizen-tests/deprecatedapi/support/getJsonConf.js
iot/tct-deprecatedapi-tizen-tests/deprecatedapi/support/messaging_common.js [new file with mode: 0755]
iot/tct-deprecatedapi-tizen-tests/tests.css
iot/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_image.jpg [new file with mode: 0755]
iot/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_noise.mp3 [new file with mode: 0755]
mobile/tct-deprecatedapi-tizen-tests/NOTICE
mobile/tct-deprecatedapi-tizen-tests/config.xml
mobile/tct-deprecatedapi-tizen-tests/deprecatedapi/support/getJsonConf.js
mobile/tct-deprecatedapi-tizen-tests/deprecatedapi/support/messaging_common.js [new file with mode: 0755]
mobile/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_image.jpg [new file with mode: 0755]
mobile/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_noise.mp3 [new file with mode: 0755]

index 9a0903b256fda3ad6ddd624834f50fbcb461ad5e..d0dcad1347bc19ff01d730b0782e804f2ca12e3e 100755 (executable)
@@ -1,5 +1,11 @@
-Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
 Copyright (c) 2012 Intel Corporation.
 Except as noted, this software is licensed under Apache License, Version 2 or BSD-3-Clause License.
 Please, see the LICENSE.Apache-2.0 file for Apache License, Version 2 terms and conditions
 or the COPYING file for BSD-3-Clause License.
+Following resources are licensed under its own license.
+webapi-tizen-messaging-test_image.jpg,
+webapi-tizen-messaging-test_noise.mp3:
+Copyright (c) 2012 Samsung Electronics Co., Ltd. All right reserved.
+The above resource files are licensed under Creative Commons Attribution 3.0.
+Please see the LICENSE.CC-BY-3.0 for Creative Commons Attribution 3.0 terms and conditions.
index bc2fd36b799cf55106a37c5bbcf1016fe203a842..aac70b967e98edc1d6b6a1cd257d3bd03e21ee6c 100755 (executable)
   <tizen:privilege name="http://tizen.org/privilege/mediacontroller.server"/>
   <tizen:privilege name="http://tizen.org/privilege/healthinfo"/>
   <tizen:privilege name="http://tizen.org/privilege/location"/>
+  <tizen:privilege name="http://tizen.org/privilege/messaging.read"/>
+  <tizen:privilege name="http://tizen.org/privilege/messaging.write"/>
   <tizen:privilege name="http://tizen.org/privilege/internet"/>
+  <feature name="http://tizen.org/feature/network.telephony"/>
+  <feature name="http://tizen.org/feature/network.telephony.mms"/>
   <feature name="http://tizen.org/feature/sensor.activity_recognition"/>
   <feature name="http://tizen.org/feature/sensor.gesture_recognition"/>
   <icon src="icon.png" height="117" width="117"/>
index 84b98e40564724db2dd867486d018e406cb490f0..3a516587c834be3fede69b4e3b225fed35955a12 100755 (executable)
@@ -44,6 +44,7 @@ $.ajax({
     CONTENT_DIR = path2[1];
     CONTENT_PATH = CONTENT_DIR + "/Downloads/";
     TEST_CONTENT_PATH = CONTENT_DIR + "/Downloads/tct-deprecatedapi-tizen-tests/";
+    TEST_DIR = "file://" + RESOURCE_DIR + "/tct-deprecatedapi-tizen-tests/";
   }
 });
 
@@ -55,5 +56,7 @@ $.ajax({
   success:function(data){
        DATE_FORMAT=data[0]["DATE_FORMAT"];
        TIME_FORMAT=data[0]["TIME_FORMAT"];
+       TEST_EMAIL_RECIPIENT_1 = data[0]["EMAIL_RECIPIENT_1"];
+       TEST_EMAIL_RECIPIENT_2 = data[0]["EMAIL_RECIPIENT_2"];
   }
 })
diff --git a/iot/tct-deprecatedapi-tizen-tests/deprecatedapi/support/messaging_common.js b/iot/tct-deprecatedapi-tizen-tests/deprecatedapi/support/messaging_common.js
new file mode 100755 (executable)
index 0000000..1ba046d
--- /dev/null
@@ -0,0 +1,249 @@
+/*
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd.
+
+Licensed under the Apache License, Version 2.0 (the License);
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+
+Authors:
+        JungHyuk, Park <junghyuk.park@samsung.com>
+
+*/
+
+var TEST_EMAIL_RECIPIENT_1 = ""; // this variable MUST be set before executing tests
+var TEST_EMAIL_RECIPIENT_2 = ""; // this variable MUST be set before executing tests
+
+var EMAIL_SYNC_INTERVAL = 10000;
+var EMAIL_RESEND_LIMIT = 30;
+var EMAIL_RESYNC_LIMIT = 30;
+
+var TYPE_MISMATCH_ERR  = 'TypeMismatchError';
+
+var MESSAGE_FOLDER_TYPE_INBOX = "INBOX";
+
+var TEST_DIR = "";
+var MESSAGE_ATTACHMENT_IMAGE_PATH = TEST_DIR + "webapi-tizen-messaging-test_image.jpg";
+var MESSAGE_ATTACHMENT_IMAGE_MIME_TYPE = "image/jpg";
+
+var MESSAGE_ATTACHMENT_SOUND_PATH = TEST_DIR + "webapi-tizen-messaging-test_noise.mp3";
+var MESSAGE_ATTACHMENT_SOUND_MIME_TYPE = "audio/mp3";
+
+var MESSAGE_BODY_PLAIN = "Sample Plain Body"
+var MESSAGE_BODY_HTML = "<p>Sample HTML Body</p>"
+
+var generateSubject = function () {
+    var datetime = new Date().getTime();
+    var count = 0;
+    var subject = function(datetime, count) {
+        return "sample subject: "+datetime+"-"+count;
+    }
+
+    generateSubject = function () {
+        count++;
+        return subject(datetime, count);
+    }
+    return subject(datetime, count);
+};
+
+
+function createSimpleMessageTo(recipient) {
+    return new tizen.Message("messaging.email", {
+        subject: generateSubject(),
+        to: [recipient],
+        plainBody: MESSAGE_BODY_PLAIN
+    }); 
+}
+
+function sendMessage(t, service, msg, onSuccess, onError) {
+    var sendError, requestSending, resend=0;
+
+    sendError = t.step_func(function (error) {
+        if (resend <= EMAIL_RESEND_LIMIT) {
+            setTimeout(requestSending, 5000);
+        } else {
+            onError(error);
+        }
+    });
+
+    requestSending = t.step_func(function () {
+        resend++;
+        service.sendMessage(msg, onSuccess, sendError);
+    });
+
+    requestSending();
+}
+
+
+function sync(t, service, onSuccess, onError, limit) {
+    var syncError, requestSync, argc=arguments.length, resync=0;
+
+    syncError = t.step_func(function (error) {
+        if (resync <= EMAIL_RESYNC_LIMIT) {
+            setTimeout(requestSync, 5000);
+        } else {
+            onError(error);
+        }
+    });
+
+    requestSync = t.step_func(function () {
+        resync++;
+
+        if (argc >= 5) {
+            service.sync(onSuccess, syncError, limit);
+        } else  {
+            service.sync(onSuccess, syncError);
+        }
+    });
+
+    setTimeout(t.step_func(function () {
+        requestSync();
+    }), EMAIL_SYNC_INTERVAL);
+}
+
+
+function getEmailService(t, onSuccess, onError) {
+    t.step(function () {
+        tizen.messaging.getMessageServices(
+            "messaging.email",
+            t.step_func(function (services) {
+                assert_type(services, "array", "Not an array");
+                assert_greater_than(services.length, 0, "Received empty services array");
+                onSuccess(services[0]);
+            }),
+            onError
+        );
+    });
+}
+
+
+function message_conversation_test(t, onReady) {
+    var service, message, serviceSuccess, serviceError, addDraftSuccess, addDraftError,
+    filterConversation, findConversationsSuccess, findConversationsError;
+
+    findConversationsSuccess = t.step_func(function (conversations) {
+        assert_equals(conversations.length, 1, "Incorrect number of conversations found");
+        assert_equals(conversations[0].id, message.conversationId, "Found incorrect convesation");
+        t.step_func(onReady)(service, message, conversations[0]);
+    });
+
+    findConversationsError = t.step_func(function (error) {
+        assert_unreached("findConversations() error callback: name:" + error.name + ", msg:" + error.message);
+    });
+
+    addDraftSuccess = t.step_func(function () {
+        filterConversation = new tizen.AttributeFilter("id", "EXACTLY", message.conversationId);
+        service.messageStorage.findConversations(filterConversation, findConversationsSuccess, findConversationsError);
+    });
+
+    addDraftError = t.step_func(function (error) {
+        assert_unreached("addDraftMessage() error callback: name:" + error.name + ", msg:" + error.message);
+    });
+
+    serviceSuccess = t.step_func(function (emailService) {
+        service = emailService;
+
+        message = new tizen.Message("messaging.email", {
+            subject: generateSubject(),
+            to: [TEST_EMAIL_RECIPIENT_2],
+            cc: [TEST_EMAIL_RECIPIENT_1],
+            bcc: [TEST_EMAIL_RECIPIENT_1],
+            plainBody: MESSAGE_BODY_PLAIN,
+            htmlBody: MESSAGE_BODY_HTML,
+            isHighPriority: false
+        }); 
+
+        assert_true("conversationId" in message, "No 'conversationId' attribute in message");
+        assert_equals(message.conversationId, null, "message.conversationId default value should be null");
+        check_readonly(message, "conversationId", null, "object", "12345");
+
+        service.messageStorage.addDraftMessage(message, addDraftSuccess, addDraftError);
+    });
+
+    serviceError = t.step_func(function (error) {
+        assert_unreached("getEmailService() error callback: name:" + error.name + ", msg:" + error.message);
+    });
+
+    t.step(function () {
+        getEmailService(t, serviceSuccess, serviceError);
+    });
+}
+
+
+function findFolders(t, service, onSuccess, onError) {
+    var filter = new tizen.AttributeFilter("serviceId", "EXACTLY", service.id);
+    service.messageStorage.findFolders(filter, onSuccess, onError);
+}
+
+
+function getInboxFolder(t, folders) {
+    var i, inboxFolder;
+    t.step(function () {
+        for(i = 0; i < folders.length; i++) {
+            if (folders[i].type === MESSAGE_FOLDER_TYPE_INBOX) {
+                inboxFolder = folders[i];
+                break;
+            }
+        }
+        assert_not_equals(inboxFolder, undefined, "Inbox folder not found");
+    });
+    return inboxFolder;
+}
+
+function findMessages(t, service, folder, subject, onSuccess, onError) {
+    var subjectFilter, folderFilter, compositefilter;
+
+    t.step(function() {
+        folderFilter = new tizen.AttributeFilter("folderId", "EXACTLY", folder.id);
+        subjectFilter = new tizen.AttributeFilter("subject", "EXACTLY", subject);
+        compositefilter = new tizen.CompositeFilter("INTERSECTION", [folderFilter, subjectFilter]);
+        service.messageStorage.findMessages(compositefilter, onSuccess, onError);
+    });
+}
+
+function assert_message_equals(t, messages, message, folder) {
+    t.step(function() {
+        assert_type(messages, "array", "Not an array");
+        assert_equals(messages.length, 1, "incorrect messages found");
+        assert_true(messages[0] instanceof tizen.Message, "Not a Message");
+        assert_equals(messages[0].subject, message.subject, "Incorrect subject.");
+
+        if (arguments.length >= 4) {
+            assert_equals(messages[0].folderId, folder.id, "Incorrect folderId.");
+        }
+    });
+}
+
+function assert_draft_message_equals(t, messages, message) {
+    t.step(function() {
+        assert_type(messages, "array", "Not an array");
+        assert_equals(messages.length, 1, "incorrect messages found");
+        assert_true(messages[0] instanceof tizen.Message, "Not a Message");
+        assert_equals(messages[0].id, message.id, "Incorrect folderId.");
+        assert_equals(messages[0].subject, message.subject, "Incorrect subject.");
+    });
+}
+
+function assert_inbox_message_equals(t, messages, message, folder) {
+    t.step(function() {
+        assert_type(messages, "array", "Not an array");
+        assert_equals(messages.length, 1, "incorrect messages found");
+        assert_true(messages[0] instanceof tizen.Message, "Not a Message");
+        assert_equals(messages[0].subject, message.subject, "Incorrect subject.");
+        assert_equals(messages[0].folderId, folder.id, "Incorrect folderId.");
+    });
+}
+
+// change TEST_EMAIL_RECIPIENT_1 and TEST_EMAIL_RECIPIENT_2
+document.write('<script src="../webrunner/jquery-1.10.2.min.js"></script>');
+document.write('<script src="support/getJsonConf.js"></script>');
index c2ba69b3d28d5acb800f7f0dcf380de51dc283d3..135fa57d318c5a803ce2342b1f566dd949e0ebc3 100755 (executable)
-@charset "UTF-8";\r
-/* CSS Document */\r
-#testcasepage div,\r
-#testcasepage h1,\r
-#testcasepage p,\r
-#testcasepage table,\r
-#testcasepage tr,\r
-#testcasepage th,\r
-#testcasepage td {\r
-  margin: 0;\r
-  padding: 0;\r
-  border: 0;\r
-  font-weight: inherit;\r
-  font-style: inherit;\r
-  font-size: 0.96em;\r
-  font-family: arial;\r
-  vertical-align: baseline;\r
-}\r
-\r
-#testcasepage p {\r
-  text-align: left;\r
-}\r
-\r
-#suite_title {\r
-  text-align: left;\r
-}\r
-\r
-#btc {\r
-  text-align: right;\r
-}\r
-\r
-#testcasepage table {\r
-  border-collapse: separate;\r
-  border-spacing: 0;\r
-  margin-bottom: 1.4em;\r
-  vertical-align: middle;\r
-}\r
-\r
-#testcasepage th,\r
-#testcasepage td {\r
-  text-align: left;\r
-  font-weight: normal;\r
-  padding: 4px 10px 4px 5px;\r
-  vertical-align: middle;\r
-}\r
-\r
-#cases table {\r
-  width: 101%;\r
-}\r
-\r
-#fail_cases table {\r
-  width: 101%;\r
-}\r
-\r
-#title table {\r
-  width: 101%;\r
-}\r
-\r
-#device table {\r
-  width: 50%;\r
-}\r
-\r
-#summary table {\r
-  width: 50%;\r
-}\r
-\r
-#testcasepage th {\r
-  border-bottom: 1px solid #000;\r
-  background-color: #AAAAAA;\r
-  border-left: 1px solid #000;\r
-  border-top: 1px solid #000;\r
-  color: #000;\r
-  font-weight: bold;\r
-  vertical-align: bottom;\r
-}\r
-\r
-#testcasepage th:last-child,\r
-#testcasepage td:last-child {\r
-  border-right: 1px solid #000;\r
-}\r
-\r
-#testcasepage td {\r
-  border-left: 1px solid;\r
-  font-weight: normal;\r
-  border-bottom: 1px solid;\r
-}\r
-\r
-#testcasepage td.yellow_rate {\r
-  background-color: #ffcc00;\r
-}\r
-\r
-#testcasepage td.green_rate {\r
-  background-color: #33cc33;\r
-}\r
-\r
-#testcasepage td.dgreen_rate {\r
-  background-color: #339933;\r
-}\r
-\r
-#testcasepage td.red_rate {\r
-  background-color: #FF3333;\r
-}\r
-\r
-#title table,\r
-#title tr,\r
-#title td {\r
-  border-left: none;\r
-  border-bottom: none;\r
-  text-align: center;\r
-}\r
-\r
-#title td:last-child {\r
-  border-right: none;\r
-}\r
-\r
-#testcasepage h1 {\r
-  font-size: 2em;\r
-  font-family: Arial, sans-serif;\r
-  font-weight: bold;\r
-  line-height: 1;\r
-  color: #000;\r
-  margin-bottom: 0.75em;\r
-  padding-top: 0.25em;\r
-  font-weight: bold;\r
-}\r
-\r
-#goTopBtn {\r
-  right: 0px;\r
-  bottom: 0px;\r
-  position: fixed; +position: absolute;\r
-  top: expression(parseInt(document.body.scrollTop) + document.body.clientHeight - 40);\r
-}\r
+@charset "UTF-8";
+/* CSS Document */
+#testcasepage div,
+#testcasepage h1,
+#testcasepage p,
+#testcasepage table,
+#testcasepage tr,
+#testcasepage th,
+#testcasepage td {
+  margin: 0;
+  padding: 0;
+  border: 0;
+  font-weight: inherit;
+  font-style: inherit;
+  font-size: 0.96em;
+  font-family: arial;
+  vertical-align: baseline;
+}
+
+#testcasepage p {
+  text-align: left;
+}
+
+#suite_title {
+  text-align: left;
+}
+
+#btc {
+  text-align: right;
+}
+
+#testcasepage table {
+  border-collapse: separate;
+  border-spacing: 0;
+  margin-bottom: 1.4em;
+  vertical-align: middle;
+}
+
+#testcasepage th,
+#testcasepage td {
+  text-align: left;
+  font-weight: normal;
+  padding: 4px 10px 4px 5px;
+  vertical-align: middle;
+}
+
+#cases table {
+  width: 101%;
+}
+
+#fail_cases table {
+  width: 101%;
+}
+
+#title table {
+  width: 101%;
+}
+
+#device table {
+  width: 50%;
+}
+
+#summary table {
+  width: 50%;
+}
+
+#testcasepage th {
+  border-bottom: 1px solid #000;
+  background-color: #AAAAAA;
+  border-left: 1px solid #000;
+  border-top: 1px solid #000;
+  color: #000;
+  font-weight: bold;
+  vertical-align: bottom;
+}
+
+#testcasepage th:last-child,
+#testcasepage td:last-child {
+  border-right: 1px solid #000;
+}
+
+#testcasepage td {
+  border-left: 1px solid;
+  font-weight: normal;
+  border-bottom: 1px solid;
+}
+
+#testcasepage td.yellow_rate {
+  background-color: #ffcc00;
+}
+
+#testcasepage td.green_rate {
+  background-color: #33cc33;
+}
+
+#testcasepage td.dgreen_rate {
+  background-color: #339933;
+}
+
+#testcasepage td.red_rate {
+  background-color: #FF3333;
+}
+
+#title table,
+#title tr,
+#title td {
+  border-left: none;
+  border-bottom: none;
+  text-align: center;
+}
+
+#title td:last-child {
+  border-right: none;
+}
+
+#testcasepage h1 {
+  font-size: 2em;
+  font-family: Arial, sans-serif;
+  font-weight: bold;
+  line-height: 1;
+  color: #000;
+  margin-bottom: 0.75em;
+  padding-top: 0.25em;
+  font-weight: bold;
+}
+
+#goTopBtn {
+  right: 0px;
+  bottom: 0px;
+  position: fixed; +position: absolute;
+  top: expression(parseInt(document.body.scrollTop) + document.body.clientHeight - 40);
+}
diff --git a/iot/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_image.jpg b/iot/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_image.jpg
new file mode 100755 (executable)
index 0000000..7a57964
Binary files /dev/null and b/iot/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_image.jpg differ
diff --git a/iot/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_noise.mp3 b/iot/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_noise.mp3
new file mode 100755 (executable)
index 0000000..d4d1659
Binary files /dev/null and b/iot/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_noise.mp3 differ
index 9a0903b256fda3ad6ddd624834f50fbcb461ad5e..e11c43a1c23545ee87bbab08d46829f24eb6c300 100755 (executable)
@@ -1,5 +1,11 @@
-Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
-Copyright (c) 2012 Intel Corporation.
-Except as noted, this software is licensed under Apache License, Version 2 or BSD-3-Clause License.
-Please, see the LICENSE.Apache-2.0 file for Apache License, Version 2 terms and conditions
-or the COPYING file for BSD-3-Clause License.
+Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.\r
+Copyright (c) 2012 Intel Corporation.\r
+Except as noted, this software is licensed under Apache License, Version 2 or BSD-3-Clause License.\r
+Please, see the LICENSE.Apache-2.0 file for Apache License, Version 2 terms and conditions\r
+or the COPYING file for BSD-3-Clause License.\r
+Following resources are licensed under its own license.\r
+webapi-tizen-messaging-test_image.jpg,\r
+webapi-tizen-messaging-test_noise.mp3:\r
+Copyright (c) 2012 Samsung Electronics Co., Ltd. All right reserved.\r
+The above resource files are licensed under Creative Commons Attribution 3.0.\r
+Please see the LICENSE.CC-BY-3.0 for Creative Commons Attribution 3.0 terms and conditions.\r
index 4fbbcc1436ee0a0f7792bad0bff379a17862e5de..aac70b967e98edc1d6b6a1cd257d3bd03e21ee6c 100755 (executable)
@@ -12,9 +12,9 @@
   <tizen:privilege name="http://tizen.org/privilege/mediacontroller.server"/>
   <tizen:privilege name="http://tizen.org/privilege/healthinfo"/>
   <tizen:privilege name="http://tizen.org/privilege/location"/>
+  <tizen:privilege name="http://tizen.org/privilege/messaging.read"/>
+  <tizen:privilege name="http://tizen.org/privilege/messaging.write"/>
   <tizen:privilege name="http://tizen.org/privilege/internet"/>
-  <tizen:privilege name="http://tizen.org/privilege/messaging.write "/>
-  <tizen:privilege name="http://tizen.org/privilege/messaging.read "/>
   <feature name="http://tizen.org/feature/network.telephony"/>
   <feature name="http://tizen.org/feature/network.telephony.mms"/>
   <feature name="http://tizen.org/feature/sensor.activity_recognition"/>
index 84b98e40564724db2dd867486d018e406cb490f0..3a516587c834be3fede69b4e3b225fed35955a12 100755 (executable)
@@ -44,6 +44,7 @@ $.ajax({
     CONTENT_DIR = path2[1];
     CONTENT_PATH = CONTENT_DIR + "/Downloads/";
     TEST_CONTENT_PATH = CONTENT_DIR + "/Downloads/tct-deprecatedapi-tizen-tests/";
+    TEST_DIR = "file://" + RESOURCE_DIR + "/tct-deprecatedapi-tizen-tests/";
   }
 });
 
@@ -55,5 +56,7 @@ $.ajax({
   success:function(data){
        DATE_FORMAT=data[0]["DATE_FORMAT"];
        TIME_FORMAT=data[0]["TIME_FORMAT"];
+       TEST_EMAIL_RECIPIENT_1 = data[0]["EMAIL_RECIPIENT_1"];
+       TEST_EMAIL_RECIPIENT_2 = data[0]["EMAIL_RECIPIENT_2"];
   }
 })
diff --git a/mobile/tct-deprecatedapi-tizen-tests/deprecatedapi/support/messaging_common.js b/mobile/tct-deprecatedapi-tizen-tests/deprecatedapi/support/messaging_common.js
new file mode 100755 (executable)
index 0000000..1ba046d
--- /dev/null
@@ -0,0 +1,249 @@
+/*
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd.
+
+Licensed under the Apache License, Version 2.0 (the License);
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+
+Authors:
+        JungHyuk, Park <junghyuk.park@samsung.com>
+
+*/
+
+var TEST_EMAIL_RECIPIENT_1 = ""; // this variable MUST be set before executing tests
+var TEST_EMAIL_RECIPIENT_2 = ""; // this variable MUST be set before executing tests
+
+var EMAIL_SYNC_INTERVAL = 10000;
+var EMAIL_RESEND_LIMIT = 30;
+var EMAIL_RESYNC_LIMIT = 30;
+
+var TYPE_MISMATCH_ERR  = 'TypeMismatchError';
+
+var MESSAGE_FOLDER_TYPE_INBOX = "INBOX";
+
+var TEST_DIR = "";
+var MESSAGE_ATTACHMENT_IMAGE_PATH = TEST_DIR + "webapi-tizen-messaging-test_image.jpg";
+var MESSAGE_ATTACHMENT_IMAGE_MIME_TYPE = "image/jpg";
+
+var MESSAGE_ATTACHMENT_SOUND_PATH = TEST_DIR + "webapi-tizen-messaging-test_noise.mp3";
+var MESSAGE_ATTACHMENT_SOUND_MIME_TYPE = "audio/mp3";
+
+var MESSAGE_BODY_PLAIN = "Sample Plain Body"
+var MESSAGE_BODY_HTML = "<p>Sample HTML Body</p>"
+
+var generateSubject = function () {
+    var datetime = new Date().getTime();
+    var count = 0;
+    var subject = function(datetime, count) {
+        return "sample subject: "+datetime+"-"+count;
+    }
+
+    generateSubject = function () {
+        count++;
+        return subject(datetime, count);
+    }
+    return subject(datetime, count);
+};
+
+
+function createSimpleMessageTo(recipient) {
+    return new tizen.Message("messaging.email", {
+        subject: generateSubject(),
+        to: [recipient],
+        plainBody: MESSAGE_BODY_PLAIN
+    }); 
+}
+
+function sendMessage(t, service, msg, onSuccess, onError) {
+    var sendError, requestSending, resend=0;
+
+    sendError = t.step_func(function (error) {
+        if (resend <= EMAIL_RESEND_LIMIT) {
+            setTimeout(requestSending, 5000);
+        } else {
+            onError(error);
+        }
+    });
+
+    requestSending = t.step_func(function () {
+        resend++;
+        service.sendMessage(msg, onSuccess, sendError);
+    });
+
+    requestSending();
+}
+
+
+function sync(t, service, onSuccess, onError, limit) {
+    var syncError, requestSync, argc=arguments.length, resync=0;
+
+    syncError = t.step_func(function (error) {
+        if (resync <= EMAIL_RESYNC_LIMIT) {
+            setTimeout(requestSync, 5000);
+        } else {
+            onError(error);
+        }
+    });
+
+    requestSync = t.step_func(function () {
+        resync++;
+
+        if (argc >= 5) {
+            service.sync(onSuccess, syncError, limit);
+        } else  {
+            service.sync(onSuccess, syncError);
+        }
+    });
+
+    setTimeout(t.step_func(function () {
+        requestSync();
+    }), EMAIL_SYNC_INTERVAL);
+}
+
+
+function getEmailService(t, onSuccess, onError) {
+    t.step(function () {
+        tizen.messaging.getMessageServices(
+            "messaging.email",
+            t.step_func(function (services) {
+                assert_type(services, "array", "Not an array");
+                assert_greater_than(services.length, 0, "Received empty services array");
+                onSuccess(services[0]);
+            }),
+            onError
+        );
+    });
+}
+
+
+function message_conversation_test(t, onReady) {
+    var service, message, serviceSuccess, serviceError, addDraftSuccess, addDraftError,
+    filterConversation, findConversationsSuccess, findConversationsError;
+
+    findConversationsSuccess = t.step_func(function (conversations) {
+        assert_equals(conversations.length, 1, "Incorrect number of conversations found");
+        assert_equals(conversations[0].id, message.conversationId, "Found incorrect convesation");
+        t.step_func(onReady)(service, message, conversations[0]);
+    });
+
+    findConversationsError = t.step_func(function (error) {
+        assert_unreached("findConversations() error callback: name:" + error.name + ", msg:" + error.message);
+    });
+
+    addDraftSuccess = t.step_func(function () {
+        filterConversation = new tizen.AttributeFilter("id", "EXACTLY", message.conversationId);
+        service.messageStorage.findConversations(filterConversation, findConversationsSuccess, findConversationsError);
+    });
+
+    addDraftError = t.step_func(function (error) {
+        assert_unreached("addDraftMessage() error callback: name:" + error.name + ", msg:" + error.message);
+    });
+
+    serviceSuccess = t.step_func(function (emailService) {
+        service = emailService;
+
+        message = new tizen.Message("messaging.email", {
+            subject: generateSubject(),
+            to: [TEST_EMAIL_RECIPIENT_2],
+            cc: [TEST_EMAIL_RECIPIENT_1],
+            bcc: [TEST_EMAIL_RECIPIENT_1],
+            plainBody: MESSAGE_BODY_PLAIN,
+            htmlBody: MESSAGE_BODY_HTML,
+            isHighPriority: false
+        }); 
+
+        assert_true("conversationId" in message, "No 'conversationId' attribute in message");
+        assert_equals(message.conversationId, null, "message.conversationId default value should be null");
+        check_readonly(message, "conversationId", null, "object", "12345");
+
+        service.messageStorage.addDraftMessage(message, addDraftSuccess, addDraftError);
+    });
+
+    serviceError = t.step_func(function (error) {
+        assert_unreached("getEmailService() error callback: name:" + error.name + ", msg:" + error.message);
+    });
+
+    t.step(function () {
+        getEmailService(t, serviceSuccess, serviceError);
+    });
+}
+
+
+function findFolders(t, service, onSuccess, onError) {
+    var filter = new tizen.AttributeFilter("serviceId", "EXACTLY", service.id);
+    service.messageStorage.findFolders(filter, onSuccess, onError);
+}
+
+
+function getInboxFolder(t, folders) {
+    var i, inboxFolder;
+    t.step(function () {
+        for(i = 0; i < folders.length; i++) {
+            if (folders[i].type === MESSAGE_FOLDER_TYPE_INBOX) {
+                inboxFolder = folders[i];
+                break;
+            }
+        }
+        assert_not_equals(inboxFolder, undefined, "Inbox folder not found");
+    });
+    return inboxFolder;
+}
+
+function findMessages(t, service, folder, subject, onSuccess, onError) {
+    var subjectFilter, folderFilter, compositefilter;
+
+    t.step(function() {
+        folderFilter = new tizen.AttributeFilter("folderId", "EXACTLY", folder.id);
+        subjectFilter = new tizen.AttributeFilter("subject", "EXACTLY", subject);
+        compositefilter = new tizen.CompositeFilter("INTERSECTION", [folderFilter, subjectFilter]);
+        service.messageStorage.findMessages(compositefilter, onSuccess, onError);
+    });
+}
+
+function assert_message_equals(t, messages, message, folder) {
+    t.step(function() {
+        assert_type(messages, "array", "Not an array");
+        assert_equals(messages.length, 1, "incorrect messages found");
+        assert_true(messages[0] instanceof tizen.Message, "Not a Message");
+        assert_equals(messages[0].subject, message.subject, "Incorrect subject.");
+
+        if (arguments.length >= 4) {
+            assert_equals(messages[0].folderId, folder.id, "Incorrect folderId.");
+        }
+    });
+}
+
+function assert_draft_message_equals(t, messages, message) {
+    t.step(function() {
+        assert_type(messages, "array", "Not an array");
+        assert_equals(messages.length, 1, "incorrect messages found");
+        assert_true(messages[0] instanceof tizen.Message, "Not a Message");
+        assert_equals(messages[0].id, message.id, "Incorrect folderId.");
+        assert_equals(messages[0].subject, message.subject, "Incorrect subject.");
+    });
+}
+
+function assert_inbox_message_equals(t, messages, message, folder) {
+    t.step(function() {
+        assert_type(messages, "array", "Not an array");
+        assert_equals(messages.length, 1, "incorrect messages found");
+        assert_true(messages[0] instanceof tizen.Message, "Not a Message");
+        assert_equals(messages[0].subject, message.subject, "Incorrect subject.");
+        assert_equals(messages[0].folderId, folder.id, "Incorrect folderId.");
+    });
+}
+
+// change TEST_EMAIL_RECIPIENT_1 and TEST_EMAIL_RECIPIENT_2
+document.write('<script src="../webrunner/jquery-1.10.2.min.js"></script>');
+document.write('<script src="support/getJsonConf.js"></script>');
diff --git a/mobile/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_image.jpg b/mobile/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_image.jpg
new file mode 100755 (executable)
index 0000000..7a57964
Binary files /dev/null and b/mobile/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_image.jpg differ
diff --git a/mobile/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_noise.mp3 b/mobile/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_noise.mp3
new file mode 100755 (executable)
index 0000000..d4d1659
Binary files /dev/null and b/mobile/tct-deprecatedapi-tizen-tests/webapi-tizen-messaging-test_noise.mp3 differ