Changed signal order for StyleManager 86/66186/8
authorDavid Steele <david.steele@samsung.com>
Fri, 15 Apr 2016 16:32:04 +0000 (17:32 +0100)
committerDavid Steele <david.steele@samsung.com>
Tue, 26 Apr 2016 14:36:43 +0000 (15:36 +0100)
With this change, StyleManager will first trigger an internal signal
that is picked up by all Controls, then will emit StyleChanged to
signal to the application that the theme or system fonts have changed
and that the styling has completed.

Change-Id: I54ced7ad5ffc08bf5e55c9895be03848bea6b7a6
Signed-off-by: David Steele <david.steele@samsung.com>
34 files changed:
automated-tests/src/dali-toolkit-styling/CMakeLists.txt [new file with mode: 0644]
automated-tests/src/dali-toolkit-styling/tct-dali-toolkit-styling-core.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/CMakeLists.txt
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-button.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-button.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-bitmap-loader.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-color-controller.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-feedback-player.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-file-loader.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.h [deleted file]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.h [deleted file]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-sound-player.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-abstraction.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-virtual-keyboard.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/utc-Dali-ControlRenderer.cpp
automated-tests/src/dali-toolkit/utc-Dali-StyleManager.cpp [deleted file]
dali-toolkit/devel-api/styling/style-manager.cpp
dali-toolkit/devel-api/styling/style-manager.h
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/styling/style-manager-impl.cpp
dali-toolkit/internal/styling/style-manager-impl.h
dali-toolkit/public-api/controls/control-impl.cpp

