--- /dev/null
+<!DOCTYPE html>
+<!--
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Tan, Shiyou <shiyoux.tan@intel.com>
+
+-->
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, width=device-width" />
+ <link rel="stylesheet" type="text/css" href="../../css/jquery.mobile.css" />
+ <link rel="stylesheet" type="text/css" href="../../css/main.css" />
+ <script src="../../js/thirdparty/jquery.js"></script>
+ <script src="../../js/thirdparty/jquery.mobile.js"></script>
+ <script src="../../js/tests.js"></script>
+ <script src="js/main.js"></script>
+ </head>
+ <body bgcolor="FFFFFF" >
+ <div data-role="page" id="main">
+ <div data-role="header" data-position="fixed" data-tap-toggle="false">
+ <h1 id="main_page_title"></h1>
+ </div>
+ <div id="content">
+ <ul data-role="listview">
+ <li data-role="list-divider">Package Install</li>
+ <li>
+ <div data-role="button" id="install" class="wgtButton">Install</div>
+ </li>
+ <li data-role="list-divider">Package Launch</li>
+ <li>
+ <div data-role="button" id="launch1" class="wgtButton">Launch</div>
+ </li>
+ <li data-role="list-divider">Package Uninstall</li>
+ <li>
+ <div data-role="button" id="uninstall" class="wgtButton">Uninstall</div>
+ </li>
+ </ul>
+ </div>
+ <div data-role="footer" data-position="fixed" data-tap-toggle="false">
+ </div>
+ <div data-role="popup" id="popup_info" data-theme="a">
+ <font class="fontSize">
+ <p>Test Purpose: </p>
+ <p>Verifies the device supports set preview data functions.</p>
+ <p>Pre-condition: </p>
+ <p>Ensure the PreviewWebAPITest widget is installed successfully.</p>
+ <p>Test Step: </p>
+ <ol>
+ <li>Click the "Install" button to install the widget.</li>
+ <li>Click the "Launch" button to launch the widget.</li>
+ <li>Click the "Uninstall" button to uninstall the widget.</li>
+ </ol>
+ <p>Expected Result: </p>
+ <p>Test passes if all the "SetPreviewData", "SetPreviewData(delete)", "GetVersion" can work normally.</p>
+ </font>
+ </div>
+ </div>
+ </body>
+</html>
--- /dev/null
+/*
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Tan, Shiyou <shiyoux.tan@intel.com>
+*/
+
+var RESOURCE_DIR;
+$.ajax({
+ url:"/opt/usr/home/owner/share/TCT_CONFIG",
+ data:{},
+ async:false,
+ success:function(data){
+ var regEx = /DEVICE_SUITE_TARGET_30=(.+)/i;
+ var path = regEx.exec(data);
+ RESOURCE_DIR = path[1];
+ }
+});
+var installUrl;
+$(document).delegate("#main", "pageinit", function() {
+ DisablePassButton();
+
+ $("#install").bind("vclick", function() {
+ install(installUrl, "install");
+ });
+ $("#launch1").bind("vclick", function() {
+ launch();
+ $("#uninstall").removeClass("ui-disabled");
+ });
+ $("#uninstall").bind("vclick", function() {
+ uninstall();
+ });
+ try {
+ tizen.package.setPackageInfoEventListener(packageEventCallback);
+ } catch (e) {
+ alert("Exception: " + e.message);
+ }
+
+ packagePre();
+ $("#launch1").addClass("ui-disabled");
+ $("#uninstall").addClass("ui-disabled");
+
+ if(checkInstalledPkg("g3rSasdgsA")) {
+ $("#install").addClass("ui-disabled");
+ $("#launch1").removeClass("ui-disabled");
+ }
+});
+
+var packageEventCallback = {
+ oninstalled: function(packageInfo) {
+ hideProcess();
+ alert("The application " + packageInfo.name + " is installed");
+ },
+ onuninstalled: function(packageId) {
+ hideProcess();
+ alert("The application PreviewWebAPITest is uninstalled");
+ }
+};
+
+function fileURI() {
+ var documentsDir;
+ function onsuccess(files) {
+ for (var i = 0; i < files.length; i++)
+ {
+ if(files[i].name == "PreviewWebAPITestSuite.wgt")
+ {
+ var Url1 = files[i].toURI();
+ installUrl = Url1.replace("file:///", "/");
+ }
+ }
+ }
+
+ function onerror(error) {
+ alert("The error " + error.message + " occurred when listing the files in the selected folder");
+ }
+
+ tizen.filesystem.resolve(
+ 'file://' + RESOURCE_DIR + '/Documents',
+ function(dir){
+ documentsDir = dir;
+ dir.listFiles(onsuccess, onerror);
+ }, function(e) {
+ alert("Error" + e.message);
+ }, "r"
+ );
+}
+
+function install(url, type) {
+ var onInstallationSuccess = {
+ onprogress: function(packageId, percentage)
+ {
+ console.log("On installation(" + packageId + "): progress(" + percentage + ")");
+ showProcess();
+ },
+ oncomplete: function(packageId)
+ {
+ console.log("Installation(" + packageId + ") Complete");
+ if(checkInstalledPkg("g3rSasdgsA")) {
+ $("#install").addClass("ui-disabled");
+ $("#launch1").removeClass("ui-disabled");
+ }
+ }
+ }
+
+ var onError = function (err) {
+ alert("Error occured on installation : " + err.message);
+ $.mobile.hidePageLoadingMsg();
+ }
+
+ try {
+ tizen.package.install(url, onInstallationSuccess, onError);
+ } catch(e) {
+ alert("Exception: " + e.name);
+ }
+}
+
+function uninstall() {
+
+ var onUninstallationSuccess = {
+
+ onprogress: function(packageId, percentage)
+ {
+ showProcess();
+ console.log("On uninstallation(" + packageId + "): progress(" + percentage + ")");
+ },
+ oncomplete: function(packageId)
+ {
+ console.log("Uninstallation(" + packageId + ") Complete");
+ $("#launch1").addClass("ui-disabled");
+ $("#uninstall").addClass("ui-disabled");
+ EnablePassButton();
+ }
+ }
+
+ var onError = function (err) {
+ alert("Error occured on uninstallation : " + err.name);
+ $.mobile.hidePageLoadingMsg();
+ }
+
+ try {
+ tizen.package.uninstall("g3rSasdgsA", onUninstallationSuccess, onError);
+ } catch (e) {
+ alert("Exception: " + e.name);
+ }
+}
+
+function launch() {
+ function onSuccess() {
+ console.log(id + " launched successfully!");
+ }
+
+ function onError(err) {
+ alert("launch failed : PreviewWebAPITest application is already uninstalled or not installed");
+ }
+ try {
+ tizen.application.launch("g3rSasdgsA.PreviewWebAPITestSuite", onSuccess, onError);
+ } catch (exc) {
+ alert("launch exc:" + exc.message);
+ }
+}
+
+function packagePre() {
+ var documentsDir;
+ function onsuccess(files) {
+ for (var i = 0; i < files.length; i++)
+ {
+ if(files[i].name == "PreviewWebAPITestSuite")
+ {
+ documentsDir.copyTo(
+ files[i].fullPath,
+ "file://" + RESOURCE_DIR + "/Documents/PreviewWebAPITestSuite.wgt",
+ true,
+ function() {
+ console.log("PreviewWebAPITestSuite Precondition Success(2)!");
+ });
+ }
+ }
+ fileURI();
+ }
+
+ function onerror(error) {
+ alert("The error " + error.message + " occurred when listing the files in the selected folder");
+ }
+
+ tizen.filesystem.resolve(
+ 'wgt-package/tests/PreviewWebAPITestSuite/res/',
+ function(dir){
+ documentsDir = dir;
+ dir.listFiles(onsuccess, onerror);
+ }, function(e) {
+ alert("Error" + e.message);
+ }, "r"
+ );
+}
+
+function hideProcess() {
+ $.mobile.hidePageLoadingMsg();
+ $("#popup_info-screen").addClass("ui-screen-hidden");
+ $("#popup_info-screen").removeClass("in");
+}
+
+function showProcess() {
+ $.mobile.showPageLoadingMsg();
+ $("#popup_info-screen").removeClass("ui-screen-hidden");
+ $("#popup_info-screen").addClass("in");
+}