-
-int UtcDaliInternalSaveResource01(void)
-{
- TestApplication application;
- tet_infoline("Testing SaveResource() with valid id, and valid filename");
-
- Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
-
- Dali::ModelData modelData = BuildTreeModel();
- testTicketObserver.Reset();
-
- Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( Integration::ModelResourceType(), "model.dae" );
- ticket->AddObserver(testTicketObserver);
-
- // First, load a model resource
- application.SendNotification(); // Flush update messages
- application.Render(); // Process resource request
- Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Internal::ModelData& modelDataImpl = GetImplementation(modelData);
- Integration::ResourcePointer resourcePtr(&modelDataImpl);
-
- application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
- application.Render(); // Process LoadComplete
- application.SendNotification(); // Process event messages
- DALI_TEST_CHECK( ticket->GetLoadingState() == ResourceLoadingSucceeded );
-
- // Try saving it
- resourceClient.SaveResource( ticket, "model.dali-bin" );
- application.SendNotification(); // Flush update messages
- application.Render(); // Process save resource request
-
- DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::SaveResourceFunc ) );
- req = application.GetPlatform().GetRequest();
- DALI_TEST_CHECK( req->GetType()->id == Integration::ResourceModel );
- DALI_TEST_CHECK( req->GetPath().compare("model.dali-bin") == 0 );
-
- // Set up success response
- application.GetPlatform().SetResourceSaved(req->GetId(), req->GetType()->id);
- application.Render(); // GetResources --> SaveComplete
- application.SendNotification(); // Send event messages
-
- DALI_TEST_CHECK( testTicketObserver.SaveSucceededCalled() == 1 );
- DALI_TEST_EQUALS( ticket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION )
-;
- END_TEST;
-}
-
-
-int UtcDaliInternalSaveResource02(void)
-{
- TestApplication application;
- tet_infoline("Testing SaveResource() with invalid id");
- testTicketObserver.Reset();
-
- Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
-
- Dali::ModelData modelData = BuildTreeModel();
-
- Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( Integration::ModelResourceType(), "model.dae" );
- ticket->AddObserver(testTicketObserver);
-
- // First, load a model resource
- application.SendNotification(); // Flush update messages
- application.Render(); // Process resource request
- Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Internal::ModelData& modelDataImpl = GetImplementation(modelData);
- Integration::ResourcePointer resourcePtr(&modelDataImpl);
- application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
- application.Render(); // Process LoadComplete
- application.SendNotification(); // Process event messages
- DALI_TEST_CHECK(ticket->GetLoadingState() == ResourceLoadingSucceeded);
- application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
-
- Internal::ResourceTypePath typePath(Integration::ModelResourceType(), "");
- Internal::ResourceTicketPtr aTicket = new Internal::ResourceTicket( testTicketLifetimeObserver, 2000, typePath );
- try
- {
- resourceClient.SaveResource( aTicket, "model.dali-bin" ); // Should be outside range of valid resources!
- } catch (DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
-
- DALI_TEST_ASSERT(e, "mImpl->mTickets.find(ticket->GetId()) != mImpl->mTickets.end()", TEST_LOCATION );
- }
-
- application.SendNotification(); // Flush update messages
- application.Render(); // Process save resource request
-
- // Ensure no request sent to platform abstraction
- DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::SaveResourceFunc ) );
- req = application.GetPlatform().GetRequest();
- DALI_TEST_CHECK ( req == NULL );
- END_TEST;
-}
-
-int UtcDaliInternalSaveResource03(void)
-{
- TestApplication application;
- tet_infoline("Testing SaveResource() with invalid id");
- testTicketObserver.Reset();
-
- Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
-
- Dali::ModelData modelData = BuildTreeModel();
-
- Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( Integration::ModelResourceType(), "model.dae" );
- ticket->AddObserver(testTicketObserver);
-
- // First, load a model resource
- application.SendNotification(); // Flush update messages
- application.Render(); // Process resource request
- Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Internal::ModelData& modelDataImpl = GetImplementation(modelData);
- Integration::ResourcePointer resourcePtr(&modelDataImpl);
- application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
- application.Render(); // Process LoadComplete
- application.SendNotification(); // Process event messages
- DALI_TEST_CHECK(ticket->GetLoadingState() == ResourceLoadingSucceeded);
- application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
-
- Internal::ResourceTicketPtr aTicket;
- try
- {
- resourceClient.SaveResource( aTicket, "model.dali-bin" ); // Should be outside range of valid resources!
- } catch (DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
-
- DALI_TEST_EQUALS(e.mCondition, "ticket", TEST_LOCATION);
- }
-
- application.SendNotification(); // Flush update messages
- application.Render(); // Process save resource request
-
- // Ensure no request sent to platform abstraction
- DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::SaveResourceFunc ) );
- req = application.GetPlatform().GetRequest();
- DALI_TEST_CHECK ( req == NULL );
- END_TEST;
-}
-
-
-int UtcDaliInternalSaveResource04(void)
-{
- TestApplication application;
- tet_infoline("Testing SaveResource() with valid id, but invalid filename");
- testTicketObserver.Reset();
-
- Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
-
- // First, load a model resource
- Internal::ResourceTicketPtr ticket = CheckLoadModel(application, "model.dae");
-
- resourceClient.SaveResource( ticket, "model.dali-bin" );
- application.SendNotification(); // Flush update messages
- application.Render(); // Process save resource request
-
- // Set up fail response
- application.GetPlatform().SetResourceSaveFailed(ticket->GetId(), Integration::FailureInvalidPath );
- application.Render(); // GetResources --> SaveFailed
- application.SendNotification(); // Send event messages
-
- DALI_TEST_CHECK( testTicketObserver.SaveSucceededCalled() == 0 );
- DALI_TEST_CHECK( testTicketObserver.SaveFailedCalled() == 1 );
- DALI_TEST_EQUALS( ticket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION )
-;
- END_TEST;
-}
-
-int UtcDaliInternalSaveResource05(void)
-{
- TestApplication application;
- tet_infoline("Testing SaveResource() with valid id, but invalid resource type");
- testTicketObserver.Reset();
-
- Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
-
- // First, load a bitmap resource
- Internal::ResourceTicketPtr ticket = CheckLoadBitmap(application, "bitmap.jpg", 80, 80);
-
- // Try saving it
- resourceClient.SaveResource( ticket, "bitmap.png" );
- application.SendNotification(); // Flush update messages
- application.Render(); // Process save resource request
-
- DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::SaveResourceFunc ) );
- END_TEST;
-}
-