diff --git a/automated-tests/src/dali-toolkit-styling/CMakeLists.txt b/automated-tests/src/dali-toolkit-styling/CMakeLists.txt
new file mode 100644 (file)
index 0000000..92653f1
--- /dev/null
@@ -0,0 +1,83 @@
+SET(PKG_NAME "dali-toolkit-styling")
+
+SET(EXEC_NAME "tct-${PKG_NAME}-core")
+SET(RPM_NAME "core-${PKG_NAME}-tests")
+
+SET(CAPI_LIB "dali-toolkit-styling")
+
+# List of test case sources (Only these get parsed for test cases)
+SET(TC_SOURCES
+   utc-Dali-StyleManager.cpp
+)
+
+# Append list of test harness files (Won't get parsed for test cases)
+LIST(APPEND TC_SOURCES
+   ../dali-toolkit/dali-toolkit-test-utils/test-harness.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-bitmap-loader.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-color-controller.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-environment-variable.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-feedback-player.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-file-loader.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-physical-keyboard.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-sound-player.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-text-abstraction.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-tts-player.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-virtual-keyboard.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-animation-data.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-button.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-application.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-gesture-manager.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-render-controller.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-native-image.cpp
+)
+
+
+PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
+  dali-core
+  dali-toolkit
+)
+
+PKG_CHECK_MODULES(DALI_ADAPTOR REQUIRED
+  dali-adaptor
+)
+
+SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -O0 -ggdb --coverage -Wall -Werror")
+
+ADD_DEFINITIONS(-DTEST_RESOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/../../resources\" )
+
+FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
+    SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
+ENDFOREACH(directory ${CAPI_LIB_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(
+    ../../../
+    ${${CAPI_LIB}_INCLUDE_DIRS}
+    ${DALI_ADAPTOR_INCLUDE_DIRS}
+    ../dali-toolkit/dali-toolkit-test-utils
+)
+
+ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
+TARGET_LINK_LIBRARIES(${EXEC_NAME}
+  ${${CAPI_LIB}_LIBRARIES}
+  -lpthread -ldl
+)
+
+INSTALL(PROGRAMS ${EXEC_NAME}
+    DESTINATION ${BIN_DIR}/${EXEC_NAME}
+)
diff --git a/automated-tests/src/dali-toolkit-styling/tct-dali-toolkit-styling-core.cpp b/automated-tests/src/dali-toolkit-styling/tct-dali-toolkit-styling-core.cpp
new file mode 100644 (file)
index 0000000..6e99684
--- /dev/null
@@ -0,0 +1,51 @@
+#include <string.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <test-harness.h>
+#include "tct-dali-toolkit-styling-core.h"
+
+int main(int argc, char * const argv[])
+{
+  int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
+
+  const char* optString = "rs";
+  bool optRerunFailed(true);
+  bool optRunSerially(false);
+
+  int nextOpt = 0;
+  do
+  {
+    nextOpt = getopt( argc, argv, optString );
+    switch(nextOpt)
+    {
+      case 'r':
+        optRerunFailed = true;
+        break;
+      case 's':
+        optRunSerially = true;
+        break;
+      case '?':
+        TestHarness::Usage(argv[0]);
+        exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
+        break;
+    }
+  } while( nextOpt != -1 );
+
+  if( optind == argc ) // no testcase name in argument list
+  {
+    if( optRunSerially )
+    {
+      result = TestHarness::RunAll( argv[0], tc_array );
+    }
+    else
+    {
+      result = TestHarness::RunAllInParallel( argv[0], tc_array, optRerunFailed );
+    }
+  }
+  else
+  {
+    // optind is index of next argument - interpret as testcase name
+    result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
+  }
+  return result;
+}
diff --git a/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp b/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp
new file mode 100644 (file)
index 0000000..e463e2f
--- /dev/null
@@ -0,0 +1,420 @@
+/*
+ * 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/integration-api/events/touch-event-integ.h>
+#include <dali-toolkit/devel-api/styling/style-manager.h>
+#include <dali-toolkit/devel-api/builder/builder.h>
+#include <test-button.h>
+#include <test-animation-data.h>
+#include <toolkit-style-monitor.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+namespace
+{
+const char* defaultTheme =
+"{\n"
+"  \"styles\":\n"
+"  {\n"
+"    \"textlabel\":\n"
+"    {\n"
+"      \"pointSize\":18\n"
+"    },\n"
+"\n"
+"    \"textlabelFontSize0\":\n"
+"    {\n"
+"      \"pointSize\":8\n"
+"    },\n"
+"    \"textlabelFontSize1\":\n"
+"    {\n"
+"      \"pointSize\":10\n"
+"    },\n"
+"    \"textlabelFontSize2\":\n"
+"    {\n"
+"      \"pointSize\":15\n"
+"    },\n"
+"    \"textlabelFontSize3\":\n"
+"    {\n"
+"      \"pointSize\":19\n"
+"    },\n"
+"    \"textlabelFontSize4\":\n"
+"    {\n"
+"      \"pointSize\":25\n"
+"    },\n"
+"\n"
+"    \"textfield\":\n"
+"    {\n"
+"      \"pointSize\":18,\n"
+"      \"primaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
+"      \"secondaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
+"      \"cursorWidth\":3,\n"
+"      \"selectionHighlightColor\":[0.75,0.96,1.0,1.0],\n"
+"      \"grabHandleImage\" : \"{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png\",\n"
+"      \"selectionHandleImageLeft\" : {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png\" },\n"
+"      \"selectionHandleImageRight\": {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png\" }\n"
+"    },\n"
+"\n"
+"    \"textfieldFontSize0\":\n"
+"    {\n"
+"      \"pointSize\":10\n"
+"    },\n"
+"    \"textfieldFontSize1\":\n"
+"    {\n"
+"      \"pointSize\":10\n"
+"    },\n"
+"    \"textfieldFontSize2\":\n"
+"    {\n"
+"      \"pointSize\":10\n"
+"    },\n"
+"    \"textfieldFontSize3\":\n"
+"    {\n"
+"      \"pointSize\":10\n"
+"    },\n"
+"    \"textfieldFontSize4\":\n"
+"    {\n"
+"      \"pointSize\":10\n"
+"    },\n"
+"    \"textselectionpopup\":\n"
+"    {\n"
+"      \"popupMaxSize\":[656,72],\n"
+"      \"optionDividerSize\":[2,0],\n"
+"      \"popupDividerColor\":[0.23,0.72,0.8,0.11],\n"
+"      \"popupIconColor\":[1.0,1.0,1.0,1.0],\n"
+"      \"popupPressedColor\":[0.24,0.72,0.8,0.11],\n"
+"      \"background\": {\n"
+"        \"rendererType\": \"nPatch\",\n"
+"        \"imageUrl\": \"{DALI_IMAGE_DIR}selection-popup-bg.9.png\"\n"
+"        },\n"
+"      \"popupFadeInDuration\":0.25,\n"
+"      \"popupFadeOutDuration\":0.25\n"
+"    },\n"
+"    \"textselectionpopupbutton\":\n"
+"    {\n"
+"      \"label\":\n"
+"      {\n"
+"        \"pointSize\":8,\n"
+"        \"fontStyle\":\"{\\\\""weight\\\\"":\\\\""light\\\\""}\"\n"
+"      }\n"
+"    },\n"
+"    \"textselectiontoolbar\":\n"
+"    {\n"
+"      \"enableOvershoot\":true,\n"
+"      \"scrollView\":\n"
+"      {\n"
+"        \"overshootAnimationSpeed\":360.0,\n"
+"        \"overshootSize\":[720.0,130.0]\n"
+"      }\n"
+"    },\n"
+"    \"scrollview\":\n"
+"    {\n"
+"      \"overshootEffectColor\":\"B018\",\n"
+"      \"overshootAnimationSpeed\":360.0,\n"
+"      \"overshootSize\":[720.0,130.0]\n"
+"    },\n"
+"    \"itemview\":\n"
+"    {\n"
+"      \"overshootEffectColor\":\"B018\",\n"
+"      \"overshootAnimationSpeed\":360.0,\n"
+"      \"overshootSize\":[720.0,130.0]\n"
+"    },\n"
+"    \"texteditor\":\n"
+"    {\n"
+"      \"pointSize\":18,\n"
+"      \"primaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
+"      \"secondaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
+"      \"cursorWidth\":3,\n"
+"      \"selectionHighlightColor\":[0.75,0.96,1.0,1.0],\n"
+"      \"grabHandleImage\" : \"{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png\",\n"
+"      \"selectionHandleImageLeft\" : {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png\" },\n"
+"      \"selectionHandleImageRight\": {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png\" }\n"
+"    }\n"
+"  }\n"
+"}\n";
+
+} // anonymous namespace
+
+
+
+void dali_style_manager_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void dali_style_manager_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+int UtcDaliStyleManagerGet(void)
+{
+  ToolkitTestApplication application;
+
+  tet_infoline(" UtcDaliStyleManagerGet");
+
+  // Register Type
+  TypeInfo type;
+  type = TypeRegistry::Get().GetTypeInfo( "StyleManager" );
+  DALI_TEST_CHECK( type );
+  BaseHandle handle = type.CreateInstance();
+  DALI_TEST_CHECK( handle );
+
+  StyleManager manager;
+
+  manager = StyleManager::Get();
+  DALI_TEST_CHECK(manager);
+
+  StyleManager newManager = StyleManager::Get();
+  DALI_TEST_CHECK(newManager);
+
+  // Check that focus manager is a singleton
+  DALI_TEST_CHECK(manager == newManager);
+  END_TEST;
+}
+
+int UtcDaliStyleManagerSetOrientationValue(void)
+{
+  ToolkitTestApplication application;
+
+  tet_infoline( " UtcDaliStyleManagerSetOrientationValue" );
+
+  StyleManager manager = StyleManager::Get();
+
+  int orientation1 = 0;
+  manager.SetOrientationValue( orientation1 );
+  DALI_TEST_CHECK( manager.GetOrientationValue() == orientation1 );
+
+  int orientation2 = 180;
+  manager.SetOrientationValue( orientation2 );
+  DALI_TEST_CHECK( manager.GetOrientationValue() == orientation2 );
+
+  END_TEST;
+}
+
+int UtcDaliStyleManagerSetOrientation(void)
+{
+  ToolkitTestApplication application;
+
+  tet_infoline( " UtcDaliStyleManagerSetOrientation" );
+
+  StyleManager manager = StyleManager::Get();
+
+  Orientation orientation;
+
+  manager.SetOrientation( orientation );
+
+  DALI_TEST_CHECK( manager.GetOrientation() == orientation );
+
+  END_TEST;
+}
+
+int UtcDaliStyleManagerSetStyleConstant(void)
+{
+  ToolkitTestApplication application;
+
+  tet_infoline( " UtcDaliStyleManagerSetStyleConstant" );
+
+  StyleManager manager = StyleManager::Get();
+
+  std::string key( "key" );
+  Property::Value value( 100 );
+
+  manager.SetStyleConstant( key, value );
+
+  Property::Value returnedValue;
+  manager.GetStyleConstant( key, returnedValue );
+
+  DALI_TEST_CHECK( value.Get<int>() == returnedValue.Get<int>() );
+
+  std::string key2( "key2" );
+  Property::Value returnedValue2;
+  DALI_TEST_CHECK( !manager.GetStyleConstant( key2, returnedValue2 ) );
+
+  END_TEST;
+}
+
+namespace
+{
+class StyleChangedSignalChecker : public ConnectionTracker
+{
+public:
+  StyleChangedSignalChecker()
+  : signalCount(0)
+  {
+  }
+
+  void OnStyleChanged(StyleManager styleManager, StyleChange::Type type)
+  {
+    signalCount++;
+  }
+
+  void Reset()
+  {
+    signalCount =0;
+  }
+
+public:
+  int signalCount;
+};
+
+} // anonymous namespace
+
+int UtcDaliStyleManagerPropertyOverride(void)
+{
+  ToolkitTestApplication application;
+
+  tet_infoline( "Testing StyleManager property overrides" );
+
+  const char* json1 =
+    "{\n"
+    "  \"styles\":\n"
+    "  {\n"
+    "    \"testbutton\":\n"
+    "    {\n"
+    "      \"backgroundColor\":[1.0,1.0,0.0,1.0],\n"
+    "      \"foregroundColor\":[0.0,0.0,1.0,1.0]\n"
+    "    }\n"
+    "  }\n"
+    "}\n";
+
+  const char* json2 =
+    "{\n"
+    "  \"styles\":\n"
+    "  {\n"
+    "    \"testbutton\":\n"
+    "    {\n"
+    "      \"backgroundColor\":[1.0,0.0,0.0,1.0],\n"
+    "      \"foregroundColor\":[0.0,1.0,1.0,1.0]\n"
+    "    }\n"
+    "  }\n"
+    "}\n";
+
+  // Add 2 buttons to test how many times the signal is sent
+  Test::TestButton testButton = Test::TestButton::New();
+  Test::TestButton testButton2 = Test::TestButton::New();
+  Stage::GetCurrent().Add( testButton );
+  Stage::GetCurrent().Add( testButton2 );
+  StyleChangedSignalChecker styleChangedSignalHandler;
+  StyleChangedSignalChecker styleChangedSignalHandler2;
+  StyleManager styleManager = StyleManager::Get();
+
+  styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  tet_infoline("Apply the style");
+
+  Test::StyleMonitor::SetThemeFileOutput(json1);
+  std::string themeFile("ThemeOne");
+  StyleManager::Get().RequestThemeChange(themeFile);
+
+  Property::Value bgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
+  Property::Value fgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
+
+  DALI_TEST_EQUALS( bgColor, Property::Value(Color::YELLOW), 0.001, TEST_LOCATION );
+  DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
+
+  tet_infoline("Testing that the signal handler is called only once");
+  DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
+
+  tet_infoline("Override the background property");
+  testButton.SetProperty( Test::TestButton::Property::BACKGROUND_COLOR, Color::GREEN );
+  bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
+  fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
+  DALI_TEST_EQUALS( bgColor, Property::Value(Color::GREEN), 0.001, TEST_LOCATION );
+  DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  tet_infoline("Apply the style again");
+
+  styleChangedSignalHandler.signalCount = 0;
+  StyleManager::Get().RequestThemeChange(themeFile);
+
+  bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
+  fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
+
+  tet_infoline("Check that the property is changed");
+  DALI_TEST_EQUALS( bgColor, Property::Value(Color::YELLOW), 0.001, TEST_LOCATION );
+  DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
+  tet_infoline("Testing that the signal handler is called only once");
+  DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
+
+  tet_infoline( "Load a different stylesheet");
+
+  tet_infoline("Apply the new style");
+  Test::StyleMonitor::SetThemeFileOutput(json2);
+
+  styleChangedSignalHandler.signalCount = 0;
+  std::string themeFile2("ThemeTwo");
+  StyleManager::Get().RequestThemeChange(themeFile2);
+
+  bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
+  fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
+
+  tet_infoline("Check that the properties change, but the signal gets sent only once");
+  DALI_TEST_EQUALS( bgColor, Property::Value(Color::RED), 0.001, TEST_LOCATION );
+  DALI_TEST_EQUALS( fgColor, Property::Value(Color::CYAN), 0.001, TEST_LOCATION );
+  DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliStyleManagerFontSizeChange(void)
+{
+  tet_infoline("Test that the StyleChange signal is fired when the font size is altered" );
+  Test::StyleMonitor::SetThemeFileOutput(defaultTheme);
+
+  ToolkitTestApplication application;
+
+  std::string labelStr("Label");
+  Toolkit::TextLabel label = Toolkit::TextLabel::New(labelStr);
+  Stage::GetCurrent().Add( label );
+
+  Toolkit::TextLabel label2 = Toolkit::TextLabel::New(labelStr);
+  Stage::GetCurrent().Add( label2 );
+
+  StyleChangedSignalChecker styleChangedSignalHandler;
+  StyleMonitor styleMonitor = StyleMonitor::Get();
+  StyleManager styleManager = StyleManager::Get();
+
+  styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
+
+  Test::StyleMonitor::SetDefaultFontFamily("Times New Roman");
+
+  styleMonitor.StyleChangeSignal().Emit( styleMonitor,  StyleChange::DEFAULT_FONT_CHANGE);
+
+  tet_infoline("Test that the StyleChanged signal is received only once");
+
+  DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
+
+  // Check that the label's font style has been altered
+  Property::Value family = label.GetProperty(TextLabel::Property::FONT_FAMILY);
+  std::string familyStr;
+  family.Get( familyStr );
+
+  DALI_TEST_EQUALS( familyStr, "Times New Roman", TEST_LOCATION);
+
+  END_TEST;
+}
index 15ffd4c..4d63fee 100644 (file)
@@ -45,7 +45,6 @@ SET(TC_SOURCES
    utc-Dali-PushButton.cpp
    utc-Dali-RadioButton.cpp
    utc-Dali-ScrollViewEffect.cpp
-   utc-Dali-StyleManager.cpp
    utc-Dali-SuperBlurView.cpp
    utc-Dali-Toolkit.cpp
    utc-Dali-Model3dView.cpp
index 0a90c8e..467bb52 100644 (file)
@@ -233,12 +233,27 @@ void DALI_TEST_EQUALS( const std::string &str1, const char* str2, const char* lo
   DALI_TEST_EQUALS(str1.c_str(), str2, location);
 }
 
-/**
- * Test whether two strings are equal.
- * @param[in] str1 The first string
- * @param[in] str2 The second string
- * @param[in] location The TEST_LOCATION macro should be used here
- */
+void DALI_TEST_EQUALS( Property::Value& str1, const char* str2, const char* location)
+{
+  bool result = false;
+
+  if( str1.GetType() == Property::STRING )
+  {
+    std::string string;
+    str1.Get(string);
+    result = !string.compare(str2);
+  }
+
+  if( result )
+  {
+    tet_result(TET_PASS);
+  }
+  else
+  {
+    tet_result(TET_FAIL);
+  }
+}
+
 void DALI_TEST_EQUALS( const char* str1, const std::string &str2, const char* location)
 {
   DALI_TEST_EQUALS(str1, str2.c_str(), location);
index baeaa6a..5e10efe 100644 (file)
@@ -153,6 +153,82 @@ inline bool CompareType<Degree>(Degree q1, Degree q2, float epsilon)
   return CompareType<float>(q1.degree, q2.degree, epsilon);
 }
 
+template <>
+inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2, float epsilon)
+{
+  Property::Type type = q1.GetType();
+  if( type != q2.GetType() )
+  {
+    return false;
+  }
+
+  switch(type)
+  {
+    case Property::BOOLEAN:
+    {
+      bool a, b;
+      q1.Get(a);
+      q2.Get(b);
+      return a == b;
+      break;
+    }
+    case Property::INTEGER:
+    {
+      int a, b;
+      q1.Get(a);
+      q2.Get(b);
+      return a == b;
+      break;
+    }
+    case Property::FLOAT:
+    {
+      float a, b;
+      q1.Get(a);
+      q2.Get(b);
+      return CompareType<float>(a, b, epsilon);
+      break;
+    }
+    case Property::VECTOR2:
+    {
+      Vector2 a, b;
+      q1.Get(a);
+      q2.Get(b);
+      return CompareType<Vector2>(a, b, epsilon);
+      break;
+    }
+    case Property::VECTOR3:
+    {
+      Vector3 a, b;
+      q1.Get(a);
+      q2.Get(b);
+      return CompareType<Vector3>(a, b, epsilon);
+      break;
+    }
+    case Property::RECTANGLE:
+    case Property::VECTOR4:
+    {
+      Vector4 a, b;
+      q1.Get(a);
+      q2.Get(b);
+      return CompareType<Vector4>(a, b, epsilon);
+      break;
+    }
+    case Property::ROTATION:
+    {
+      Quaternion a, b;
+      q1.Get(a);
+      q2.Get(b);
+      return CompareType<Quaternion>(a, b, epsilon);
+      break;
+    }
+    default:
+      return false;
+  }
+
+  return false;
+}
+
+
 bool operator==(TimePeriod a, TimePeriod b);
 std::ostream& operator<<( std::ostream& ostream, TimePeriod value );
 std::ostream& operator<<( std::ostream& ostream, Radian angle );
@@ -316,6 +392,14 @@ inline void DALI_TEST_EQUALS<const std::string&>( const std::string &str1, const
  * @param[in] str2 The second string
  * @param[in] location The TEST_LOCATION macro should be used here
  */
+void DALI_TEST_EQUALS( Property::Value& str1, const char* str2, const char* location);
+
+/**
+ * Test whether two strings are equal.
+ * @param[in] str1 The first string
+ * @param[in] str2 The second string
+ * @param[in] location The TEST_LOCATION macro should be used here
+ */
 void DALI_TEST_EQUALS( const std::string &str1, const char* str2, const char* location);
 
 /**
index cbecb9b..a83f3e3 100644 (file)
@@ -72,6 +72,7 @@ void TestButton::SetProperty( BaseObject* object, Property::Index index, const P
 
   if ( button )
   {
+    TestButton& buttonImpl = GetImpl(button);
     switch ( index )
     {
       case Test::TestButton::Property::PRESS_TRANSITION:
@@ -79,19 +80,28 @@ void TestButton::SetProperty( BaseObject* object, Property::Index index, const P
         if( value.GetType() == Property::MAP )
         {
           Property::Map* valueMap = value.GetMap();
-          TestButton& buttonImpl = GetImpl(button);
           buttonImpl.mPressTransitionData.Clear();
           NewAnimation( *valueMap, buttonImpl.mPressTransitionData );
         }
         else if( value.GetType() == Property::ARRAY )
         {
           Property::Array* valueArray = value.GetArray();
-          TestButton& buttonImpl = GetImpl(button);
           buttonImpl.mPressTransitionData.Clear();
           NewAnimation( *valueArray, buttonImpl.mPressTransitionData );
         }
         break;
       }
+      case Test::TestButton::Property::BACKGROUND_COLOR:
+      {
+        buttonImpl.mBackgroundColor = value.Get<Vector4>();
+        break;
+      }
+
+      case Test::TestButton::Property::FOREGROUND_COLOR:
+      {
+        buttonImpl.mForegroundColor = value.Get<Vector4>();
+        break;
+      }
     }
   }
 }
@@ -100,6 +110,8 @@ Property::Value TestButton::GetProperty( BaseObject* object, Property::Index pro
 {
   Test::TestButton button = Test::TestButton::DownCast( Dali::BaseHandle( object ) );
 
+  Property::Value value;
+
   if ( button )
   {
     TestButton& buttonImpl = GetImpl(button);
@@ -108,22 +120,26 @@ Property::Value TestButton::GetProperty( BaseObject* object, Property::Index pro
       case Test::TestButton::Property::PRESS_TRANSITION:
       {
         return ConvertAnimationMap(buttonImpl.mPressTransitionData);
-        break;
       }
       case Test::TestButton::Property::RELEASE_TRANSITION:
       {
         return ConvertAnimationMap(buttonImpl.mReleaseTransitionData);
-        break;
       }
       case Test::TestButton::Property::DISABLED_TRANSITION:
       {
         return ConvertAnimationMap(buttonImpl.mDisabledTransitionData);
-        break;
       }
       case Test::TestButton::Property::ENABLED_TRANSITION:
       {
         return ConvertAnimationMap(buttonImpl.mEnabledTransitionData);
-        break;
+      }
+      case Test::TestButton::Property::BACKGROUND_COLOR:
+      {
+        return Property::Value(buttonImpl.mBackgroundColor);
+      }
+      case Test::TestButton::Property::FOREGROUND_COLOR:
+      {
+        return Property::Value(buttonImpl.mForegroundColor);
       }
     }
   }
@@ -142,6 +158,8 @@ DALI_PROPERTY_REGISTRATION( Test, TestButton, "pressTransition", ARRAY, PRESS_TR
 DALI_PROPERTY_REGISTRATION( Test, TestButton, "releaseTransition", ARRAY, RELEASE_TRANSITION)
 DALI_PROPERTY_REGISTRATION( Test, TestButton, "disabledTransition", ARRAY, DISABLED_TRANSITION )
 DALI_PROPERTY_REGISTRATION( Test, TestButton, "enabledTransition", ARRAY, ENABLED_TRANSITION )
+DALI_PROPERTY_REGISTRATION( Test, TestButton, "backgroundColor", VECTOR4, BACKGROUND_COLOR )
+DALI_PROPERTY_REGISTRATION( Test, TestButton, "foregroundColor", VECTOR4, FOREGROUND_COLOR )
 
 DALI_TYPE_REGISTRATION_END()
 
index 5dd5ac3..c9a29e4 100644 (file)
@@ -42,7 +42,9 @@ public:
       PRESS_TRANSITION = PROPERTY_START_INDEX,
       RELEASE_TRANSITION,
       DISABLED_TRANSITION,
-      ENABLED_TRANSITION
+      ENABLED_TRANSITION,
+      BACKGROUND_COLOR,
+      FOREGROUND_COLOR
     };
   };
   TestButton();
@@ -79,6 +81,8 @@ public:
   Test::TestAnimationData mReleaseTransitionData;
   Test::TestAnimationData mDisabledTransitionData;
   Test::TestAnimationData mEnabledTransitionData;
+  Dali::Vector4 mBackgroundColor;
+  Dali::Vector4 mForegroundColor;
 };
 
 inline TestButton& GetImpl( Test::TestButton& handle )
index a69b323..5820806 100644 (file)
@@ -394,6 +394,12 @@ static Internal::Adaptor::AccessibilityAdaptor& GetImplementation(Dali::Accessib
   return static_cast<Internal::Adaptor::AccessibilityAdaptor&>(handle);
 }
 
+static const Internal::Adaptor::AccessibilityAdaptor& GetImplementation(const Dali::AccessibilityAdaptor& adaptor)
+{
+  const BaseObject& handle = adaptor.GetBaseObject();
+  return static_cast<const Internal::Adaptor::AccessibilityAdaptor&>(handle);
+}
+
 
 } // namespace Adaptor
 } // namespace Internal
@@ -422,7 +428,7 @@ void AccessibilityAdaptor::MockSetReadPosition( Vector2& position )
 
 // Methods:
 
-Vector2 AccessibilityAdaptor::GetReadPosition()
+Vector2 AccessibilityAdaptor::GetReadPosition() const
 {
   return Internal::Adaptor::GetImplementation(*this).GetReadPosition();
 }
index 900f374..2975c33 100644 (file)
@@ -56,7 +56,7 @@ public: // Getters
 
   static AccessibilityAdaptor Get();
 
-  Vector2 GetReadPosition();
+  Vector2 GetReadPosition() const;
   bool IsEnabled() const;
   void SetActionHandler(AccessibilityActionHandler& handler);
   void SetGestureHandler(AccessibilityGestureHandler& handler);
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-bitmap-loader.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-bitmap-loader.cpp
new file mode 100644 (file)
index 0000000..00c1204
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2016 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 <dali/public-api/object/base-object.h>
+#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
+#include <cstring>
+
+using namespace Dali;
+
+namespace Dali
+{
+class Adaptor;
+
+namespace Internal
+{
+
+class BitmapLoader : public BaseObject
+{
+public:
+  static IntrusivePtr<BitmapLoader> New( const std::string& url,
+                                         ImageDimensions size,
+                                         FittingMode::Type fittingMode,
+                                         SamplingMode::Type samplingMode,
+                                         bool orientationCorrection)
+  {
+    IntrusivePtr<BitmapLoader> internal = new BitmapLoader( url, size, fittingMode, samplingMode, orientationCorrection );
+    return internal;
+  }
+
+  BitmapLoader(const std::string& url,
+               ImageDimensions size,
+               FittingMode::Type fittingMode,
+               SamplingMode::Type samplingMode,
+               bool orientationCorrection)
+  : mSize(size),
+    mPixelData(),
+    mUrl(url)
+  {
+  }
+
+  ~BitmapLoader(){}
+
+  void Load()
+  {
+    size_t bufferSize  = mSize.GetWidth() * mSize.GetHeight() * 4;
+    unsigned char* buffer = static_cast<unsigned char*>(malloc(bufferSize));
+    memset(buffer, 0, bufferSize);
+
+    mPixelData = PixelData::New( buffer, mSize.GetWidth(), mSize.GetHeight(), Pixel::RGBA8888, PixelData::FREE);
+  }
+
+  PixelDataPtr GetPixelData() const
+  {
+    return mPixelData;
+  }
+
+  const std::string& GetUrl() const
+  {
+    return mUrl;
+  }
+
+  bool IsLoaded()
+  {
+    return mPixelData ? true : false;
+  }
+
+  ImageDimensions mSize;
+  PixelDataPtr mPixelData;
+  const std::string mUrl;
+};
+
+} // internal
+
+inline Internal::BitmapLoader& GetImplementation(Dali::BitmapLoader& handle)
+{
+  DALI_ASSERT_ALWAYS( handle && "handle is empty" );
+  BaseObject& object = handle.GetBaseObject();
+  return static_cast<Internal::BitmapLoader&>(object);
+}
+
+inline const Internal::BitmapLoader& GetImplementation(const Dali::BitmapLoader& handle)
+{
+  DALI_ASSERT_ALWAYS( handle && "handle is empty" );
+  const BaseObject& object = handle.GetBaseObject();
+  return static_cast<const Internal::BitmapLoader&>(object);
+}
+
+Dali::BitmapLoader Dali::BitmapLoader::New(std::string const&url, Dali::Uint16Pair size, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode, bool orientationCorrection)
+{
+  IntrusivePtr<Internal::BitmapLoader> internal = Internal::BitmapLoader::New(url, size, fittingMode, samplingMode, orientationCorrection);
+  return BitmapLoader( internal.Get() );
+}
+
+Dali::BitmapLoader::BitmapLoader(Dali::BitmapLoader const& handle)
+:BaseHandle(handle)
+{
+}
+Dali::BitmapLoader::BitmapLoader(Internal::BitmapLoader* internal)
+:BaseHandle(internal)
+{
+}
+Dali::BitmapLoader::~BitmapLoader()
+{
+}
+void Dali::BitmapLoader::Load()
+{
+  GetImplementation(*this).Load();
+}
+PixelDataPtr Dali::BitmapLoader::GetPixelData() const
+{
+  return GetImplementation(*this).GetPixelData();
+}
+std::string Dali::BitmapLoader::GetUrl() const
+{
+  return GetImplementation(*this).GetUrl();
+}
+bool Dali::BitmapLoader::IsLoaded()
+{
+  return GetImplementation(*this).IsLoaded();
+}
+
+} // Dali
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-color-controller.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-color-controller.cpp
new file mode 100644 (file)
index 0000000..f24bc44
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2016 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 <dali/devel-api/adaptor-framework/color-controller.h>
+
+#include <dali/public-api/object/base-object.h>
+
+using namespace Dali;
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+class ColorController : public BaseObject
+{
+public:
+  ColorController(){}
+  static Dali::ColorController Get()
+  {
+    return Dali::ColorController( new ColorController() );
+  }
+
+  bool RetrieveColor( const std::string& colorCode, Vector4& colorValue )
+  {
+    return false;
+  }
+
+  bool RetrieveColor( const std::string& colorCode ,
+                      Vector4&           textColor,
+                      Vector4&           textOutlineColor,
+                      Vector4&           textShadowColor)
+  {
+    return false;
+  }
+protected:
+  virtual ~ColorController(){}
+};
+
+} // Adaptor
+} // Internal
+
+inline Internal::Adaptor::ColorController& GetImplementation(Dali::ColorController& controller)
+{
+  DALI_ASSERT_ALWAYS(controller && "ColorController handle is empty");
+  BaseObject& handle = controller.GetBaseObject();
+  return static_cast<Internal::Adaptor::ColorController&>(handle);
+}
+
+inline const Internal::Adaptor::ColorController& GetImplementation(const Dali::ColorController& controller)
+{
+  DALI_ASSERT_ALWAYS(controller && "ColorController handle is empty");
+  const BaseObject& handle = controller.GetBaseObject();
+  return static_cast<const Internal::Adaptor::ColorController&>(handle);
+}
+
+ColorController ColorController::Get()
+{
+  return Internal::Adaptor::ColorController::Get();
+}
+
+ColorController::ColorController(Internal::Adaptor::ColorController* internal)
+: BaseHandle(internal)
+{
+}
+
+ColorController::~ColorController()
+{
+}
+
+bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
+{
+  return GetImplementation(*this).RetrieveColor( colorCode, colorValue );
+}
+
+} // Dali
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-feedback-player.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-feedback-player.cpp
new file mode 100644 (file)
index 0000000..999249a
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2016 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 <dali/devel-api/adaptor-framework/feedback-player.h>
+#include <dali/devel-api/adaptor-framework/singleton-service.h>
+#include <dali/public-api/object/base-object.h>
+
+using namespace Dali;
+
+namespace Dali
+{
+class Adaptor;
+
+namespace Internal
+{
+namespace Adaptor
+{
+
+class FeedbackPlayer : public Dali::BaseObject
+{
+public:
+  static Dali::FeedbackPlayer New()
+  {
+    Dali::FeedbackPlayer player = Dali::FeedbackPlayer( new FeedbackPlayer() );
+    return player;
+  }
+
+  static Dali::FeedbackPlayer Get()
+  {
+    Dali::FeedbackPlayer player;
+    Dali::SingletonService service( Dali::SingletonService::Get() );
+    if( service )
+    {
+      // Check whether the singleton is already created
+      Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::FeedbackPlayer ) );
+      if( handle )
+      {
+        player = Dali::FeedbackPlayer( dynamic_cast< FeedbackPlayer* >( handle.GetObjectPtr() ) );
+      }
+      else
+      {
+        player = Dali::FeedbackPlayer( New() );
+        service.Register( typeid( player ), player );
+      }
+    }
+    return player;
+  }
+  void PlayMonotone(unsigned int duration)
+  {
+  }
+
+  void PlayFile( const std::string& filePath )
+  {
+  }
+
+  void Stop()
+  {
+  }
+
+  int PlaySound( const std::string& fileName )
+  {
+    return 0;
+  }
+
+  void StopSound( int handle )
+  {
+  }
+
+  void PlayFeedbackPattern( int type, int pattern )
+  {
+  }
+
+  bool LoadFile(const std::string& filename, std::string& data)
+  {
+    return true;
+  }
+
+private:
+  FeedbackPlayer()
+  {
+  }
+
+  virtual ~FeedbackPlayer()
+  {
+  }
+
+  FeedbackPlayer(const FeedbackPlayer&)
+  {
+  }
+
+  FeedbackPlayer& operator=(FeedbackPlayer&)
+  {
+    return *this;
+  }
+};
+
+} // Adaptor
+} // Internal
+
+inline Internal::Adaptor::FeedbackPlayer& GetImplementation(Dali::FeedbackPlayer& player)
+{
+  DALI_ASSERT_ALWAYS( player && "FeedbackPlayer handle is empty" );
+  BaseObject& handle = player.GetBaseObject();
+  return static_cast<Internal::Adaptor::FeedbackPlayer&>(handle);
+}
+
+inline const Internal::Adaptor::FeedbackPlayer& GetImplementation(const Dali::FeedbackPlayer& player)
+{
+  DALI_ASSERT_ALWAYS( player && "FeedbackPlayer handle is empty" );
+  const BaseObject& handle = player.GetBaseObject();
+  return static_cast<const Internal::Adaptor::FeedbackPlayer&>(handle);
+}
+
+FeedbackPlayer::FeedbackPlayer()
+{
+}
+
+FeedbackPlayer FeedbackPlayer::Get()
+{
+  return Internal::Adaptor::FeedbackPlayer::Get();
+}
+
+FeedbackPlayer::~FeedbackPlayer()
+{
+}
+
+void FeedbackPlayer::PlayMonotone(unsigned int duration)
+{
+  GetImplementation(*this).PlayMonotone(duration);
+}
+
+void FeedbackPlayer::PlayFile(const std::string filePath)
+{
+  GetImplementation(*this).PlayFile(filePath);
+}
+
+void FeedbackPlayer::Stop()
+{
+  GetImplementation(*this).Stop();
+}
+
+int FeedbackPlayer::PlaySound( const std::string& fileName )
+{
+  return GetImplementation(*this).PlaySound(fileName);
+}
+
+void FeedbackPlayer::StopSound( int handle )
+{
+  GetImplementation(*this).StopSound(handle);
+}
+
+void FeedbackPlayer::PlayFeedbackPattern( int type, int pattern )
+{
+  GetImplementation(*this).PlayFeedbackPattern(type, pattern);
+}
+
+bool FeedbackPlayer::LoadFile(const std::string& filename, std::string& data)
+{
+  return GetImplementation(*this).LoadFile(filename, data);
+}
+
+FeedbackPlayer::FeedbackPlayer( Internal::Adaptor::FeedbackPlayer* player )
+: BaseHandle( player )
+{
+}
+
+} // Dali
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-file-loader.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-file-loader.cpp
new file mode 100644 (file)
index 0000000..5cc6ad1
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015 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 <string>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/object/base-handle.h>
+#include <dali/devel-api/adaptor-framework/file-loader.h>
+
+namespace Dali
+{
+
+namespace FileLoader
+{
+
+int ReadFile(
+  const std::string& filename,
+  Dali::Vector<char> & memblock,
+  FileLoader::FileType fileType)
+{
+  return 0;
+}
+
+int ReadFile(
+  const std::string& filename,
+  std::streampos& fileSize,
+  Dali::Vector<char> & memblock,
+  FileLoader::FileType fileType)
+{
+  return 0;
+}
+
+std::streampos GetFileSize(const std::string& filename)
+{
+  return 0;
+}
+
+}
+}
index 30dd65f..b1b5660 100644 (file)
  *
  */
 
-#include "toolkit-orientation.h"
+#include <dali/devel-api/adaptor-framework/orientation.h>
 
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/signals/dali-signal.h>
 
-namespace Dali
-{
+using namespace Dali;
 
-namespace
+namespace Dali
 {
-ToolkitOrientation* gToolkitOrientation(NULL);
-} // unnamed namespace
+class Adaptor;
 
 namespace Internal
 {
-
 namespace Adaptor
 {
+class Window;
+
+
+struct RotationEvent
+{
+  int angle;     ///< one of 0, 90, 180, 270
+  int winResize; ///< true if the window should be resized
+  int width;     ///< new window width
+  int height;    ///< new window height
+};
 
 /**
- * Stub for the Orientation
+ * The RotationObserver can be overridden in order to listen to rotation events.
  */
-class Orientation : public BaseObject
+class RotationObserver
 {
-public: // Creation & Destruction
+public:
+  virtual void OnRotationPrepare( const RotationEvent& rotation ) = 0;
+  virtual void OnRotationRequest( ) = 0;
 
-  Orientation();
-  Orientation(ToolkitOrientation *orientation);
-  ~Orientation();
+protected:
+  RotationObserver(){}
+  virtual ~RotationObserver(){}
+};
 
-public: // Setters & Getters
+class Orientation : public BaseObject, public RotationObserver
+{
+public:
+  typedef Dali::Orientation::OrientationSignalType OrientationSignalType;
 
-  void SetDegrees( int degrees )
+  static Orientation* New(Window* window)
+  {
+    Orientation* orientation = new Orientation(window);
+    return orientation;
+  }
+  Orientation(Window* window)
   {
-    mOrientation = degrees;
   }
 
-  int GetDegrees() const;
-  float GetRadians() const;
-
-public: // Signals
-
-  Dali::Orientation::OrientationSignalType& ChangedSignal();
-
-  void EmitChangedSignal()
+protected:
+  virtual ~Orientation()
+  {
+  }
+public:
+  void SetAdaptor(Dali::Adaptor& adaptor)
+  {
+  }
+  int GetDegrees() const
+  {
+    return 0;
+  }
+  float GetRadians() const
+  {
+    return 0.0f;
+  }
+  OrientationSignalType& ChangedSignal()
   {
-    mChangedSignal.Emit(Dali::Orientation(this));
+    return mChangedSignal;
   }
+  virtual void OnRotationPrepare( const RotationEvent& rotation )
+  {
+  };
+  virtual void OnRotationRequest( )
+  {
+  };
 
 private:
-
-  Dali::Orientation::OrientationSignalType mChangedSignal;
-
-  ToolkitOrientation* mToolkitOrientation;
-
-  int mOrientation;
+  Orientation(const Orientation&);
+  Orientation& operator=(Orientation&);
+  OrientationSignalType mChangedSignal;
 };
 
-Orientation::Orientation()
-: mToolkitOrientation(NULL),
-  mOrientation(0)
-{
-}
+} // Adaptor namespace
+} // Internal namespace
 
-Orientation::Orientation(ToolkitOrientation *orientation)
-: mToolkitOrientation(orientation),
-  mOrientation(0)
+inline Internal::Adaptor::Orientation& GetImplementation (Dali::Orientation& orientation)
 {
+  DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
+  BaseObject& handle = orientation.GetBaseObject();
+  return static_cast<Internal::Adaptor::Orientation&>(handle);
 }
-
-Orientation::~Orientation()
+inline const Internal::Adaptor::Orientation& GetImplementation(const Dali::Orientation& orientation)
 {
+  DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
+  const BaseObject& handle = orientation.GetBaseObject();
+  return static_cast<const Internal::Adaptor::Orientation&>(handle);
 }
 
-int Orientation::GetDegrees() const
+Orientation::Orientation()
 {
-  mToolkitOrientation->mFunctionsCalled.GetDegrees = true;
-  return mOrientation;
 }
-
-float Orientation::GetRadians() const
+Orientation::~Orientation()
 {
-  mToolkitOrientation->mFunctionsCalled.GetRadians = true;
-  return Math::PI * (float)mOrientation / 180.0f;
 }
-
-Dali::Orientation::OrientationSignalType& Orientation::ChangedSignal()
+Orientation::Orientation(const Orientation& handle)
+: BaseHandle(handle)
 {
-  mToolkitOrientation->mFunctionsCalled.ChangedSignal = true;
-  return mChangedSignal;
 }
 
-} // namespace Adaptor
-
-} // namespace Internal
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-ToolkitOrientation::ToolkitOrientation()
-: mOrientationStub(new Internal::Adaptor::Orientation(this)),
-  mOrientation( mOrientationStub )
+Orientation& Orientation::operator=(const Orientation& rhs)
 {
-  gToolkitOrientation = this;
+  BaseHandle::operator=(rhs);
+  return *this;
 }
 
-ToolkitOrientation::~ToolkitOrientation()
+int Orientation::GetDegrees() const
 {
-  gToolkitOrientation = NULL;
+  return GetImplementation(*this).GetDegrees();
 }
 
-Orientation ToolkitOrientation::GetHandle()
+float Orientation::GetRadians() const
 {
-  return mOrientation;
+  return GetImplementation(*this).GetRadians();
 }
 
-void ToolkitOrientation::SetDegrees( int degrees )
+Orientation::OrientationSignalType& Orientation::ChangedSignal()
 {
-  mOrientationStub->SetDegrees( degrees );
+  return GetImplementation(*this).ChangedSignal();
 }
 
-void ToolkitOrientation::EmitChangedSignal()
+Orientation::Orientation( Internal::Adaptor::Orientation* orientation )
+: BaseHandle(orientation)
 {
-  mOrientationStub->EmitChangedSignal();
 }
 
-} // namespace Dali
+} // Dali
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.h
deleted file mode 100644 (file)
index 007f70f..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-#ifndef __DALI_TOOLKIT_TOOLKIT_ORIENTATION_H__
-#define __DALI_TOOLKIT_TOOLKIT_ORIENTATION_H__
-
-/*
- * 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-#include <dali/devel-api/adaptor-framework/orientation.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-namespace Adaptor
-{
-class Orientation;
-}
-}
-
-/**
- * This creates a stubbed Orientation so that internal Toolkit Adaptor calls work.
- * Furthermore, it provides an interface to see if certain methods were invoked.
- */
-class ToolkitOrientation
-{
-public: // Construction & Destruction
-
-  ToolkitOrientation();
-  ~ToolkitOrientation();
-
-public: // Getters
-
-  Orientation GetHandle();
-
-public: // Setters
-
-  void SetDegrees( int degrees );
-
-public: // Signal Emissions
-
-  void EmitChangedSignal();
-
-public: // TEST FUNCTIONS
-
-  // Enumeration of Adaptor methods
-  enum TestFuncEnum
-  {
-    GetDegrees,
-    GetRadians,
-    ChangedSignal,
-  };
-
-  void Reset()
-  {
-    mFunctionsCalled.Reset();
-  }
-
-  bool WasCalled(TestFuncEnum func)
-  {
-    switch(func)
-    {
-      case GetDegrees:          return mFunctionsCalled.GetDegrees;
-      case GetRadians:          return mFunctionsCalled.GetRadians;
-      case ChangedSignal:       return mFunctionsCalled.ChangedSignal;
-    }
-    return false;
-  }
-
-  void ResetCallStatistics(TestFuncEnum func)
-  {
-    switch(func)
-    {
-      case GetDegrees:          mFunctionsCalled.GetDegrees = false; break;
-      case GetRadians:          mFunctionsCalled.GetRadians = false; break;
-      case ChangedSignal:       mFunctionsCalled.ChangedSignal = false; break;
-    }
-  }
-
-private:
-
-  struct TestFunctions
-  {
-    TestFunctions()
-    : GetDegrees(false),
-      GetRadians(false),
-      ChangedSignal(false)
-    {
-    }
-
-    void Reset()
-    {
-      GetDegrees = false;
-      GetRadians = false;
-      ChangedSignal = false;
-    }
-
-    bool GetDegrees;
-    bool GetRadians;
-    bool ChangedSignal;
-  };
-
-  TestFunctions mFunctionsCalled;
-
-  // The stub
-  Internal::Adaptor::Orientation* mOrientationStub;
-  friend class Internal::Adaptor::Orientation;
-  Orientation mOrientation; // Hold a handle ourselves.
-};
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_TOOLKIT_ORIENTATION_H__
index 8ac2d0f..d8efd70 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -15,7 +15,7 @@
  *
  */
 
