40 ****************************************************************************/ |
40 ****************************************************************************/ |
41 |
41 |
42 #include <qmobilityglobal.h> |
42 #include <qmobilityglobal.h> |
43 #include <QtTest/QtTest> |
43 #include <QtTest/QtTest> |
44 |
44 |
45 #include "qvideowidget.h" |
45 #include "../../../src/multimedia/qvideowidget.h" |
46 |
46 |
47 #include "qmediaobject.h" |
47 #include "../../../src/multimedia/qmediaobject.h" |
48 #include "qmediaservice.h" |
48 #include "../../../src/multimedia/qmediaservice.h" |
49 #include "qpaintervideosurface_p.h" |
49 #include "../../../src/multimedia/qpaintervideosurface_p.h" |
50 #include "qvideooutputcontrol.h" |
50 #include "../../../src/multimedia/qvideooutputcontrol.h" |
51 #include "qvideowindowcontrol.h" |
51 #include "../../../src/multimedia/qvideowindowcontrol.h" |
52 #include "qvideowidgetcontrol.h" |
52 #include "../../../src/multimedia/qvideowidgetcontrol.h" |
53 |
53 |
54 #include "qvideorenderercontrol.h" |
54 #include "../../../src/multimedia/qvideorenderercontrol.h" |
55 #include <QtMultimedia/qabstractvideosurface.h> |
55 #include <QtMultimedia/qabstractvideosurface.h> |
56 #include <QtMultimedia/qvideosurfaceformat.h> |
56 #include <QtMultimedia/qvideosurfaceformat.h> |
57 |
57 |
58 #include <QtGui/qapplication.h> |
58 #include <QtGui/qapplication.h> |
59 |
59 |
702 |
702 |
703 widget.move(10, 10); |
703 widget.move(10, 10); |
704 |
704 |
705 widget.hide(); |
705 widget.hide(); |
706 |
706 |
707 QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); |
707 QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); |
708 } |
708 } |
709 |
709 |
710 void tst_QVideoWidget::aspectRatioWindowControl() |
710 void tst_QVideoWidget::aspectRatioWindowControl() |
711 { |
711 { |
712 QtTestVideoObject object(new QtTestWindowControl, 0, 0); |
712 QtTestVideoObject object(new QtTestWindowControl, 0, 0); |
713 object.testService->windowControl->setAspectRatioMode(QVideoWidget::IgnoreAspectRatio); |
713 object.testService->windowControl->setAspectRatioMode(Qt::IgnoreAspectRatio); |
714 |
714 |
715 QVideoWidget widget; |
715 QVideoWidget widget; |
716 widget.setMediaObject(&object); |
716 widget.setMediaObject(&object); |
717 widget.setWindowFlags(Qt::X11BypassWindowManagerHint); |
717 widget.setWindowFlags(Qt::X11BypassWindowManagerHint); |
718 |
718 |
719 // Test the aspect ratio defaults to keeping the aspect ratio. |
719 // Test the aspect ratio defaults to keeping the aspect ratio. |
720 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
720 QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); |
721 |
721 |
722 // Test the control has been informed of the aspect ratio change, post show. |
722 // Test the control has been informed of the aspect ratio change, post show. |
723 widget.show(); |
723 widget.show(); |
724 QTest::qWaitForWindowShown(&widget); |
724 QTest::qWaitForWindowShown(&widget); |
725 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
725 QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); |
726 QCOMPARE(object.testService->windowControl->aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
726 QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::KeepAspectRatio); |
727 |
727 |
728 // Test an aspect ratio change is enforced immediately while visible. |
728 // Test an aspect ratio change is enforced immediately while visible. |
729 widget.setAspectRatioMode(QVideoWidget::IgnoreAspectRatio); |
729 widget.setAspectRatioMode(Qt::IgnoreAspectRatio); |
730 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::IgnoreAspectRatio); |
730 QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); |
731 QCOMPARE(object.testService->windowControl->aspectRatioMode(), QVideoWidget::IgnoreAspectRatio); |
731 QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::IgnoreAspectRatio); |
732 |
732 |
733 // Test an aspect ratio set while not visible is respected. |
733 // Test an aspect ratio set while not visible is respected. |
734 widget.hide(); |
734 widget.hide(); |
735 widget.setAspectRatioMode(QVideoWidget::KeepAspectRatio); |
735 widget.setAspectRatioMode(Qt::KeepAspectRatio); |
736 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
736 QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); |
737 widget.show(); |
737 widget.show(); |
738 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
738 QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); |
739 QCOMPARE(object.testService->windowControl->aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
739 QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::KeepAspectRatio); |
740 } |
740 } |
741 |
741 |
742 void tst_QVideoWidget::aspectRatioWidgetControl() |
742 void tst_QVideoWidget::aspectRatioWidgetControl() |
743 { |
743 { |
744 QtTestVideoObject object(0, new QtTestWidgetControl, 0); |
744 QtTestVideoObject object(0, new QtTestWidgetControl, 0); |
745 object.testService->widgetControl->setAspectRatioMode(QVideoWidget::IgnoreAspectRatio); |
745 object.testService->widgetControl->setAspectRatioMode(Qt::IgnoreAspectRatio); |
746 |
746 |
747 QVideoWidget widget; |
747 QVideoWidget widget; |
748 widget.setMediaObject(&object); |
748 widget.setMediaObject(&object); |
749 widget.setWindowFlags(Qt::X11BypassWindowManagerHint); |
749 widget.setWindowFlags(Qt::X11BypassWindowManagerHint); |
750 |
750 |
751 // Test the aspect ratio defaults to keeping the aspect ratio. |
751 // Test the aspect ratio defaults to keeping the aspect ratio. |
752 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
752 QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); |
753 |
753 |
754 // Test the control has been informed of the aspect ratio change, post show. |
754 // Test the control has been informed of the aspect ratio change, post show. |
755 widget.show(); |
755 widget.show(); |
756 QTest::qWaitForWindowShown(&widget); |
756 QTest::qWaitForWindowShown(&widget); |
757 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
757 QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); |
758 QCOMPARE(object.testService->widgetControl->aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
758 QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::KeepAspectRatio); |
759 |
759 |
760 // Test an aspect ratio change is enforced immediately while visible. |
760 // Test an aspect ratio change is enforced immediately while visible. |
761 widget.setAspectRatioMode(QVideoWidget::IgnoreAspectRatio); |
761 widget.setAspectRatioMode(Qt::IgnoreAspectRatio); |
762 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::IgnoreAspectRatio); |
762 QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); |
763 QCOMPARE(object.testService->widgetControl->aspectRatioMode(), QVideoWidget::IgnoreAspectRatio); |
763 QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::IgnoreAspectRatio); |
764 |
764 |
765 // Test an aspect ratio set while not visible is respected. |
765 // Test an aspect ratio set while not visible is respected. |
766 widget.hide(); |
766 widget.hide(); |
767 widget.setAspectRatioMode(QVideoWidget::KeepAspectRatio); |
767 widget.setAspectRatioMode(Qt::KeepAspectRatio); |
768 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
768 QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); |
769 widget.show(); |
769 widget.show(); |
770 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
770 QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); |
771 QCOMPARE(object.testService->widgetControl->aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
771 QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::KeepAspectRatio); |
772 } |
772 } |
773 |
773 |
774 void tst_QVideoWidget::aspectRatioRendererControl() |
774 void tst_QVideoWidget::aspectRatioRendererControl() |
775 { |
775 { |
776 QtTestVideoObject object(0, 0, new QtTestRendererControl); |
776 QtTestVideoObject object(0, 0, new QtTestRendererControl); |
778 QVideoWidget widget; |
778 QVideoWidget widget; |
779 widget.setMediaObject(&object); |
779 widget.setMediaObject(&object); |
780 widget.setWindowFlags(Qt::X11BypassWindowManagerHint); |
780 widget.setWindowFlags(Qt::X11BypassWindowManagerHint); |
781 |
781 |
782 // Test the aspect ratio defaults to keeping the aspect ratio. |
782 // Test the aspect ratio defaults to keeping the aspect ratio. |
783 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
783 QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); |
784 |
784 |
785 // Test the control has been informed of the aspect ratio change, post show. |
785 // Test the control has been informed of the aspect ratio change, post show. |
786 widget.show(); |
786 widget.show(); |
787 QTest::qWaitForWindowShown(&widget); |
787 QTest::qWaitForWindowShown(&widget); |
788 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
788 QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); |
789 |
789 |
790 // Test an aspect ratio change is enforced immediately while visible. |
790 // Test an aspect ratio change is enforced immediately while visible. |
791 widget.setAspectRatioMode(QVideoWidget::IgnoreAspectRatio); |
791 widget.setAspectRatioMode(Qt::IgnoreAspectRatio); |
792 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::IgnoreAspectRatio); |
792 QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); |
793 |
793 |
794 // Test an aspect ratio set while not visible is respected. |
794 // Test an aspect ratio set while not visible is respected. |
795 widget.hide(); |
795 widget.hide(); |
796 widget.setAspectRatioMode(QVideoWidget::KeepAspectRatio); |
796 widget.setAspectRatioMode(Qt::KeepAspectRatio); |
797 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
797 QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); |
798 widget.show(); |
798 widget.show(); |
799 QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); |
799 QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); |
800 } |
800 } |
801 |
801 |
802 void tst_QVideoWidget::sizeHint_data() |
802 void tst_QVideoWidget::sizeHint_data() |
803 { |
803 { |
804 QTest::addColumn<QSize>("size"); |
804 QTest::addColumn<QSize>("size"); |