Asynchronous Load N-patch resource
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-TextureManager.cpp
index af5f1a6..21f6f7c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 
 using namespace Dali::Toolkit::Internal;
 
+
+void utc_dali_toolkit_texture_manager_startup(void)
+{
+  setenv( "LOG_TEXTURE_MANAGER", "3", 1 );
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_toolkit_texture_manager_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
 class TestObserver : public Dali::Toolkit::TextureUploadObserver
 {
 public:
@@ -41,6 +53,12 @@ public:
     mObserverCalled = true;
   }
 
+  virtual void LoadComplete( bool loadSuccess, Devel::PixelBuffer pixelBuffer, const VisualUrl& url, bool preMultiplied ) override
+  {
+    mLoaded = loadSuccess;
+    mObserverCalled = true;
+  }
+
   bool mLoaded;
   bool mObserverCalled;
 };
@@ -72,3 +90,30 @@ int UtcTextureManagerRequestLoad(void)
 
   END_TEST;
 }
+
+int UtcTextureManagerGenerateHash(void)
+{
+  ToolkitTestApplication application;
+
+  TextureManager textureManager; // Create new texture manager
+
+  TestObserver observer;
+  std::string filename( "image.png" );
+  auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
+  TextureManager::TextureId textureId = textureManager.RequestLoad(
+    filename,
+    ImageDimensions(),
+    FittingMode::SCALE_TO_FILL,
+    SamplingMode::BOX_THEN_LINEAR,
+    TextureManager::USE_ATLAS,
+    &observer,
+    true,
+    TextureManager::ReloadPolicy::CACHED,
+    preMultiply);
+
+  VisualUrl url = textureManager.GetVisualUrl( textureId );
+
+  DALI_TEST_EQUALS( url.GetUrl().compare( filename ), 0, TEST_LOCATION );
+
+  END_TEST;
+}