-#include "toolkit-singleton-service.h"
+#include <dali/devel-api/adaptor-framework/singleton-service.h>
 
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/object/base-object.h>
@@ -31,108 +31,125 @@ namespace Internal
 namespace Adaptor
 {
 
-/**
- * Stub for the SingletonService
- */
-class SingletonService : public Dali::BaseObject
+namespace
 {
-public:
-  static Dali::SingletonService New();
-  static Dali::SingletonService Get();
-  void Register( const std::type_info& info, BaseHandle singleton );
-  void UnregisterAll();
-  BaseHandle GetSingleton( const std::type_info& info ) const;
-
-private:
-  SingletonService();
-  virtual ~SingletonService();
+Dali::IntrusivePtr<SingletonService> gSingletonService;
+} // unnamed namespace
 
-  // Undefined
-  SingletonService( const SingletonService& );
-  SingletonService& operator=( SingletonService& );
 
-private:
-
-  typedef std::pair<std::string, BaseHandle> SingletonPair;
-  typedef std::map<std::string, BaseHandle>  SingletonContainer;
-  typedef SingletonContainer::const_iterator SingletonConstIter;
-
-  SingletonContainer mSingletonContainer; ///< The container to look up singleton by its type name
+class SingletonService : public Dali::BaseObject
+{
+public:
 
-  static Dali::SingletonService mToolkitSingletonService;
-};
+  /**
+   * Create a SingletonService.
+   * This should only be called once by the Application class.
+   * @return A newly created SingletonService.
+   */
+  static Dali::SingletonService New()
+  {
+    DALI_ASSERT_ALWAYS( 0 && "SingletonService New method used");
+    gSingletonService = Dali::IntrusivePtr<SingletonService>( new SingletonService() );
+    return Dali::SingletonService( gSingletonService.Get() );
+  }
 
-Dali::SingletonService SingletonService::mToolkitSingletonService;
+  /**
+   * @copydoc Dali::SingletonService::Get()
+   */
+  static Dali::SingletonService Get()
+  {
+    Dali::SingletonService singletonService;
+    if ( !gSingletonService )
+    {
+      gSingletonService = Dali::IntrusivePtr<SingletonService>( new SingletonService() );
+    }
+    return Dali::SingletonService( gSingletonService.Get() );
+  }
 
-Dali::SingletonService SingletonService::New()
-{
-  return Get();
-}
+  /**
+   * @copydoc Dali::SingletonService::Register()
+   */
+  void Register( const std::type_info& info, BaseHandle singleton )
+  {
+    if( singleton )
+    {
+      mSingletonContainer.insert( SingletonPair( info.name(), singleton ) );
+    }
+  }
 
-Dali::SingletonService SingletonService::Get()
-{
-  if( ! mToolkitSingletonService )
+  /**
+   * @copydoc Dali::SingletonService::UnregisterAll()
+   */
+  void UnregisterAll()
   {
-    mToolkitSingletonService = Dali::SingletonService( new Dali::Internal::Adaptor::SingletonService );
+    mSingletonContainer.clear();
   }
-  return mToolkitSingletonService;
-}
 
-void SingletonService::Register( const std::type_info& info, BaseHandle singleton )
-{
-  if( singleton )
+  /**
+   * @copydoc Dali::SingletonService::GetSingleton()
+   */
+  BaseHandle GetSingleton( const std::type_info& info ) const
   {
-    mSingletonContainer.insert( SingletonPair( info.name(), singleton ) );
+    BaseHandle object;
+
+    SingletonConstIter iter = mSingletonContainer.find(info.name());
+    if( iter != mSingletonContainer.end() )
+    {
+      object = ( *iter ).second;
+    }
+    return object;
   }
-}
 
-void SingletonService::UnregisterAll()
-{
-  mSingletonContainer.clear();
-}
+private:
 
-BaseHandle SingletonService::GetSingleton( const std::type_info& info ) const
-{
-  BaseHandle object;
+  /**
+   * Private Constructor
+   * @see SingletonService::New()
+   */
+  SingletonService()
+  : mSingletonContainer()
+  {
+    // Can only have one instance of SingletonService
+    DALI_ASSERT_ALWAYS( !gSingletonService && "Only one instance of SingletonService is allowed");
+    gSingletonService = this;
+  }
 
-  SingletonConstIter iter = mSingletonContainer.find(info.name());
-  if( iter != mSingletonContainer.end() )
+  /**
+   * Virtual Destructor
+   */
+  virtual ~SingletonService()
   {
-    object = ( *iter ).second;
+    gSingletonService = 0;
   }
 
-  return object;
-}
+  // Undefined
+  SingletonService( const SingletonService& );
+  SingletonService& operator=( SingletonService& );
 
-SingletonService::SingletonService()
-: mSingletonContainer()
-{
-}
+private:
+  typedef std::pair<std::string, BaseHandle> SingletonPair;
+  typedef std::map<std::string, BaseHandle>  SingletonContainer;
+  typedef SingletonContainer::const_iterator SingletonConstIter;
 
-SingletonService::~SingletonService()
-{
-}
+  SingletonContainer mSingletonContainer; ///< The container to look up singleton by its type name
+};
 
 } // namespace Adaptor
 } // namespace Internal
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
-Internal::Adaptor::SingletonService& GetImplementation(Dali::SingletonService& player)
+inline Internal::Adaptor::SingletonService& GetImplementation(Dali::SingletonService& player)
 {
   DALI_ASSERT_ALWAYS( player && "SingletonService handle is empty" );
-
   BaseObject& handle = player.GetBaseObject();
-
   return static_cast<Internal::Adaptor::SingletonService&>(handle);
 }
 
