utc-Dali-OverlayEffect.cpp
utc-Dali-PageTurnEffect.cpp
utc-Dali-PageTurnView.cpp
+ utc-Dali-Script.cpp
utc-Dali-ScrollBar.cpp
utc-Dali-ScrollView.cpp
utc-Dali-ShadowView.cpp
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/scripting/script.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+void dali_script_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void dali_script_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliScriptExecuteFileN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliScriptExecuteFileN");
+
+ Script script = Script::New();
+
+ bool ok = script.ExecuteFile("non-existing file");
+
+ DALI_TEST_CHECK( !ok );
+
+ END_TEST;
+}
* Exec buffer contents as a script
* @param buffer script file contents
* @param filename a nominal name for the buffer contents.
- * (NB filename extension may be used to disambiguate script language)
+ * filename extension may be used to disambiguate script language
+ * @return true on success, false on failure
+ *
*/
- virtual void ExecuteBuffer(const std::string& buffer, const std::string& filename) = 0;
+ virtual bool ExecuteBuffer(const std::string& buffer, const std::string& filename) = 0;
/**
* Exec file as a script
* @param filename the filename to read and execute
+ * @return true on success, false on failure
*/
- virtual void ExecuteFile(const std::string& filename) = 0;
+ virtual bool ExecuteFile(const std::string& filename) = 0;
}; // class ScriptPlugin
{
}
-void Script::ExecuteFile( const std::string &filename )
+bool Script::ExecuteFile( const std::string &filename )
{
- GetImpl(*this).ExecuteFile( filename );
+ return GetImpl(*this).ExecuteFile( filename );
}
} // namespace Toolkit
* Executes the contents of filename in a scripted environment.
* @pre A Dali Application object exists
* @param filename A filename of a script file to execute
+ * @return true on success, false on failure
+ *
*/
- void ExecuteFile( const std::string& filename );
+ bool ExecuteFile( const std::string& filename );
private:
const char* PLUGIN_FILE = "libdali-script-plugin-v8.so";
}
-void Script::ExecuteFile( const std::string& filename )
-{
- if( mPlugin )
- {
- mPlugin->ExecuteFile(filename);
- }
-}
-
Script::Script(void) : mPlugin(NULL)
{
ScriptPluginProxy *plugin = new ScriptPluginProxy( PLUGIN_FILE );
}
+bool Script::ExecuteFile( const std::string& filename )
+{
+ if( mPlugin )
+ {
+ return mPlugin->ExecuteFile(filename);
+ }
+ return false;
+}
+
Script::~Script()
{
if( mPlugin )
/**
* @copydoc Toolkit::Script::ExecuteFile
*/
- void ExecuteFile( const std::string& filename );
+ bool ExecuteFile( const std::string& filename );
protected:
}
}
-void ScriptPluginProxy::ExecuteBuffer(const std::string &buffer, const std::string &filename)
+bool ScriptPluginProxy::ExecuteBuffer(const std::string &buffer, const std::string &filename)
{
if( mIsInitialized )
{
- mScriptingPlugin->ExecuteBuffer( buffer, filename );
+ return mScriptingPlugin->ExecuteBuffer( buffer, filename );
}
+ return false;
}
-void ScriptPluginProxy::ExecuteFile(const std::string &filename)
+bool ScriptPluginProxy::ExecuteFile(const std::string &filename)
{
if( mIsInitialized )
{
- mScriptingPlugin->ExecuteFile( filename );
+ return mScriptingPlugin->ExecuteFile( filename );
}
+ return false;
}
bool ScriptPluginProxy::IsInitialized() const
return mIsInitialized;
};
-
void ScriptPluginProxy::Initialize()
{
if( mIsInitialized )
virtual void SetFlags( const std::string& flags );
/**
- * @brief Exececute the buffer contents as a script
+ * @brief Exececute the buffer contents as a script
* @param [in] buffer script file contents
* @param [in] filename a nominal name for the buffer contents.
- * (NB filename extension may be used to disambiguate script language)
+ * @note filename extension may be used to disambiguate script language
+ * @return true on success, false on failure
+ *
*/
- virtual void ExecuteBuffer( const std::string& buffer, const std::string& filename );
+ virtual bool ExecuteBuffer( const std::string& buffer, const std::string& filename );
/**
* @brief execture the file as a script
* @param [in] filename the filename to read and execute
+ * @return true on success, false on failure
*/
- virtual void ExecuteFile( const std::string& fileName );
+ virtual bool ExecuteFile( const std::string& fileName );
/**
* @brief check if the plugin is initialized
DaliWrapper::Get().SetFlagsFromString(s);
}
-void DaliScriptV8::ExecuteBuffer(const std::string& buffer, const std::string& filename)
+bool DaliScriptV8::ExecuteBuffer(const std::string& buffer, const std::string& filename)
{
- DaliWrapper::Get().ExecuteBuffer(buffer, filename);
+ return DaliWrapper::Get().ExecuteBuffer(buffer, filename);
}
-void DaliScriptV8::ExecuteFile(const std::string& filename)
+bool DaliScriptV8::ExecuteFile(const std::string& filename)
{
-
-
- DaliWrapper::Get().ExecuteFile( filename );
+ return DaliWrapper::Get().ExecuteFile( filename );
}
} // namespace V8Plugin
/**
* @copydoc Dali::Toolkit::ScriptPlugin::ExecuteBuffer()
*/
- virtual void ExecuteBuffer(const std::string& buffer, const std::string& filename);
+ virtual bool ExecuteBuffer(const std::string& buffer, const std::string& filename);
/**
* @copydoc Dali::Toolkit::ScriptPlugin::ExecuteFile()
*/
- virtual void ExecuteFile(const std::string& fileName);
+ virtual bool ExecuteFile(const std::string& fileName);
};
}
}
-void DaliWrapper::ExecuteBuffer(const std::string &sourceCode, const std::string &sourceFileName)
+bool DaliWrapper::ExecuteBuffer(const std::string &sourceCode, const std::string &sourceFileName)
{
- mModuleLoader.ExecuteScript( mIsolate, sourceCode, sourceFileName );
+ return mModuleLoader.ExecuteScript( mIsolate, sourceCode, sourceFileName );
}
-void DaliWrapper::ExecuteFile( const std::string& sourceFileName )
+bool DaliWrapper::ExecuteFile( const std::string& sourceFileName )
{
DALI_LOG_INFO( gLogExecuteFilter, Debug::Verbose, "Executing source file %s \n",sourceFileName.c_str() );
- mModuleLoader.ExecuteScriptFromFile( mIsolate, sourceFileName );
+ return mModuleLoader.ExecuteScriptFromFile( mIsolate, sourceFileName );
}
GarbageCollectorInterface& DaliWrapper::GetDaliGarbageCollector()
*
* @param[in] sourceCode The buffer containing javascript to execute
* @param[in] sourceFileName Filename associated with the buffer (for error tracing)
+ * @return true on success, false on failure
*/
- void ExecuteBuffer(const std::string &sourceCode, const std::string &sourceFileName);
+ bool ExecuteBuffer(const std::string &sourceCode, const std::string &sourceFileName);
/**
* Excute the buffer in the v8 context
*
* @param[in] sourceFileName Filename associated with the buffer (for error tracing)
+ * @return true on success, false on failure
*/
- void ExecuteFile( const std::string& sourceFileName);
+ bool ExecuteFile( const std::string& sourceFileName);
/**
V8Utils::GetFileContents( fileName, contents );
+ if( contents.empty() )
+ {
+ return false;
+ }
+
return ExecuteScript( isolate, contents, fileName );
}
/**
* Execute a script from a file
* @param[in] fileName file name
+ * @return true on success, false on failure
+ *
*/
bool ExecuteScriptFromFile( v8::Isolate* isolate, const std::string& fileName );
* Execute a script
* @param[in] sourceCode source code to run
* @param[in] sourceFileName source file name
+ * @return true on success, false on failure
*/
bool ExecuteScript( v8::Isolate* isolate,
const std::string& sourceCode,