+int UtcDaliCameraActorProjectionDirection(void)
+{
+ TestApplication application;
+
+ Integration::Scene stage = application.GetScene();
+ Vector2 stageSize = stage.GetSize();
+
+ CameraActor defaultCameraActor = stage.GetRenderTaskList().GetTask(0).GetCameraActor();
+ CameraActor expectCameraActor1 = CameraActor::New(stageSize);
+ CameraActor expectCameraActor2 = CameraActor::New(stageSize);
+ CameraActor expectCameraActor3 = CameraActor::New(stageSize);
+
+ float fieldOfView = defaultCameraActor.GetFieldOfView();
+ float aspectRatio = defaultCameraActor.GetAspectRatio();
+
+ // Calculate expect camera 1's fov.
+ float anotherFieldOfView = 2.0f * std::atan(std::tan(fieldOfView * 0.5f) / aspectRatio);
+ expectCameraActor1.SetFieldOfView(anotherFieldOfView);
+
+ // Calculate expect camera 2's fov and aspect ratio.
+ float anotherFieldOfView2 = 2.0f * std::atan(std::tan(fieldOfView * 0.5f) * aspectRatio);
+ float anotherAspectRatio = 1.0f / aspectRatio;
+ expectCameraActor2.SetFieldOfView(anotherFieldOfView2);
+ expectCameraActor2.SetAspectRatio(anotherAspectRatio);
+
+ // Calculate expect camera 3's aspect raio
+ expectCameraActor3.SetAspectRatio(anotherAspectRatio);
+
+ stage.Add(expectCameraActor1);
+ stage.Add(expectCameraActor2);
+ stage.Add(expectCameraActor3);
+
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+
+ // Test default projection direction is VERTICAL
+ DALI_TEST_EQUALS(defaultCameraActor.GetProperty<int>(Dali::DevelCameraActor::Property::PROJECTION_DIRECTION), static_cast<int>(Dali::DevelCameraActor::ProjectionDirection::VERTICAL), TEST_LOCATION);
+
+ Matrix matrixBefore, matrixAfter;
+ Matrix matrixExpect1, matrixExpect2, matrixExpect3;
+
+ defaultCameraActor.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixBefore);
+ expectCameraActor1.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixExpect1);
+ expectCameraActor2.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixExpect2);
+ expectCameraActor3.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixExpect3);
+
+ tet_printf("Check ProjectionDirection::HORIZONTAL\n");
+
+ defaultCameraActor.SetProperty(Dali::DevelCameraActor::Property::PROJECTION_DIRECTION, Dali::DevelCameraActor::ProjectionDirection::HORIZONTAL);
+ DALI_TEST_EQUALS(defaultCameraActor.GetProperty<int>(Dali::DevelCameraActor::Property::PROJECTION_DIRECTION), static_cast<int>(Dali::DevelCameraActor::ProjectionDirection::HORIZONTAL), TEST_LOCATION);
+ // NOTE : ProjectionDirection doesn't change camera actor's FieldOfView and AspectRatio value.)
+ DALI_TEST_EQUALS(defaultCameraActor.GetFieldOfView(), fieldOfView, TEST_LOCATION);
+ DALI_TEST_EQUALS(defaultCameraActor.GetAspectRatio(), aspectRatio, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+
+ defaultCameraActor.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixAfter);
+
+ // Check camera's ProjectionMatrix same as expect camera 1's ProjectionMatrix.
+ DALI_TEST_EQUALS(matrixAfter, matrixExpect1, Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+
+ tet_printf("Check ProjectionDirection::HORIZONTAL + Change aspect ratio\n");
+
+ defaultCameraActor.SetAspectRatio(anotherAspectRatio);
+ DALI_TEST_EQUALS(defaultCameraActor.GetAspectRatio(), anotherAspectRatio, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+
+ defaultCameraActor.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixAfter);
+
+ // Check camera's ProjectionMatrix same as expect camera 2's ProjectionMatrix.
+ DALI_TEST_EQUALS(matrixAfter, matrixExpect2, Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+
+ tet_printf("Check ProjectionDirection::HORIZONTAL + Change aspect ratio + Change fov\n");
+
+ defaultCameraActor.SetFieldOfView(anotherFieldOfView);
+ DALI_TEST_EQUALS(defaultCameraActor.GetFieldOfView(), anotherFieldOfView, TEST_LOCATION);
+ DALI_TEST_EQUALS(defaultCameraActor.GetAspectRatio(), anotherAspectRatio, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+
+ defaultCameraActor.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixAfter);
+
+ // Check camera's ProjectionMatrix same as expect camera 3's ProjectionMatrix.
+ DALI_TEST_EQUALS(matrixAfter, matrixExpect3, Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+
+ tet_printf("Check ProjectionDirection::VERTICAL, the original camera\n");
+
+ defaultCameraActor.SetProperty(Dali::DevelCameraActor::Property::PROJECTION_DIRECTION, Dali::DevelCameraActor::ProjectionDirection::VERTICAL);
+ defaultCameraActor.SetFieldOfView(fieldOfView);
+ defaultCameraActor.SetAspectRatio(aspectRatio);
+ DALI_TEST_EQUALS(defaultCameraActor.GetProperty<int>(Dali::DevelCameraActor::Property::PROJECTION_DIRECTION), static_cast<int>(Dali::DevelCameraActor::ProjectionDirection::VERTICAL), TEST_LOCATION);
+ DALI_TEST_EQUALS(defaultCameraActor.GetFieldOfView(), fieldOfView, TEST_LOCATION);
+ DALI_TEST_EQUALS(defaultCameraActor.GetAspectRatio(), aspectRatio, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+
+ defaultCameraActor.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixAfter);
+
+ // Check vertical camera's ProjectionMatrix same as original ProjectionMatrix.
+ DALI_TEST_EQUALS(matrixAfter, matrixBefore, Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+
+ END_TEST;
+}
+