-const Internal::Adaptor::SingletonService& GetImplementation(const Dali::SingletonService& player)
+inline const Internal::Adaptor::SingletonService& GetImplementation(const Dali::SingletonService& player)
 {
   DALI_ASSERT_ALWAYS( player && "SingletonService handle is empty" );
-
   const BaseObject& handle = player.GetBaseObject();
-
   return static_cast<const Internal::Adaptor::SingletonService&>(handle);
 }
 
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.h
deleted file mode 100644 (file)
index 68e4ecc..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef __DALI_TOOLKIT_TOOLKIT_SINGLETON_SERVICE_H__
-#define __DALI_TOOLKIT_TOOLKIT_SINGLETON_SERVICE_H__
-
-/*
- * 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.
- *
- */
-
-// EXTERNAL INCLUDES
-
-#define __DALI_SINGELTON_SERVICE_H__
-#include <typeinfo>
-#include <dali/public-api/object/base-handle.h>
-
-// INTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class SingletonService;
-}
-}
-
-class SingletonService : public BaseHandle
-{
-public:
-  SingletonService();
-  static Dali::SingletonService New();
-  static SingletonService Get();
-  ~SingletonService();
-  void Register( const std::type_info& info, BaseHandle singleton );
-  void UnregisterAll();
-  BaseHandle GetSingleton( const std::type_info& info ) const;
-
-public: // Not intended for application developers
-  SingletonService( Internal::Adaptor::SingletonService* singletonService );
-};
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_TOOLKIT_SINGLETON_SERVICE_H__
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-sound-player.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-sound-player.cpp
new file mode 100644 (file)
index 0000000..8eefcfa
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2016 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 <dali/public-api/object/base-object.h>
+#include <dali/devel-api/adaptor-framework/singleton-service.h>
+#include <dali/devel-api/adaptor-framework/sound-player.h>
+
+using namespace Dali;
+
+namespace Dali
+{
+class Adaptor;
+
+namespace Internal
+{
+namespace Adaptor
+{
+
+
+class SoundPlayer : public Dali::BaseObject
+{
+public:
+  static Dali::SoundPlayer New()
+  {
+    Dali::SoundPlayer player = Dali::SoundPlayer( new SoundPlayer() );
+    return player;
+  }
+
+  static Dali::SoundPlayer Get()
+  {
+    Dali::SoundPlayer player;
+
+    Dali::SingletonService service( Dali::SingletonService::Get() );
+    if ( service )
+    {
+      // Check whether the singleton is already created
+      Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::SoundPlayer ) );
+      if ( handle )
+      {
+        // If so, downcast the handle
+        player = Dali::SoundPlayer( dynamic_cast< SoundPlayer* >( handle.GetObjectPtr() ) );
+      }
+      else
+      {
+        player = Dali::SoundPlayer( New() );
+        service.Register( typeid( player ), player );
+      }
+    }
+    return player;
+  }
+
+  int PlaySound(const std::string fileName)
+  {
+    return 0;
+  }
+
+  void Stop(int handle)
+  {
+  }
+
+private:
+  SoundPlayer()
+  {
+  }
+
+  virtual ~SoundPlayer()
+  {
+  }
+
+  SoundPlayer(const SoundPlayer&);
+  SoundPlayer& operator=(SoundPlayer&);
+};
+
+} // Adaptor namespace
+} // Internal namespace
+
+inline Internal::Adaptor::SoundPlayer& GetImplementation(Dali::SoundPlayer& player)
+{
+  DALI_ASSERT_ALWAYS( player && "SoundPlayer handle is empty" );
+  BaseObject& handle = player.GetBaseObject();
+  return static_cast<Internal::Adaptor::SoundPlayer&>(handle);
+}
+
+inline const Internal::Adaptor::SoundPlayer& GetImplementation(const Dali::SoundPlayer& player)
+{
+  DALI_ASSERT_ALWAYS( player && "SoundPlayer handle is empty" );
+  const BaseObject& handle = player.GetBaseObject();
+  return static_cast<const Internal::Adaptor::SoundPlayer&>(handle);
+}
+
+SoundPlayer SoundPlayer::Get()
+{
+  return Internal::Adaptor::SoundPlayer::Get();
+}
+
+SoundPlayer::SoundPlayer()
+{
+}
+
+SoundPlayer::SoundPlayer(Internal::Adaptor::SoundPlayer*player)
+:BaseHandle(player)
+{
+}
+
+SoundPlayer::~SoundPlayer()
+{
+}
+
+int SoundPlayer::PlaySound(const std::string fileName)
+{
+  return GetImplementation(*this).PlaySound(fileName);
+}
+
+} // Dali
index 65750c1..ba0469d 100644 (file)
 
 namespace Dali
 {
+const std::string Dali::StyleMonitor::DEFAULT_FONT_FAMILY("DefaultFont");
+const std::string Dali::StyleMonitor::DEFAULT_FONT_STYLE("Regular");
+const float       Dali::StyleMonitor::DEFAULT_FONT_SIZE(1.0f);
+}
 
