on xenial help sign in
add tests for the spread
commit9e2fd34206dca2b5af86a83508815e0e267f68aa authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 26 Feb 2014, 17:55 (13 years ago) parentf1e24fd
5 files changed+42−5
qml/Stages/PhoneStage.qml+3−2 tests/mocks/Unity/Application/ApplicationManager.cpp+26−1 tests/mocks/Unity/Application/ApplicationManager.h+11 tests/mocks/Unity/Application/ApplicationScreenshotProvider.cpp+1−1 tests/qmltests/CMakeLists.txt+1−1
qml/Stages/PhoneStage.qml+3−2
@@ -133,7 +133,7 @@ Item {
133133 // Mir signals us that the newly started app has gotten focus before it paints something on the screen
134134 // This would result in the old app surface becoming visible for a bit.
135135 // FIXME: change appManager to only change the focusedApplicationId when the surface is ready to be shown.
136− interval: 1500
136+ interval: 0//1500
137137 repeat: false
138138 onTriggered: {
139139 priv.applicationStarting = false;
@@ -270,6 +270,7 @@ Item {
270270
271271 Flickable {
272272 id: spreadView
273+ objectName: "spreadView"
273274 anchors.fill: parent
274275 visible: spreadDragArea.status == DirectionalDragArea.Recognized || stage > 1 || snapAnimation.running
275276 contentWidth: spreadRow.width - shift
@@ -378,6 +379,7 @@ Item {
378379 model: ApplicationManager
379380 delegate: TransformedSpreadDelegate {
380381 id: appDelegate
382+ objectName: "appDelegate" + index
381383 startAngle: 45
382384 endAngle: 5
383385 startScale: 1.1
@@ -400,7 +402,6 @@ Item {
400402 if (index == 1 && spreadView.stage < 2) {
401403 tileProgress += spreadView.tileDistance / spreadView.width
402404 }
403− print("returning tile progress!!!", tileProgress, spreadView.shiftedContentX, spreadView.shift, spreadView.contentX )
404405 return tileProgress;
405406 }
406407
tests/mocks/Unity/Application/ApplicationManager.cpp+26−1
@@ -35,6 +35,7 @@ ApplicationManager::ApplicationManager(QObject *parent)
3535 , m_mainStage(0)
3636 , m_sideStageComponent(0)
3737 , m_sideStage(0)
38+ , m_rightMargin(0)
3839{
3940 buildListOfAvailableApplications();
4041}
@@ -336,10 +337,12 @@ void ApplicationManager::generateQmlStrings(ApplicationInfo *application)
336337 "Image {\n"
337338 " anchors.fill: parent\n"
338339 " anchors.topMargin: %1\n"
339− " source: \"file://%2/Dash/graphics/phone/screenshots/%3.png\"\n"
340+ " anchors.rightMargin: %2\n"
341+ " source: \"file://%3/Dash/graphics/phone/screenshots/%4.png\"\n"
340342 " smooth: true\n"
341343 " fillMode: Image.PreserveAspectCrop\n"
342344 "}").arg(topMargin)
345+ .arg(m_rightMargin)
343346 .arg(qmlDirectory())
344347 .arg(application->icon().toString());
345348 application->setWindowQml(windowQml);
@@ -568,3 +571,25 @@ void ApplicationManager::createSideStage()
568571 m_sideStage->setParentItem(shell);
569572 m_sideStage->setFlag(QQuickItem::ItemHasContents, false);
570573}
574+
575+QStringList ApplicationManager::availableApplications()
576+{
577+ QStringList appIds;
578+ Q_FOREACH(ApplicationInfo *app, m_availableApplications) {
579+ appIds << app->appId();
580+ }
581+ return appIds;
582+}
583+
584+int ApplicationManager::rightMargin() const
585+{
586+ return m_rightMargin;
587+}
588+
589+void ApplicationManager::setRightMargin(int rightMargin)
590+{
591+ m_rightMargin = rightMargin;
592+ Q_FOREACH(ApplicationInfo *app, m_availableApplications) {
593+ generateQmlStrings(app);
594+ }
595+}
tests/mocks/Unity/Application/ApplicationManager.h+11
@@ -45,6 +45,10 @@ class ApplicationManager : public ApplicationManagerInterface {
4545
4646 Q_PROPERTY(bool fake READ fake CONSTANT)
4747
48+ // Only for testing
49+ // This can be used to place some controls to right, like make tryPhoneStage for example
50+ Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin)
51+
4852 public:
4953 ApplicationManager(QObject *parent = NULL);
5054 virtual ~ApplicationManager();
@@ -99,6 +103,11 @@ class ApplicationManager : public ApplicationManagerInterface {
99103 bool suspended() const;
100104 void setSuspended(bool suspended);
101105
106+ // Only for testing
107+ Q_INVOKABLE QStringList availableApplications();
108+ int rightMargin() const;
109+ void setRightMargin(int rightMargin);
110+
102111 Q_SIGNALS:
103112 void keyboardHeightChanged();
104113 void keyboardVisibleChanged();
@@ -124,6 +133,8 @@ class ApplicationManager : public ApplicationManagerInterface {
124133 QQuickItem *m_mainStage;
125134 QQmlComponent *m_sideStageComponent;
126135 QQuickItem *m_sideStage;
136+
137+ int m_rightMargin;
127138};
128139
129140Q_DECLARE_OPERATORS_FOR_FLAGS(ApplicationManager::ExecFlags)
tests/mocks/Unity/Application/ApplicationScreenshotProvider.cpp+1−1
@@ -57,7 +57,7 @@ QImage ApplicationScreenshotProvider::requestImage(const QString &imageId, QSize
5757 Q_FOREACH (QWindow *win, unity->allWindows()) {
5858 QQuickWindow *quickWin = qobject_cast<QQuickWindow*>(win);
5959 if (quickWin) {
60− image = image.scaledToWidth(quickWin->width());
60+ image = image.scaledToWidth(quickWin->width() - m_appManager->rightMargin());
6161 }
6262 }
6363
tests/qmltests/CMakeLists.txt+1−1
@@ -89,6 +89,6 @@ add_qml_test(Panel/Indicators DefaultIndicatorPage IMPORT_PATHS ${CMAKE_BINARY_D
8989 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
9090add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
9191add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
92−add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
92+add_qml_test(Stages PhoneStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
9393 ${CMAKE_BINARY_DIR}/tests/mocks
9494 ${CMAKE_BINARY_DIR}/plugins)