+namespace
+{
+const char* DEFAULT_THEME=
+  "{\"styles\":{\n"
+  "  \"textlabel\":\n"
+  "    {\n"
+  "      \"fontStyle\":\"Regular\",\n"
+  "      \"pointSize\":18\n"
+  "    }\n"
+  "  }\n"
+  "}\n";
+
+std::string gTheme;
+std::string gFontFamily = Dali::StyleMonitor::DEFAULT_FONT_FAMILY;
+std::string gFontStyle  = Dali::StyleMonitor::DEFAULT_FONT_STYLE;
+float       gFontSize   = Dali::StyleMonitor::DEFAULT_FONT_SIZE;
+}
 
+namespace Dali
+{
 namespace Internal
 {
 namespace Adaptor
@@ -41,9 +64,11 @@ public: // Creation & Destruction
 
 public: // Style Information
   std::string GetDefaultFontFamily() const;
+  std::string GetDefaultFontStyle() const;
   float GetDefaultFontSize() const;
   const std::string& GetTheme() const;
   void SetTheme(std::string theme);
+  bool LoadThemeFile( const std::string& filename, std::string& output );
 
 public: // Signals
   Dali::StyleMonitor::StyleChangeSignalType& StyleChangeSignal();
@@ -57,6 +82,8 @@ private:
   Dali::StyleMonitor::StyleChangeSignalType mStyleChangeSignal;
   static Dali::StyleMonitor mToolkitStyleMonitor;
   std::string mTheme;
+
+  std::string mOutput; //<<< Test output. Use SetThemeFileOutput in a testharness to use it.
 };
 
 Dali::StyleMonitor StyleMonitor::mToolkitStyleMonitor;
@@ -81,12 +108,18 @@ StyleMonitor::~StyleMonitor()
 
 std::string StyleMonitor::GetDefaultFontFamily() const
 {
-  return Dali::StyleMonitor::DEFAULT_FONT_FAMILY;
+  return gFontFamily;
+}
+
+std::string StyleMonitor::GetDefaultFontStyle() const
+{
+  return gFontStyle;
 }
 
 float StyleMonitor::GetDefaultFontSize() const
 {
-  return Dali::StyleMonitor::DEFAULT_FONT_SIZE;
+  return gFontSize;
+
 }
 
 const std::string& StyleMonitor::GetTheme() const
@@ -100,6 +133,19 @@ void StyleMonitor::SetTheme(std::string path)
   EmitStyleChangeSignal( StyleChange::THEME_CHANGE );
 }
 
+bool StyleMonitor::LoadThemeFile( const std::string& filename, std::string& output )
+{
+  if( !gTheme.empty() )
+  {
+    output = gTheme;
+  }
+  else
+  {
+    output = DEFAULT_THEME;
+  }
+  return true;
+}
+
 Dali::StyleMonitor::StyleChangeSignalType& StyleMonitor::StyleChangeSignal()
 {
   return mStyleChangeSignal;
@@ -121,9 +167,6 @@ const Internal::Adaptor::StyleMonitor& GetImplementation(const Dali::StyleMonito
   return static_cast<const Internal::Adaptor::StyleMonitor&>(object);
 }
 
-const std::string Dali::StyleMonitor::DEFAULT_FONT_FAMILY("DefaultFont");
-const float       Dali::StyleMonitor::DEFAULT_FONT_SIZE(1.0f);
-
 StyleMonitor::StyleMonitor()
 {
 }
@@ -147,6 +190,11 @@ std::string StyleMonitor::GetDefaultFontFamily() const
   return GetImplementation(*this).GetDefaultFontFamily();
 }
 
+std::string StyleMonitor::GetDefaultFontStyle() const
+{
+  return GetImplementation(*this).GetDefaultFontStyle();
+}
+
 float StyleMonitor::GetDefaultFontSize() const
 {
   return GetImplementation(*this).GetDefaultFontSize();
@@ -172,6 +220,11 @@ void StyleMonitor::EmitStyleChangeSignal(StyleChange::Type styleChange)
   GetImplementation(*this).EmitStyleChangeSignal(styleChange);
 }
 
+bool StyleMonitor::LoadThemeFile( const std::string& filename, std::string& output )
+{
+  return GetImplementation(*this).LoadThemeFile(filename, output);
+}
+
 StyleMonitor& StyleMonitor::operator=(const StyleMonitor& monitor)
 {
   if( *this != monitor )
@@ -187,3 +240,31 @@ StyleMonitor::StyleMonitor(Internal::Adaptor::StyleMonitor* internal)
 }
 
 } // namespace Dali
+
+namespace Test
+{
+namespace StyleMonitor
+{
+
+void SetThemeFileOutput( const std::string& output )
+{
+  gTheme = output;
+}
+
+void SetDefaultFontFamily(const std::string& family)
+{
+  gFontFamily = family;
+}
+
+void SetDefaultFontStyle(const std::string& style)
+{
+  gFontStyle = style;
+}
+
+void SetDefaultFontSize( float size )
+{
+  gFontSize = size;
+}
+
+} // StyleMonitor
+} // Test
index 8aa55e5..9bdb67c 100644 (file)
@@ -43,6 +43,7 @@ class StyleMonitor : public BaseHandle
 public: // Typedefs
   typedef Signal< void (StyleMonitor, StyleChange::Type) > StyleChangeSignalType;
   static const std::string DEFAULT_FONT_FAMILY;
+  static const std::string DEFAULT_FONT_STYLE;
   static const float       DEFAULT_FONT_SIZE;
 
 public: // Creation & Destruction
@@ -54,9 +55,11 @@ public: // Creation & Destruction
 
 public: // Style Information
   std::string GetDefaultFontFamily() const;
+  std::string GetDefaultFontStyle() const;
   float GetDefaultFontSize() const;
   const std::string& GetTheme() const;
   void SetTheme(std::string themeFilePath);
+  bool LoadThemeFile( const std::string& filename, std::string& output );
 
 public: // Signals
   StyleChangeSignalType& StyleChangeSignal();
@@ -72,4 +75,16 @@ public:
 
 } // namespace Dali
 
+namespace Test
+{
+namespace StyleMonitor
+{
+void SetThemeFileOutput( const std::string& output );
+void SetDefaultFontFamily(const std::string& family);
+void SetDefaultFontStyle(const std::string& style);
+void SetDefaultFontSize( float size );
+
+}
+}
+
 #endif // __DALI_TOOLKIT_TOOLKIT_STYLE_MONITOR_H__
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-abstraction.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-abstraction.cpp
new file mode 100644 (file)
index 0000000..cd0c19d
--- /dev/null
@@ -0,0 +1,553 @@
+/*
+ * Copyright (c) 2016 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 <dali/devel-api/text-abstraction/bidirectional-support.h>
+#include <dali/devel-api/text-abstraction/font-client.h>
+#include <dali/devel-api/text-abstraction/font-metrics.h>
+#include <dali/devel-api/text-abstraction/glyph-info.h>
+#include <dali/devel-api/text-abstraction/script.h>
+#include <dali/devel-api/text-abstraction/segmentation.h>
+#include <dali/devel-api/text-abstraction/shaping.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/devel-api/adaptor-framework/singleton-service.h>
+#include <cstring>
+
+using namespace Dali;
+
+namespace Dali
+{
+class Adaptor;
+
+namespace TextAbstraction
+{
+namespace Internal
+{
+
+class BidirectionalSupport : public BaseObject
+{
+public:
+  BidirectionalSupport()
+  {
+  }
+
+  ~BidirectionalSupport()
+  {
+  }
+
+  static TextAbstraction::BidirectionalSupport Get()
+  {
+    TextAbstraction::BidirectionalSupport bidirectionalSupportHandle;
+
+    Dali::SingletonService service( Dali::SingletonService::Get() );
+    if( service )
+    {
+      // Check whether the singleton is already created
+      BaseHandle handle = service.GetSingleton( typeid( TextAbstraction::BidirectionalSupport ) );
+      if(handle)
+      {
+        // If so, downcast the handle
+        BidirectionalSupport* impl = dynamic_cast< Internal::BidirectionalSupport* >( handle.GetObjectPtr() );
+        bidirectionalSupportHandle = TextAbstraction::BidirectionalSupport( impl );
+      }
+      else // create and register the object
+      {
+        bidirectionalSupportHandle = TextAbstraction::BidirectionalSupport( new BidirectionalSupport );
+        service.Register( typeid( bidirectionalSupportHandle ), bidirectionalSupportHandle );
+      }
+    }
+    return bidirectionalSupportHandle;
+  }
+  BidiInfoIndex CreateInfo( const Character* const paragraph, Length numberOfCharacters ){return 0;}
+
+  void DestroyInfo( BidiInfoIndex bidiInfoIndex )
+  {
+  }
+
+  void Reorder( BidiInfoIndex bidiInfoIndex,CharacterIndex firstCharacterIndex,Length numberOfCharacters,CharacterIndex* visualToLogicalMap )
+  {
+  }
+
+  bool GetMirroredText( Character* text,CharacterDirection* directions,Length numberOfCharacters )
+  {
+    return true;
+  }
+
+  bool GetParagraphDirection( BidiInfoIndex bidiInfoIndex ) const
+  {
+    return true;
+  }
+
+  void GetCharactersDirection( BidiInfoIndex bidiInfoIndex, CharacterDirection* directions, Length numberOfCharacters )
+  {
+  }
+}; // class BidirectionalSupport
+
+
+class FontClient : public BaseObject
+{
+public:
+  FontClient()
+  : mDpiHorizontal( 0 ),
+    mDpiVertical( 0 )
+  {
+  }
+
+  ~FontClient(){}
+
+  static Dali::TextAbstraction::FontClient Get()
+  {
+    Dali::TextAbstraction::FontClient fontClientHandle;
+
+    Dali::SingletonService service( SingletonService::Get() );
+    if ( service )
+    {
+      // Check whether the singleton is already created
+      Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::TextAbstraction::FontClient ) );
+      if(handle)
+      {
+        // If so, downcast the handle
+        FontClient* impl = dynamic_cast< Dali::TextAbstraction::Internal::FontClient* >( handle.GetObjectPtr() );
+        fontClientHandle = Dali::TextAbstraction::FontClient( impl );
+      }
+      else // create and register the object
+      {
+        fontClientHandle = Dali::TextAbstraction::FontClient( new FontClient );
+        service.Register( typeid( fontClientHandle ), fontClientHandle );
+      }
+    }
+
+    return fontClientHandle;
+  }
+
+  void SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi ){}
+  void GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi ){horizontalDpi=verticalDpi=96;}
+
+  void ResetSystemDefaults(){}
+  void GetDefaultFonts( FontList& defaultFonts ){}
+  void GetDefaultPlatformFontDescription( FontDescription& fontDescription ){}
+  void GetSystemFonts( FontList& systemFonts ){}
+  void GetDescription( FontId id, FontDescription& fontDescription ){}
+  PointSize26Dot6 GetPointSize( FontId id ){return 9;}
+  FontId FindDefaultFont( Character charcode, PointSize26Dot6 pointSize, bool preferColor ){return 0;}
+  FontId FindFallbackFont( FontId preferredFont, Character charcode, PointSize26Dot6 pointSize, bool preferColor ){return 0;}
+  FontId GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex ){return 0;}
+  FontId GetFontId( const FontDescription& fontDescription,PointSize26Dot6 pointSize, FaceIndex faceIndex ){return 0;}
+  bool IsScalable( const FontPath& path ){return true;}
+  bool IsScalable( const FontDescription& fontDescription ){return true;}
+  void GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes ){}
+  void GetFixedSizes( const FontDescription& fontDescription, Dali::Vector< PointSize26Dot6 >& sizes ){}
+  void GetFontMetrics( FontId fontId, FontMetrics& metrics, int desiredFixedSize ){}
+  GlyphIndex GetGlyphIndex( FontId fontId, Character charcode ){return 0;}
+  bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal, int desiredFixedSize ){return true;}
+  BufferImage CreateBitmap( FontId fontId, GlyphIndex glyphIndex ){return BufferImage();}
+  void CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob,
+                         unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
+  {
+    blobLength = 0;
+  }
+  const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 pointSize ){return mGlyphInfo;}
+private:
+  unsigned int mDpiHorizontal;
+  unsigned int mDpiVertical;
+  GlyphInfo    mGlyphInfo;
+}; // class FontClient
+
+
+class Shaping : public BaseObject
+{
+public:
+  Shaping() : mText(NULL)
+  {}
+
+  ~Shaping()
+  {
+    delete [] mText;
+  }
+
+  static Dali::TextAbstraction::Shaping Get()
+  {
+    Dali::TextAbstraction::Shaping shapingHandle;
+
+    Dali::SingletonService service( SingletonService::Get() );
+    if ( service )
+    {
+      // Check whether the singleton is already created
+      Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::TextAbstraction::Shaping ) );
+      if(handle)
+      {
+        // If so, downcast the handle
+        Shaping* impl = dynamic_cast< Dali::TextAbstraction::Internal::Shaping* >( handle.GetObjectPtr() );
+        shapingHandle = Dali::TextAbstraction::Shaping( impl );
+      }
+      else // create and register the object
+      {
+        shapingHandle = Dali::TextAbstraction::Shaping( new Shaping );
+        service.Register( typeid( shapingHandle ), shapingHandle );
+      }
+    }
+    return shapingHandle;
+  }
+
+  void GetGlyphs(GlyphInfo* glyphStore, unsigned int*mappingTable)
+  {
+    // Return store & mapping table (0, 1, 2, 3... N-1))
+    if( glyphStore )
+    {
+      memcpy( glyphStore, mText, mNumChars );
+    }
+    for( unsigned int i=0; i<mNumChars ; ++i )
+    {
+      mappingTable[i] = i;
+    }
+  }
+
+  Length Shape(unsigned int const* text, unsigned int numChars, unsigned int fontId, Script script)
+  {
+    mText = new unsigned char[numChars];
+    mNumChars = numChars;
+
+    memcpy( mText, text, numChars );
+
+    return numChars;
+  }
+private:
+  unsigned char* mText;
+  unsigned int mNumChars;
+};
+
+} // Internal
+} // TextAbstraction
+
+inline static TextAbstraction::Internal::BidirectionalSupport& GetImplementation( TextAbstraction::BidirectionalSupport& bidirectionalSupport )
+{
+  DALI_ASSERT_ALWAYS( bidirectionalSupport && "bidirectional support handle is empty" );
+  BaseObject& object = bidirectionalSupport.GetBaseObject();
+  return static_cast<TextAbstraction::Internal::BidirectionalSupport&>(object);
+}
+
+inline static const TextAbstraction::Internal::BidirectionalSupport& GetImplementation( const TextAbstraction::BidirectionalSupport& bidirectionalSupport )
+{
+  DALI_ASSERT_ALWAYS( bidirectionalSupport && "bidirectional support handle is empty" );
+  const BaseObject& object = bidirectionalSupport.GetBaseObject();
+  return static_cast<const TextAbstraction::Internal::BidirectionalSupport&>(object);
+}
+
+inline static TextAbstraction::Internal::FontClient& GetImplementation(TextAbstraction::FontClient& fontClient)
+{
+  DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" );
+  BaseObject& handle = fontClient.GetBaseObject();
+  return static_cast<TextAbstraction::Internal::FontClient&>(handle);
+}
+
+inline static const TextAbstraction::Internal::FontClient& GetImplementation(const TextAbstraction::FontClient& fontClient)
+{
+  DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" );
+  const BaseObject& handle = fontClient.GetBaseObject();
+  return static_cast<const TextAbstraction::Internal::FontClient&>(handle);
+}
+
+inline static TextAbstraction::Internal::Shaping& GetImplementation(TextAbstraction::Shaping& shaping)
+{
+  DALI_ASSERT_ALWAYS( shaping && "shaping handle is empty" );
+  BaseObject& handle = shaping.GetBaseObject();
+  return static_cast<TextAbstraction::Internal::Shaping&>(handle);
+}
+
+inline static const TextAbstraction::Internal::Shaping& GetImplementation(const TextAbstraction::Shaping& shaping)
+{
+  DALI_ASSERT_ALWAYS( shaping && "shaping handle is empty" );
+  const BaseObject& handle = shaping.GetBaseObject();
+  return static_cast<const TextAbstraction::Internal::Shaping&>(handle);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+/******************************************************************************/
+
+namespace TextAbstraction
+{
+const PointSize26Dot6 FontClient::DEFAULT_POINT_SIZE = 768u; // 12*64
+
+BidirectionalSupport::BidirectionalSupport()
+{
+}
+
+BidirectionalSupport::~BidirectionalSupport()
+{
+}
+
+BidirectionalSupport::BidirectionalSupport( Internal::BidirectionalSupport* implementation )
+: BaseHandle( implementation )
+{
+}
+
+BidirectionalSupport BidirectionalSupport::Get()
+{
+  return Internal::BidirectionalSupport::Get();
+}
+
+BidiInfoIndex BidirectionalSupport::CreateInfo( const Character* const paragraph,
+                                                Length numberOfCharacters )
+{
+  return GetImplementation( *this ).CreateInfo( paragraph, numberOfCharacters );
+}
+
+void BidirectionalSupport::DestroyInfo( BidiInfoIndex bidiInfoIndex )
+{
+  GetImplementation( *this ).DestroyInfo( bidiInfoIndex );
+}
+
+void BidirectionalSupport::Reorder( BidiInfoIndex bidiInfoIndex,
+                                    CharacterIndex firstCharacterIndex,
+                                    Length numberOfCharacters,
+                                    CharacterIndex* visualToLogicalMap )
+{
+  GetImplementation( *this ).Reorder( bidiInfoIndex, firstCharacterIndex, numberOfCharacters, visualToLogicalMap );
+}
+
+bool BidirectionalSupport::GetMirroredText( Character* text,
+                                            CharacterDirection* directions,
+                                            Length numberOfCharacters )
+{
+  return GetImplementation( *this ).GetMirroredText( text, directions, numberOfCharacters );
+}
+
+bool BidirectionalSupport::GetParagraphDirection( BidiInfoIndex bidiInfoIndex ) const
+{
+  return GetImplementation( *this ).GetParagraphDirection( bidiInfoIndex );
+}
+
+void BidirectionalSupport::GetCharactersDirection( BidiInfoIndex bidiInfoIndex,
+                                                   CharacterDirection* directions,
+                                                   Length numberOfCharacters )
+{
+  GetImplementation( *this ).GetCharactersDirection( bidiInfoIndex, directions, numberOfCharacters );
+}
+
+
+FontClient FontClient::Get()
+{
+  return Internal::FontClient::Get();
+}
+
+FontClient::FontClient()
+{
+}
+
+FontClient::~FontClient()
+{
+}
+
+FontClient::FontClient( const FontClient& handle )
+: BaseHandle( handle )
+{
+}
+
+FontClient& FontClient::operator=( const FontClient& handle )
+{
+  BaseHandle::operator=( handle );
+  return *this;
+}
+
+void FontClient::SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi  )
+{
+  GetImplementation(*this).SetDpi( horizontalDpi, verticalDpi );
+}
+
+void FontClient::GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi )
+{
+  GetImplementation(*this).GetDpi( horizontalDpi, verticalDpi );
+}
+
+void FontClient::ResetSystemDefaults()
+{
+  GetImplementation(*this).ResetSystemDefaults();
+}
+
+void FontClient::GetDefaultFonts( FontList& defaultFonts )
+{
+  GetImplementation(*this).GetDefaultFonts( defaultFonts );
+}
+
+void FontClient::GetDefaultPlatformFontDescription( FontDescription& fontDescription )
+{
+  GetImplementation(*this).GetDefaultPlatformFontDescription( fontDescription );
+}
+
+void FontClient::GetSystemFonts( FontList& systemFonts )
+{
+  GetImplementation(*this).GetSystemFonts( systemFonts );
+}
+
+void FontClient::GetDescription( FontId id, FontDescription& fontDescription )
+{
+  GetImplementation(*this).GetDescription( id, fontDescription );
+}
+
+PointSize26Dot6 FontClient::GetPointSize( FontId id )
+{
+  return GetImplementation(*this).GetPointSize( id );
+}
+
+FontId FontClient::FindDefaultFont( Character charcode, PointSize26Dot6 pointSize, bool preferColor )
+{
+  return GetImplementation(*this).FindDefaultFont( charcode, pointSize, preferColor );
+}
+
+FontId FontClient::FindFallbackFont( FontId preferredFont, Character charcode, PointSize26Dot6 pointSize, bool preferColor )
+{
+  return GetImplementation(*this).FindFallbackFont( preferredFont, charcode, pointSize, preferColor );
+}
+
+FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex )
+{
+  return GetImplementation(*this).GetFontId( path, pointSize, faceIndex );
+}
+
+FontId FontClient::GetFontId( const FontDescription& fontDescription,
+                              PointSize26Dot6 pointSize,
+                              FaceIndex faceIndex )
+{
+  return GetImplementation(*this).GetFontId( fontDescription,
+                                             pointSize,
+                                             faceIndex );
+}
+
+bool FontClient::IsScalable( const FontPath& path )
+{
+  return GetImplementation(*this).IsScalable( path );
+}
+
+bool FontClient::IsScalable( const FontDescription& fontDescription )
+{
+  return GetImplementation(*this).IsScalable( fontDescription );
+}
+
+void FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
+{
+  GetImplementation(*this).GetFixedSizes( path, sizes );
+}
+
+void FontClient::GetFixedSizes( const FontDescription& fontDescription,
+                                Dali::Vector< PointSize26Dot6 >& sizes )
+{
+  GetImplementation(*this).GetFixedSizes( fontDescription, sizes );
+}
+
+void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics, int desiredFixedSize )
+{
+  GetImplementation(*this).GetFontMetrics( fontId, metrics, desiredFixedSize );
+}
+
+GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
+{
+  return GetImplementation(*this).GetGlyphIndex( fontId, charcode );
+}
+
+bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal, int desiredFixedSize )
+{
+  return GetImplementation(*this).GetGlyphMetrics( array, size, horizontal, desiredFixedSize );
+}
+
+BufferImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
+{
+  return GetImplementation(*this).CreateBitmap( fontId, glyphIndex );
+}
+
+
+void FontClient::CreateVectorBlob( FontId fontId,
+                                   GlyphIndex glyphIndex,
+                                   VectorBlob*& blob,
+                                   unsigned int& blobLength,
+                                   unsigned int& nominalWidth,
+                                   unsigned int& nominalHeight )
+{
+  GetImplementation(*this).CreateVectorBlob( fontId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight );
+}
+
+const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 pointSize )
+{
+  return GetImplementation(*this).GetEllipsisGlyph( pointSize );
+}
+
+FontClient::FontClient( Internal::FontClient* internal )
+: BaseHandle( internal )
+{
+}
+
+FontMetrics::FontMetrics()
+: ascender( 0.f ),
+  descender( 0.f ),
+  height( 0.f ),
+  underlinePosition( 0.f ),
+  underlineThickness( 0.f )
+{
+}
+
+GlyphInfo::GlyphInfo()
+{
+}
+
+Script GetCharacterScript(unsigned int x)
+{
+  return LATIN;
+}
+bool HasLigatureMustBreak(Script x){return false;}
+bool IsCommonScript(unsigned int character){ return false;}
+bool IsNewParagraph(unsigned int character){return false;}
+bool IsRightToLeftScript(Script){return false;}
+bool IsWhiteSpace(unsigned int character)
+{
+  return character < 0x21;
+}
+
+Segmentation Segmentation::Get(){ return Segmentation();}
+Segmentation::Segmentation(){}
+Segmentation::~Segmentation(){}
+void Segmentation::GetLineBreakPositions(unsigned int const*, unsigned int, char*){}
+void Segmentation::GetWordBreakPositions(unsigned int const*, unsigned int, char*){}
+
+Shaping Shaping::Get()
+{
+  return TextAbstraction::Internal::Shaping::Get();
+}
+
+Shaping::Shaping()
+{
+}
+
+Shaping::Shaping( Internal::Shaping* internal )
+: BaseHandle( internal )
+{
+}
+
+Shaping::~Shaping()
+{
+}
+
+void Shaping::GetGlyphs(GlyphInfo* glyphStore, unsigned int*mappingTable)
+{
+  // Return store & mapping table (0, 1, 2, 3... N-1))
+  GetImplementation(*this).GetGlyphs(glyphStore, mappingTable);
+}
+
+Length Shaping::Shape(unsigned int const* text, unsigned int numChars, unsigned int fontId, Script script)
+{
+  return GetImplementation(*this).Shape( text, numChars, fontId, script );
+}
+
+} // TextAbstraction
+} // Dali
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-virtual-keyboard.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-virtual-keyboard.cpp
new file mode 100644 (file)
index 0000000..e3f3ce5
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2016 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 <dali/devel-api/adaptor-framework/virtual-keyboard.h>
+#include <dali/public-api/adaptor-framework/key.h>
+
+using namespace Dali;
+
+namespace Dali
+{
+class Adaptor;
+
+namespace Internal
+{
+namespace Adaptor
+{
+
+namespace VirtualKeyboard
+{
+Dali::VirtualKeyboard::StatusSignalType gKeyboardStatusSignal;
+}
+
+} // Adaptor
+} // Internal
+
+
+bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey)
+{
+  return true;
+}
+
+namespace VirtualKeyboard
+{
+
+void ApplySettings( Dali::Property::Map const& )
+{
+}
+
+bool IsVisible()
+{
+  return false;
+}
+
+void Show()
+{
+}
+
+StatusSignalType& StatusChangedSignal()
+{
+  return Internal::Adaptor::VirtualKeyboard::gKeyboardStatusSignal;
+}
+
+} // VirtualKeyboard
+} // Dali
index 810079f..55fa608 100644 (file)
@@ -321,7 +321,7 @@ int UtcDaliControlRendererGetPropertyMap2(void)
   DALI_TEST_CHECK( typeValue );
   DALI_TEST_CHECK( typeValue->Get<std::string>() == "border" );
 
-   colorValue = resultMap.Find( "borderColor",  Property::VECTOR4 );
+  colorValue = resultMap.Find( "borderColor",  Property::VECTOR4 );
   DALI_TEST_CHECK( colorValue );
   DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
 
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-StyleManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-StyleManager.cpp
deleted file mode 100644 (file)
index 98a4d0b..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * 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/integration-api/events/touch-event-integ.h>
-#include <dali-toolkit/devel-api/styling/style-manager.h>
-
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-void dali_style_manager_startup(void)
-{
-  test_return_value = TET_UNDEF;
-}
-
-void dali_style_manager_cleanup(void)
-{
-  test_return_value = TET_PASS;
-}
-
-int UtcDaliStyleManagerGet(void)
-{
-  ToolkitTestApplication application;
-
-  tet_infoline(" UtcDaliStyleManagerGet");
-
-  // Register Type
-  TypeInfo type;
-  type = TypeRegistry::Get().GetTypeInfo( "StyleManager" );
-  DALI_TEST_CHECK( type );
-  BaseHandle handle = type.CreateInstance();
-  DALI_TEST_CHECK( handle );
-
-  StyleManager manager;
-
-  manager = StyleManager::Get();
-  DALI_TEST_CHECK(manager);
-
-  StyleManager newManager = StyleManager::Get();
-  DALI_TEST_CHECK(newManager);
-
-  // Check that focus manager is a singleton
-  DALI_TEST_CHECK(manager == newManager);
-  END_TEST;
-}
-
-int UtcDaliStyleManagerSetOrientationValue(void)
-{
-  ToolkitTestApplication application;
-
-  tet_infoline( " UtcDaliStyleManagerSetOrientationValue" );
-
-  StyleManager manager = StyleManager::Get();
-
-  int orientation1 = 0;
-  manager.SetOrientationValue( orientation1 );
-  DALI_TEST_CHECK( manager.GetOrientationValue() == orientation1 );
-
-  int orientation2 = 180;
-  manager.SetOrientationValue( orientation2 );
-  DALI_TEST_CHECK( manager.GetOrientationValue() == orientation2 );
-
-  END_TEST;
-}
-
-int UtcDaliStyleManagerSetOrientation(void)
-{
-  ToolkitTestApplication application;
-
-  tet_infoline( " UtcDaliStyleManagerSetOrientation" );
-
-  StyleManager manager = StyleManager::Get();
-
-  Orientation orientation;
-
-  manager.SetOrientation( orientation );
-
-  DALI_TEST_CHECK( manager.GetOrientation() == orientation );
-
-  END_TEST;
-}
-
-int UtcDaliStyleManagerSetStyleConstant(void)
-{
-  ToolkitTestApplication application;
-
-  tet_infoline( " UtcDaliStyleManagerSetStyleConstant" );
-
-  StyleManager manager = StyleManager::Get();
-
-  std::string key( "key" );
-  Property::Value value( 100 );
-
-  manager.SetStyleConstant( key, value );
-
-  Property::Value returnedValue;
-  manager.GetStyleConstant( key, returnedValue );
-
-  DALI_TEST_CHECK( value.Get<int>() == returnedValue.Get<int>() );
-
-  std::string key2( "key2" );
-  Property::Value returnedValue2;
-  DALI_TEST_CHECK( !manager.GetStyleConstant( key2, returnedValue2 ) );
-
-  END_TEST;
-}
index 19e2f1f..01be6ba 100644 (file)
@@ -88,9 +88,9 @@ StyleManager::StyleManager( Internal::StyleManager *impl )
 {
 }
 
-StyleManager::StyleChangeSignalType& StyleManager::StyleChangeSignal()
+StyleManager::StyleChangedSignalType& StyleManager::StyleChangedSignal()
 {
-  return GetImpl( *this ).StyleChangeSignal();
+  return GetImpl( *this ).StyleChangedSignal();
 }
 
 void StyleManager::RequestThemeChange( const std::string& themeFile )
@@ -106,4 +106,3 @@ void StyleManager::RequestDefaultTheme()
 } // namespace Toolkit
 
 } // namespace Dali
-
index 8c9f3b5..2d790a4 100644 (file)
@@ -43,28 +43,17 @@ class StyleManager;
  *
  * The default theme is automatically loaded and applied.
  *
- * If the application wants to customize the theme, RequestThemeChange needs to be called.
- * Also, the default orientation is Portrait, if the application wants to adapt to the orientation change, call SetOrientation or SetOrienationValue.
- * @code
- *   const char* CUSTOM_THEME = DALI_SCRIPT_DIR "tizen-dark-theme.json";
- *
- *   void OnInit(Application& app)
- *   {
- *      Toolkit::StyleManager::Get().RequestThemeChange( CUSTOM_THEME );
- *      Toolkit::StyleManager::Get().SetOrientation( ... );
- *      ...
- *   }
- * @endcode
- *
- * Internal::Control can be configured to register for the signals that are required from StyleManager,
- * such as theme change.
+ * If the application wants to customize the theme, RequestThemeChange
+ * needs to be called.  Internal::Control can be configured to
+ * register for the signals that are required from StyleManager, such
+ * as theme change.
  */
 class DALI_IMPORT_API StyleManager : public BaseHandle
 {
 public:
 
   // Signals
-  typedef Signal< void ( StyleManager, StyleChange::Type ) >  StyleChangeSignalType;
+  typedef Signal< void ( StyleManager, StyleChange::Type ) >  StyleChangedSignalType;
 
   /**
    * @brief Create a StyleManager handle; this can be initialised with StyleManager::Get()
@@ -171,14 +160,16 @@ public:
 public: // Signals
 
   /**
-   * @brief This signal is emitted whenever the style (e.g. theme/font change) is changed on device
+   * @brief This signal is emitted after the style (e.g. theme/font change) has changed
+   * and the controls have been informed.
+   *
    * A callback of the following type may be connected:
    * @code
    *   void YourCallbackName( StyleManager styleManager, StyleChange change );
    * @endcode
    * @return The signal to connect to.
    */
-  StyleChangeSignalType& StyleChangeSignal();
+  StyleChangedSignalType& StyleChangedSignal();
 
 public:
 
index f0c3fc6..8301a08 100644 (file)
@@ -802,34 +802,34 @@ void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange:
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange\n");
 
-   switch ( change )
-   {
-     case StyleChange::DEFAULT_FONT_CHANGE:
-     {
-       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange DEFAULT_FONT_CHANGE\n");
-       std::string newFont = styleManager.GetDefaultFontFamily();
-       // Property system did not set the font so should update it.
-       mController->UpdateAfterFontChange( newFont );
-       break;
-     }
-
-     case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
-     {
-       DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor::OnStyleChange StyleChange::DEFAULT_FONT_SIZE_CHANGE (%f)\n", mController->GetDefaultPointSize() );
-
-       if ( (mController->GetDefaultPointSize() <= 0.0f) ) // If DefaultPointSize not set by Property system it will be 0.0f
-       {
-         // Property system did not set the PointSize so should update it.
-         // todo instruct text-controller to update model
-       }
-       break;
-     }
-     case StyleChange::THEME_CHANGE:
-     {
-       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
-       break;
-     }
-   }
+  switch ( change )
+  {
+    case StyleChange::DEFAULT_FONT_CHANGE:
+    {
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange DEFAULT_FONT_CHANGE\n");
+      std::string newFont = styleManager.GetDefaultFontFamily();
+      // Property system did not set the font so should update it.
+      mController->UpdateAfterFontChange( newFont );
+      break;
+    }
+
+    case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
+    {
+      DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor::OnStyleChange StyleChange::DEFAULT_FONT_SIZE_CHANGE (%f)\n", mController->GetDefaultPointSize() );
+
+      if ( (mController->GetDefaultPointSize() <= 0.0f) ) // If DefaultPointSize not set by Property system it will be 0.0f
+      {
+        // Property system did not set the PointSize so should update it.
+        // todo instruct text-controller to update model
+      }
+      break;
+    }
+    case StyleChange::THEME_CHANGE:
+    {
+      GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+      break;
+    }
+  }
 }
 
 Vector3 TextEditor::GetNaturalSize()
index 082e7e5..ef00fc3 100644 (file)
@@ -1024,34 +1024,34 @@ void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange\n");
 
-   switch ( change )
-   {
-     case StyleChange::DEFAULT_FONT_CHANGE:
-     {
-       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
-       std::string newFont = styleManager.GetDefaultFontFamily();
-       // Property system did not set the font so should update it.
-       mController->UpdateAfterFontChange( newFont );
-       break;
-     }
-
-     case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
-     {
-       DALI_LOG_INFO( gLogFilter, Debug::General, "TextField::OnStyleChange StyleChange::DEFAULT_FONT_SIZE_CHANGE (%f)\n", mController->GetDefaultPointSize() );
-
-       if ( (mController->GetDefaultPointSize() <= 0.0f) ) // If DefaultPointSize not set by Property system it will be 0.0f
-       {
-         // Property system did not set the PointSize so should update it.
-         // todo instruct text-controller to update model
-       }
-       break;
-     }
-     case StyleChange::THEME_CHANGE:
-     {
-       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
-       break;
-     }
-   }
+  switch ( change )
+  {
+    case StyleChange::DEFAULT_FONT_CHANGE:
+    {
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
+      std::string newFont = styleManager.GetDefaultFontFamily();
+      // Property system did not set the font so should update it.
+      mController->UpdateAfterFontChange( newFont );
+      break;
+    }
+
+    case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
+    {
+      DALI_LOG_INFO( gLogFilter, Debug::General, "TextField::OnStyleChange StyleChange::DEFAULT_FONT_SIZE_CHANGE (%f)\n", mController->GetDefaultPointSize() );
+
+      if ( (mController->GetDefaultPointSize() <= 0.0f) ) // If DefaultPointSize not set by Property system it will be 0.0f
+      {
+        // Property system did not set the PointSize so should update it.
+        // todo instruct text-controller to update model
+      }
+      break;
+    }
+    case StyleChange::THEME_CHANGE:
+    {
+      GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+      break;
+    }
+  }
 }
 
 Vector3 TextField::GetNaturalSize()
index 9d3fd45..cc633b1 100644 (file)
@@ -486,7 +486,6 @@ void TextLabel::OnInitialize()
 
 void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
 {
-
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextLabel::OnStyleChange\n");
 
   switch ( change )
index 85aa069..f9569b9 100644 (file)
@@ -248,9 +248,14 @@ void StyleManager::ApplyStyle( Toolkit::Control control, const std::string& json
   }
 }
 
-Toolkit::StyleManager::StyleChangeSignalType& StyleManager::StyleChangeSignal()
+Toolkit::StyleManager::StyleChangedSignalType& StyleManager::StyleChangedSignal()
 {
-  return mStyleChangeSignal;
+  return mStyleChangedSignal;
+}
+
+Toolkit::StyleManager::StyleChangedSignalType& StyleManager::ControlStyleChangeSignal()
+{
+  return mControlStyleChangeSignal;
 }
 
 void StyleManager::SetTheme( const std::string& themeFile )
@@ -275,7 +280,7 @@ void StyleManager::SetTheme( const std::string& themeFile )
       mFeedbackStyle->StyleChanged( mThemeFile, StyleChange::THEME_CHANGE );
     }
 
-    mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), StyleChange::THEME_CHANGE );
+    EmitStyleChangeSignals(StyleChange::THEME_CHANGE);
   }
   else
   {
@@ -447,10 +452,21 @@ void StyleManager::StyleMonitorChange( StyleMonitor styleMonitor, StyleChange::T
       break;
     }
   }
+  EmitStyleChangeSignals( styleChange );
+}
 
-  mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), styleChange );
+void StyleManager::EmitStyleChangeSignals( StyleChange::Type styleChange )
+{
+  Toolkit::StyleManager styleManager = StyleManager::Get();
+
+  // Update Controls first
+  mControlStyleChangeSignal.Emit( styleManager, styleChange );
+
+  // Inform application last
+  mStyleChangedSignal.Emit( styleManager, styleChange );
 }
 
+
 } // namespace Internal
 
 } // namespace Toolkit
index 294e601..283cf96 100644 (file)
@@ -136,8 +136,16 @@ public:
 
   /**
    * @copydoc Toolkit::StyleManager::StyleChangeSignal
+   * This signal is sent after all the controls have been updated
+   * due to style change
    */
-  Toolkit::StyleManager::StyleChangeSignalType& StyleChangeSignal();
+  Toolkit::StyleManager::StyleChangedSignalType& StyleChangedSignal();
+
+  /**
+   * This signal is sent to the controls following a style change.
+   * It should not be exposed in the public API
+   */
+  Toolkit::StyleManager::StyleChangedSignalType& ControlStyleChangeSignal();
 
 private:
   typedef std::vector<std::string> StringList;
@@ -232,6 +240,12 @@ private:
    */
   void StyleMonitorChange( StyleMonitor styleMonitor, StyleChange::Type styleChange );
 
+  /**
+   * Emit signals to controls first, app second
+   */
+  void EmitStyleChangeSignals( StyleChange::Type styleChange );
+
+
   // Undefined
   StyleManager(const StyleManager&);
 
@@ -260,7 +274,8 @@ private:
   Toolkit::Internal::FeedbackStyle* mFeedbackStyle; ///< Feedback style
 
   // Signals
-  Toolkit::StyleManager::StyleChangeSignalType       mStyleChangeSignal;         ///< Emitted when the style( theme/font ) changes
+  Toolkit::StyleManager::StyleChangedSignalType mControlStyleChangeSignal; ///< Emitted when the style( theme/font ) changes for the controls to style themselves
+  Toolkit::StyleManager::StyleChangedSignalType mStyleChangedSignal; ///< Emitted after the controls have been styled
 };
 
 } // namespace Internal
index 841e3d3..2019553 100644 (file)
@@ -674,12 +674,12 @@ Toolkit::Control::KeyEventSignalType& Control::KeyEventSignal()
   return mImpl->mKeyEventSignal;
 }
 
-Toolkit::Control::KeyInputFocusSignalType& Control:: KeyInputFocusGainedSignal()
+Toolkit::Control::KeyInputFocusSignalType& Control::KeyInputFocusGainedSignal()
 {
   return mImpl->mKeyInputFocusGainedSignal;
 }
 
-Toolkit::Control::KeyInputFocusSignalType& Control:: KeyInputFocusLostSignal()
+Toolkit::Control::KeyInputFocusSignalType& Control::KeyInputFocusLostSignal()
 {
   return mImpl->mKeyInputFocusLostSignal;
 }
@@ -720,15 +720,18 @@ void Control::Initialize()
 
   if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
   {
-    Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+    Toolkit::StyleManager styleManager = StyleManager::Get();
+
     // if stylemanager is available
     if( styleManager )
     {
+      StyleManager& styleManagerImpl = GetImpl( styleManager );
+
       // Register for style changes
-      styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
+      styleManagerImpl.ControlStyleChangeSignal().Connect( this, &Control::OnStyleChange );
 
       // Apply the current style
-      GetImpl( styleManager ).ApplyThemeStyleAtInit( Toolkit::Control( GetOwner() ) );
+      styleManagerImpl.ApplyThemeStyleAtInit( Toolkit::Control( GetOwner() ) );
     }
   }